summaryrefslogtreecommitdiff
path: root/generate.py
diff options
context:
space:
mode:
authorAda Isopods <me@bathynomus.xyz>2024-05-20 16:28:48 -0600
committerAda Isopods <me@bathynomus.xyz>2026-10-21 23:26:17 -0600
commit3a7c55a6e5e02edfe48d38c861a760fdb5aabb4a (patch)
tree4e5b1d6c3297f1524ab42c166c7d5c30c7451c68 /generate.py
parent2618b264f3b32b67c479833f4ece9c6dcf6d0d92 (diff)
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
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