first commit

This commit is contained in:
sose 2020-09-13 11:42:31 -07:00
commit c1ab7e16a1
4 changed files with 73 additions and 0 deletions

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
bot_password
*.secret

69
bot.py Executable file
View File

@ -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))

1
count_file Normal file
View File

@ -0,0 +1 @@
0

1
used_words Normal file
View File

@ -0,0 +1 @@