Allow ModuleHook hooks to be defined as string for a single hook for list for a multiple hooks->1 method relationship

This commit is contained in:
dave 2014-10-12 00:02:20 -07:00
parent 1e8607f616
commit 49b8c4785a
1 changed files with 10 additions and 2 deletions

View File

@ -385,7 +385,11 @@ class PyIRCBot(asynchat.async_chat):
:type module: object"""
" activate a module's hooks "
for hook in module.hooks:
self.addHook(hook.hook, hook.method)
if type(hook.hook) == list:
for hookcmd in hook.hook:
self.addHook(hookcmd, hook.method)
else:
self.addHook(hook.hook, hook.method)
def unloadModuleHooks(self, module):
"""**Internal.** Disable (disconnect) hooks of a module
@ -394,7 +398,11 @@ class PyIRCBot(asynchat.async_chat):
:type module: object"""
" remove a modules hooks "
for hook in module.hooks:
self.removeHook(hook.hook, hook.method)
if type(hook.hook) == list:
for hookcmd in hook.hook:
self.removeHook(hookcmd, hook.method)
else:
self.removeHook(hook.hook, hook.method)
def addHook(self, command, method):
"""**Internal.** Enable (connect) a single hook of a module