hebdobot/events/event.py

33 lines
855 B
Python
Raw Normal View History

"""
2024-04-06 22:27:24 +02:00
Script used to send notifications for review on IRC.
"""
2024-04-06 22:27:24 +02:00
from dataclasses import dataclass
import time
2024-04-06 22:27:24 +02:00
EXECUTE_EVERY = 1
EXECUTE_AT = 2
EXECUTE_AFTER = 3
2024-04-06 22:27:24 +02:00
@dataclass
class Event:
2024-04-06 22:27:24 +02:00
callback : str = ""
scheduler_type : int = 1
scheduler_delay : int = 60
2024-04-06 22:27:24 +02:00
def init(self, scheduler, callback_func):
self.scheduler = scheduler
2024-04-06 22:27:24 +02:00
self.callback_func = callback_func
if self.scheduler_type == EXECUTE_EVERY:
self.scheduler.execute_every(self.scheduler_delay, self._run)
elif self.scheduler_type == EXECUTE_AT:
self.scheduler.execute_at(self.scheduler_delay, self._run)
elif self.scheduler_type == EXECUTE_AFTER:
self.scheduler.execute_after(self.scheduler_delay, self._run)
def _run(self):
self.run(time.localtime())
2024-04-06 22:27:24 +02:00
def run(self, now):
pass