vollmond/bot/testmoon.py
2024-08-28 11:24:18 +02:00

44 lines
1 KiB
Python

from astral.moon import phase
from mastodon import Mastodon
import datetime
# Set up Mastodon
mastodon = Mastodon(
access_token = 'testtoken.secret',
# api_base_url = 'https://fnordon.de/'
api_base_url = 'https://mastodon.wazongtest.de/'
)
now = datetime.datetime.now()
moon_today = phase(now)
until_full = 14.00 - moon_today
print("until_full", end=": ")
print(until_full)
if (until_full<0):
until_full+=29.53
print("corrected", end=": ")
print(until_full)
moon_yesterday = phase(now - datetime.timedelta(days=1))
moon_tomorrow = phase(now + datetime.timedelta(days=1))
next_full = now + datetime.timedelta(days=(until_full*1.055))
moon_text = "Next full moon " + format(next_full.isoformat())
# mastodon.status_post(moon_text)
print("Heute", end=": ")
print(now)
print("Mext full", end=": ")
print(next_full)
print("Mond gestern", end=": ")
print(moon_yesterday)
print("Mond heute", end=": ")
print(moon_today)
print("bis Vollmond", end=": ")
print(until_full)
print("Mond morgen", end=": ")
print(moon_tomorrow)