feat(send.py, toots.txt): 导出所有俗语,增加发送脚本

导出所有俗语,增加发送脚本

Signed-off-by: Ching <loooching@gmail.com>
This commit is contained in:
Ching 2024-01-04 17:16:50 +08:00
commit 0954918fe3
2 changed files with 7635 additions and 0 deletions

30
send.py Normal file
View File

@ -0,0 +1,30 @@
from mastodon import Mastodon
from loguru import logger
import random
# read all toots from file
with open('toots.txt', 'r') as f:
toots = f.read().split('\n\n')
access_token = 'your access token'
instance = 'https://mastodon.social'
mastodon_cli = Mastodon(
access_token=access_token, api_base_url=instance)
#randomly choose a toot
toot = random.choice(toots)
# post toot
try:
mastodon_cli.toot(toot)
logger.info('Toot posted, %s' % toot)
# remove toot from file
with open('toots.txt', 'w') as f:
f.write('\n\n'.join(toots))
# record toot
with open('toots_sent.txt', 'a') as f:
f.write('\n\n' + toot)
except Exception as e:
logger.error(e)

7605
toots.txt Normal file

File diff suppressed because it is too large Load Diff