aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/modulemanager.lua11
1 files changed, 11 insertions, 0 deletions
diff --git a/core/modulemanager.lua b/core/modulemanager.lua
index 748c7dce..187e4d6e 100644
--- a/core/modulemanager.lua
+++ b/core/modulemanager.lua
@@ -373,6 +373,17 @@ function api:hook(event, handler, priority)
(hosts[self.host] or 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
+ xmlns, name, handler, priority = nil, xmlns, name, handler;
+ elseif not (handler and name) then
+ self:log("warn", "Error: Insufficient parameters to module:hook_stanza()");
+ return;
+ end
+ return api.hook(self, "stanza/"..(xmlns and (xmlns..":") or "")..name, function (data) return handler(data.origin, data.stanza, data); end, priority);
+end
+
--------------------------------------------------------------------
local actions = {};