core/modulemanager.lua

changeset 1328
0709c9564b1c
parent 1326
4f1994f7bd54
parent 1321
0698d0d39b35
child 1330
baad431dabc5
--- a/core/modulemanager.lua	Sun Jun 07 18:06:01 2009 +0500
+++ b/core/modulemanager.lua	Sun Jun 07 14:19:36 2009 +0100
@@ -373,6 +373,17 @@
 	(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 = {};

mercurial