summaryrefslogtreecommitdiff
path: root/generate.py
diff options
context:
space:
mode:
Diffstat (limited to 'generate.py')
-rw-r--r--generate.py34
1 files changed, 24 insertions, 10 deletions
diff --git a/generate.py b/generate.py
index a90c43e..fd4803d 100644
--- a/generate.py
+++ b/generate.py
@@ -3,27 +3,41 @@ import sys
import requests
import secrets__
+import config__
-model_f = open("model.json")
+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(80, tries=900, min_words=3)
+ text = model.make_short_sentence(config__.character_limit, tries=900, min_words=3)
generated = text is not None
text = text.replace('@','@​').replace('#','#​')
print(text)
-requests.post("https://brain.d.on-t.work/api/notes/create", json={
- 'i': secrets__.TOKEN,
+apicreate = "https://" + config__.instance_url + "/api/notes/create"\
- 'visibility': 'home',
- 'noExtractMentions': True,
- 'noExtractHashtags': True,
+if(config__.cw == ""):
+ requests.post(apicreate, json={
+ 'i': secrets__.TOKEN,
- 'text': text,
- 'cw': 'markov chain generated post'
-})
+ '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
+ }) \ No newline at end of file