diff options
Diffstat (limited to 'core/modulemanager.lua')
-rw-r--r-- | core/modulemanager.lua | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/core/modulemanager.lua b/core/modulemanager.lua index 3cf893a1..d0a0f982 100644 --- a/core/modulemanager.lua +++ b/core/modulemanager.lua @@ -177,6 +177,12 @@ function unload(host, name, ...) (hosts[host] or prosody).events.remove_handler(event, handler); end end + -- unhook event handlers hooked by module:hook_global + for event, handlers in pairs(hooks:get("*", name) or NULL) do + for handler in pairs(handlers or NULL) do + prosody.events.remove_handler(event, handler); + end + end hooks:remove(host, name); if mod.module.items then -- remove items for key,t in pairs(mod.module.items) do @@ -291,6 +297,11 @@ function api:hook(event, handler, priority) (hosts[self.host] or prosody).events.add_handler(event, handler, priority); end +function api:hook_global(event, handler, priority) + hooks:set("*", self.name, event, handler, true); + prosody.events.add_handler(event, handler, priority); +end + function api:hook_stanza(xmlns, name, handler, priority) if not handler and type(name) == "function" then -- If only 2 options then they specified no xmlns |