2023-12-08 23:17:14 +09:00
|
|
|
import os
|
2023-12-03 23:01:55 +09:00
|
|
|
import random
|
|
|
|
|
2024-07-04 18:11:04 +09:00
|
|
|
from mastodon import Mastodon
|
2023-12-08 23:17:14 +09:00
|
|
|
from dotenv import load_dotenv
|
|
|
|
|
2023-12-08 19:38:31 +09:00
|
|
|
from src.choose_sentence import chooseSentence
|
|
|
|
from src.generate_sentence import generateSentence
|
|
|
|
|
2024-07-04 18:11:04 +09:00
|
|
|
load_dotenv()
|
2023-12-08 23:17:14 +09:00
|
|
|
|
2023-12-03 23:01:55 +09:00
|
|
|
# authentication to misskey
|
2024-07-04 18:11:04 +09:00
|
|
|
mastodon = Mastodon(access_token="token.secret", api_base_url=os.environ["MASTODON_INSTANCE_ADDRESS"])
|
2023-12-03 23:01:55 +09:00
|
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
2023-12-03 23:01:55 +09:00
|
|
|
# write note
|
2024-07-04 18:11:04 +09:00
|
|
|
toot = mastodon.toot(sentence)
|
|
|
|
toot_url = toot["url"]
|
|
|
|
toot_content = toot["content"]
|
|
|
|
toot_created_at = toot["created_at"]
|
|
|
|
print(f"{toot_created_at} {toot_url} : {toot_content}")
|
2023-12-03 23:01:55 +09:00
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
writeRandomSentenceNote()
|