From 9eff1b893141e5845573b9a9c0224928b662474d Mon Sep 17 00:00:00 2001 From: jesopo Date: Tue, 19 Apr 2016 12:21:27 +0100 Subject: entirely reworked the timer system to work with the event system, will eventually persist all timers to database until complete in a central way. --- Timer.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'Timer.py') diff --git a/Timer.py b/Timer.py index b5017c85..32392628 100644 --- a/Timer.py +++ b/Timer.py @@ -1,11 +1,11 @@ import time class Timer(object): - def __init__(self, function, delay, *args, **kwargs): - self.function = function + def __init__(self, bot, event_name, delay, **kwargs): + self.bot = bot + self.event_name = event_name self.delay = delay self.kwargs = kwargs - self.args = args self._done = False self.call_count = 0 @@ -21,7 +21,8 @@ class Timer(object): def call(self): self._done = True self.call_count +=1 - self.function(self, *self.args, **self.kwargs) + self.bot.events.on("timer").on(self.event_name).call( + timer=self, **self.kwargs) def redo(self): self._done = False -- cgit v1.3.1-10-gc9f91