diff options
| author | 2016-04-19 12:21:27 +0100 | |
|---|---|---|
| committer | 2016-04-19 12:21:27 +0100 | |
| commit | 9eff1b893141e5845573b9a9c0224928b662474d (patch) | |
| tree | 498a203db4d4473cab7196cd86c113673f9b010d /Timer.py | |
| parent | fixed words.py to always show nicknames with the same count in the same order. (diff) | |
entirely reworked the timer system to work with the event system, will eventually persist all timers to database until complete in a central way.
Diffstat (limited to 'Timer.py')
| -rw-r--r-- | Timer.py | 9 |
1 files changed, 5 insertions, 4 deletions
@@ -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 |
