hebdobot/events/event.py

32 lines
932 B
Python

"""
Script used to...
"""
import time
import settings
SCHEDULER_DELAY = 60
class Event:
def __init__(self):
self.scheduler = None
self.callback = None
self.event_id = 1
self.last_update = time.gmtime()
def init_scheduler(self, scheduler, callback):
self.scheduler = scheduler
self.callback = callback
self.scheduler.execute_every(SCHEDULER_DELAY, self.do_something)
def do_something(self):
now = time.localtime()
# Gestion du rappel avant la revue hebdomadaire
for reminder in settings.CRON_REVIEW_REMINDERS:
if now.tm_hour == reminder[0] and now.tm_min == reminder[1]:
# On calcule le nombre de minutes avant la revue hebdomadaire
minutes = (settings.REVIEW_HOUR[0] - now.tm_hour) * 60
minutes += settings.REVIEW_HOUR[1] - now.tm_min
self.callback(minutes)