From 3a7c55a6e5e02edfe48d38c861a760fdb5aabb4a Mon Sep 17 00:00:00 2001 From: Ada Isopods Date: Mon, 20 May 2024 16:28:48 -0600 Subject: 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 --- generate.py | 34 ++++++++++++++++++++++++---------- 1 file changed, 24 insertions(+), 10 deletions(-) (limited to 'generate.py') 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 -- cgit v1.2.3