commit c1ab7e16a1eb851503730944c6ff8a8a0d8ee6ec Author: sose Date: Sun Sep 13 11:42:31 2020 -0700 first commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..0d27957 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +bot_password +*.secret diff --git a/bot.py b/bot.py new file mode 100755 index 0000000..c446327 --- /dev/null +++ b/bot.py @@ -0,0 +1,69 @@ +#!/usr/bin/python +# 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' +) +mastodon.toot('Hello world!') + +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("Pokémon" + 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)) + diff --git a/count_file b/count_file new file mode 100644 index 0000000..573541a --- /dev/null +++ b/count_file @@ -0,0 +1 @@ +0 diff --git a/used_words b/used_words new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/used_words @@ -0,0 +1 @@ +