Added unicode compatibility, better stdout info
This commit is contained in:
parent
a701196c2e
commit
acec5b6668
2 changed files with 69 additions and 67 deletions
8
gen.py
8
gen.py
|
@ -3,14 +3,14 @@ import json
|
||||||
import time
|
import time
|
||||||
from mastodon import Mastodon
|
from mastodon import Mastodon
|
||||||
|
|
||||||
api_base_url = "https://botsin.space"
|
api_base_url = "https://botsin.space" #todo: this shouldn't be hardcoded
|
||||||
|
|
||||||
client = Mastodon(
|
client = Mastodon(
|
||||||
client_id="clientcred.secret",
|
client_id="clientcred.secret",
|
||||||
access_token="usercred.secret",
|
access_token="usercred.secret",
|
||||||
api_base_url=api_base_url)
|
api_base_url=api_base_url)
|
||||||
|
|
||||||
with open("corpus.txt") as fp:
|
with open("corpus.txt", encoding="utf-8") as fp:
|
||||||
model = markovify.NewlineText(fp.read())
|
model = markovify.NewlineText(fp.read())
|
||||||
|
|
||||||
print("tooting")
|
print("tooting")
|
||||||
|
@ -18,4 +18,6 @@ sentence = None
|
||||||
# you will make that damn sentence
|
# you will make that damn sentence
|
||||||
while sentence is None:
|
while sentence is None:
|
||||||
sentence = model.make_sentence(tries=100000)
|
sentence = model.make_sentence(tries=100000)
|
||||||
client.toot(sentence.replace("\0", "\n"))
|
toot = sentence.replace("\0", "\n")
|
||||||
|
client.toot(toot)
|
||||||
|
print("Created toot: {}".format(toot))
|
||||||
|
|
4
main.py
4
main.py
|
@ -83,8 +83,8 @@ client = Mastodon(
|
||||||
me = client.account_verify_credentials()
|
me = client.account_verify_credentials()
|
||||||
following = client.account_following(me.id)
|
following = client.account_following(me.id)
|
||||||
|
|
||||||
with open("corpus.txt", "w+") as fp:
|
with open("corpus.txt", "w+", encoding="utf-8") as fp:
|
||||||
for f in following:
|
for f in following:
|
||||||
print(f.username)
|
print("Downloading toots for user @{}".format(f.username))
|
||||||
for t in get_toots(client, f.id):
|
for t in get_toots(client, f.id):
|
||||||
fp.write(t + "\n")
|
fp.write(t + "\n")
|
||||||
|
|
Loading…
Reference in a new issue