Compare commits
2 Commits
b8cb3aa71e
...
b652dc748c
| Author | SHA1 | Date | |
|---|---|---|---|
| b652dc748c | |||
| f1b831b2ca |
12
main.py
12
main.py
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user