vollmond/bot/bot.py

24 lines
549 B
Python
Raw Normal View History

2024-11-01 15:35:53 +00:00
import os
2024-11-01 11:00:09 +00:00
import moon
2024-08-28 09:24:18 +00:00
from mastodon import Mastodon
from pytz import timezone
from datetime import datetime
2024-08-28 09:24:18 +00:00
# Set up Mastodon
mastodon = Mastodon(
2024-11-25 09:13:52 +00:00
access_token='token.secret',
api_base_url=os.getenv('MASTODON_URL', 'https://mastodon.wazongtest.de/')
2024-08-28 09:24:18 +00:00
)
2024-11-25 09:13:52 +00:00
tz = timezone('Europe/Berlin')
now = datetime.now().astimezone(tz)
2024-11-25 09:13:52 +00:00
moon_text = "Aktuelle Mondphase:\n"
moon_text += moon.moon_phase_as_text(now)
2024-08-28 09:24:18 +00:00
print(moon_text)
mastodon.status_post(moon_text, visibility='unlisted')
2024-08-28 09:24:18 +00:00
me = mastodon.me()
2024-11-25 09:13:52 +00:00
print(mastodon.account_statuses(me['id'])[0])