#!/usr/bin/python3 # this is bad code and you should not emulate it # I don't know why python brings out the worst in me # -sose import requests import json import time from mastodon import Mastodon ''' Mastodon.create_app( 'pokemongamename', api_base_url = 'https://botsin.space', to_file = 'pytooter_clientcred.secret' ) ''' bot_password=open('./bot_password', 'r').readlines()[0].strip('\n') mastodon = Mastodon( client_id = 'pytooter_clientcred.secret', api_base_url = 'https://botsin.space' ) mastodon.log_in( 'sose-iwnl@protonmail.com', bot_password, to_file = 'pytooter_usercred.secret' ) mastodon = Mastodon( access_token = 'pytooter_usercred.secret', api_base_url = 'https://botsin.space' ) amount=100 # words to get at a time count_file=open('./count_file', 'r+') count=int(count_file.readlines()[0]) print("starting at " + str(count)) while True: obj = requests.get('http://api.conceptnet.io/r/Antonym?offset='+str(count)+'&limit='+str(amount)).json() for i in range(amount-1): used_words=open('./used_words', 'r+') used_words_list=used_words.readlines() onym=obj['edges'][i]['start']['label'] antonym=obj['edges'][i]['end']['label'] if obj['edges'][i]['start']['language'] == 'en' and obj['edges'][i]['end']['language'] == 'en': if onym+'\n' not in used_words_list and antonym+'\n' not in used_words_list: mastodon.toot("pokemon " + onym + " and " + antonym) print("Tooted pokemon " + onym + " and " + antonym) used_words.write(onym + '\n') used_words.close() count = count+1 count_file.seek(0,0) count_file.write(str(count)) time.sleep(3600) else: print("one of " + onym + " or " + antonym + " was already used") count = count+1 count_file.seek(0,0) count_file.write(str(count)) else: print("one of " + onym + " or " + antonym + " was not in english") count = count+1 count_file.seek(0,0) count_file.write(str(count))