aboutsummaryrefslogtreecommitdiff
path: root/EventManager.py
diff options
context:
space:
mode:
authorGravatar jesopo2018-08-31 13:39:40 +0100
committerGravatar jesopo2018-08-31 13:39:40 +0100
commita95ff9b677fb253a40fe50ad7e3dbc4667e7a315 (patch)
tree5d51a5599074fdcf8140f5074b206b4ded5e3c61 /EventManager.py
parentMove event priority mechanics to get_hooks() to factor in contextual events (diff)
signature
Support replay keyword in EventHookContext.hook
Diffstat (limited to 'EventManager.py')
-rw-r--r--EventManager.py10
1 files changed, 6 insertions, 4 deletions
diff --git a/EventManager.py b/EventManager.py
index 0d4d1dd1..4ca5837c 100644
--- a/EventManager.py
+++ b/EventManager.py
@@ -57,8 +57,10 @@ class EventHookContext(object):
def __init__(self, parent, context):
self._parent = parent
self.context = context
- def hook(self, function, priority=DEFAULT_PRIORITY, **kwargs):
- self._parent._context_hook(self.context, function, priority, kwargs)
+ def hook(self, function, priority=DEFAULT_PRIORITY, replay=False,
+ **kwargs):
+ self._parent._context_hook(self.context, function, priority, replay,
+ kwargs)
def on(self, subevent, *extra_subevents, delimiter=DEFAULT_DELIMITER):
return self._parent._context_on(self.context, subevent,
extra_subevents, delimiter)
@@ -103,8 +105,8 @@ class EventHook(object):
def hook(self, function, priority=DEFAULT_PRIORITY, replay=False,
**kwargs):
self._hook(function, None, priority, replay, kwargs)
- def _context_hook(self, context, function, priority, kwargs):
- self._hook(function, context, priority, False, kwargs)
+ def _context_hook(self, context, function, priority, replay, kwargs):
+ self._hook(function, context, priority, replay, kwargs)
def _hook(self, function, context, priority, replay, kwargs):
callback = EventCallback(function, self.bot, priority, kwargs)