misskey-random-sentence-bot/main.py

35 lines
828 B
Python

import os
import random
from misskey import Misskey
from dotenv import load_dotenv
from src.choose_sentence import chooseSentence
from src.generate_sentence import generateSentence
load_dotenv()
# authentication to misskey
misskey = Misskey(address=os.environ["MISSKEY_INSTANCE_ADDRESS"], i=os.environ["MISSKEY_ACCESS_TOKEN"])
def writeRandomSentenceNote():
choice_methods = [
chooseSentence,
generateSentence
]
# choose method and get sentence
sentence: str = random.choice(choice_methods)()
# write note
random_sentence_note = misskey.notes_create(text=sentence)
note_id = random_sentence_note["createdNote"]["id"]
note_text = random_sentence_note["createdNote"]["text"]
print(f"{note_id} | {note_text}")
if __name__ == "__main__":
writeRandomSentenceNote()