misskey_markov/main.py

38 lines
721 B
Python
Raw Normal View History

2024-11-06 07:51:00 +01:00
import markovify
import requests
import schedule
import json
import time
with open('config.json', 'r') as f:
data = json.load(f)
MAIN_URL = data["mainurl"]
with open("notes.txt") as f:
text = f.read()
text_model = markovify.NewlineText(text)
def sendpost():
requests.post(
MAIN_URL,
headers={
"Authorization": "Bearer " + data["misskey_token"]
},
json={
"cw":"markov generated post",
"text":text_model.make_short_sentence(200).replace("@", "@ ").replace("\\n", "\n")
}
)
schedule.every().day.at("12:00").do(sendpost)
while True:
schedule.run_pending()
time.sleep(1)