Compare commits

...

2 Commits

Author SHA1 Message Date
b652dc748c Merge branch 'main' of https://git.allucanget.biz/zwitschi/thc-webhook 2025-09-17 20:51:06 +02:00
f1b831b2ca adding halftime 2025-09-17 20:51:04 +02:00

12
main.py
View File

@@ -18,7 +18,8 @@ WEBHOOK_URL = os.getenv('DISCORD_WEBHOOK_URL')
MSG_TEST = "Discord 420 timer activated. This is a test notification."
MSG_REMINDER = "5 minute reminder!"
MSG_NOTIFICATION = "420!"
MSG_HALFTIME = "Half-time!"
MSG_NOTIFICATION = "420! Blaze it!"
COL_BLUE = 0x3498db
COL_ORANGE = 0xe67e22
COL_GREEN = 0x2ecc71
@@ -27,6 +28,7 @@ COL_UNKNOWN = 0x95a5a6
messages = {
"test": {"text": MSG_TEST, "color": COL_BLUE},
"reminder": {"text": MSG_REMINDER, "color": COL_ORANGE},
"halftime": {"text": MSG_HALFTIME, "color": COL_GREEN},
"notification": {"text": MSG_NOTIFICATION, "color": COL_GREEN},
"unknown": {"text": "Unknown notification type", "color": COL_UNKNOWN}
}
@@ -91,9 +93,9 @@ def main() -> None:
# Schedule notifications
schedule.every().hour.at(":15").do(send_notification, get_message("reminder"))
schedule.every().hour.at(":20").do(send_notification, get_message("notification"))
logging.info(
"Scheduler started. Notifications will be sent every hour at :15 and :20")
schedule.every().hour.at(":45").do(send_notification, get_message("reminder"))
schedule.every().hour.at(":50").do(send_notification, get_message("halftime"))
logging.info("Scheduler started.")
# Test the notification on startup
test_notification()
@@ -101,7 +103,7 @@ def main() -> None:
try:
while True:
schedule.run_pending()
time.sleep(60) # Check every minute
time.sleep(30) # Check every 30 seconds
except KeyboardInterrupt:
logging.info("Scheduler stopped by user")
except Exception as e: