2023-12-03 23:01:55 +09:00
|
|
|
from misskey import Misskey
|
|
|
|
import random
|
|
|
|
|
2023-12-08 19:38:31 +09:00
|
|
|
from src.setting import instance_address, access_token
|
|
|
|
from src.choose_sentence import chooseSentence
|
|
|
|
from src.generate_sentence import generateSentence
|
|
|
|
|
2023-12-03 23:01:55 +09:00
|
|
|
# authentication to misskey
|
|
|
|
misskey = Misskey(address=instance_address, i=access_token)
|
|
|
|
|
|
|
|
|
|
|
|
def writeRandomSentenceNote():
|
2023-12-08 19:38:31 +09:00
|
|
|
choice_methods = [
|
|
|
|
chooseSentence,
|
|
|
|
generateSentence
|
|
|
|
]
|
2023-12-03 23:01:55 +09:00
|
|
|
|
2023-12-08 19:38:31 +09:00
|
|
|
# choose method and get sentence
|
|
|
|
sentence: str = random.choice(choice_methods)()
|
2023-12-05 19:33:42 +09:00
|
|
|
|
|
|
|
# change newline-character to be valid
|
|
|
|
sentence = sentence.replace("\\n", "\n")
|
2023-12-03 23:01:55 +09:00
|
|
|
|
|
|
|
# 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()
|