Support replay keyword in EventHookContext.hook
This commit is contained in:
parent
fd653ba117
commit
25e6bfa900
1 changed files with 6 additions and 4 deletions
|
@ -57,8 +57,10 @@ class EventHookContext(object):
|
||||||
def __init__(self, parent, context):
|
def __init__(self, parent, context):
|
||||||
self._parent = parent
|
self._parent = parent
|
||||||
self.context = context
|
self.context = context
|
||||||
def hook(self, function, priority=DEFAULT_PRIORITY, **kwargs):
|
def hook(self, function, priority=DEFAULT_PRIORITY, replay=False,
|
||||||
self._parent._context_hook(self.context, function, priority, kwargs)
|
**kwargs):
|
||||||
|
self._parent._context_hook(self.context, function, priority, replay,
|
||||||
|
kwargs)
|
||||||
def on(self, subevent, *extra_subevents, delimiter=DEFAULT_DELIMITER):
|
def on(self, subevent, *extra_subevents, delimiter=DEFAULT_DELIMITER):
|
||||||
return self._parent._context_on(self.context, subevent,
|
return self._parent._context_on(self.context, subevent,
|
||||||
extra_subevents, delimiter)
|
extra_subevents, delimiter)
|
||||||
|
@ -103,8 +105,8 @@ class EventHook(object):
|
||||||
def hook(self, function, priority=DEFAULT_PRIORITY, replay=False,
|
def hook(self, function, priority=DEFAULT_PRIORITY, replay=False,
|
||||||
**kwargs):
|
**kwargs):
|
||||||
self._hook(function, None, priority, replay, kwargs)
|
self._hook(function, None, priority, replay, kwargs)
|
||||||
def _context_hook(self, context, function, priority, kwargs):
|
def _context_hook(self, context, function, priority, replay, kwargs):
|
||||||
self._hook(function, context, priority, False, kwargs)
|
self._hook(function, context, priority, replay, kwargs)
|
||||||
def _hook(self, function, context, priority, replay, kwargs):
|
def _hook(self, function, context, priority, replay, kwargs):
|
||||||
callback = EventCallback(function, self.bot, priority, kwargs)
|
callback = EventCallback(function, self.bot, priority, kwargs)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue