markey/generate.py
will 2c6858e306 It's a fork now
Most notably, I've moved a bunch of options to a
separate config file and added the ability to not
use a CW by leaving that field blank. Plus updated
the README
2024-05-20 16:28:48 -06:00

43 lines
No EOL
914 B
Python
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import chain
import sys
import requests
import secrets__
import config__
model_f = open(config__.model_file)
model = chain.Text.from_json(model_f.read())
generated = False
text = None
while not generated:
text = model.make_short_sentence(config__.character_limit, tries=900, min_words=3)
generated = text is not None
text = text.replace('@','@').replace('#','#')
print(text)
apicreate = "https://" + config__.instance_url + "/api/notes/create"\
if(config__.cw == ""):
requests.post(apicreate, json={
'i': secrets__.TOKEN,
'visibility': 'home',
'noExtractMentions': True,
'noExtractHashtags': True,
'text': text,
})
else:
requests.post(apicreate, json={
'i': secrets__.TOKEN,
'visibility': 'home',
'noExtractMentions': True,
'noExtractHashtags': True,
'text': text,
'cw': config__.cw
})