aboutsummaryrefslogtreecommitdiff
path: root/Timer.py
diff options
context:
space:
mode:
authorGravatar jesopo2016-04-19 12:21:27 +0100
committerGravatar jesopo2016-04-19 12:21:27 +0100
commit9eff1b893141e5845573b9a9c0224928b662474d (patch)
tree498a203db4d4473cab7196cd86c113673f9b010d /Timer.py
parentfixed 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.py9
1 files changed, 5 insertions, 4 deletions
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