core/modulemanager.lua

changeset 1333
d74441a2f3e8
parent 1330
baad431dabc5
child 1334
6846c5cc9ce2
--- a/core/modulemanager.lua	Fri Jun 12 13:06:41 2009 +0500
+++ b/core/modulemanager.lua	Fri Jun 12 13:46:31 2009 +0500
@@ -128,7 +128,7 @@
 	
 	local success, ret = pcall(mod);
 	if not success then
-		log("error", "Error initialising module '%s': %s", name or "nil", ret or "nil");
+		log("error", "Error initialising module '%s': %s", module_name or "nil", ret or "nil");
 		return nil, ret;
 	end
 	
@@ -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