Comparison

core/moduleapi.lua @ 4719:2087d42f1e77

moduleapi: Rename module:hook_stanza() -> module:hook_tag() (hook_stanza works for compat)
author Matthew Wild <mwild1@gmail.com>
date Fri, 27 Apr 2012 18:35:33 +0100
parent 4718:a9f6088a83e3
child 4747:3f526f84dbbd
comparison
equal deleted inserted replaced
4718:a9f6088a83e3 4719:2087d42f1e77
83 83
84 function api:hook_global(event, handler, priority) 84 function api:hook_global(event, handler, priority)
85 return self:hook_object_event(prosody.events, event, handler, priority); 85 return self:hook_object_event(prosody.events, event, handler, priority);
86 end 86 end
87 87
88 function api:hook_stanza(xmlns, name, handler, priority) 88 function api:hook_tag(xmlns, name, handler, priority)
89 if not handler and type(name) == "function" then 89 if not handler and type(name) == "function" then
90 -- If only 2 options then they specified no xmlns 90 -- If only 2 options then they specified no xmlns
91 xmlns, name, handler, priority = nil, xmlns, name, handler; 91 xmlns, name, handler, priority = nil, xmlns, name, handler;
92 elseif not (handler and name) then 92 elseif not (handler and name) then
93 self:log("warn", "Error: Insufficient parameters to module:hook_stanza()"); 93 self:log("warn", "Error: Insufficient parameters to module:hook_stanza()");
94 return; 94 return;
95 end 95 end
96 return self:hook("stanza/"..(xmlns and (xmlns..":") or "")..name, function (data) return handler(data.origin, data.stanza, data); end, priority); 96 return self:hook("stanza/"..(xmlns and (xmlns..":") or "")..name, function (data) return handler(data.origin, data.stanza, data); end, priority);
97 end 97 end
98 api.hook_stanza = api.hook_tag; -- COMPAT w/pre-0.9
98 99
99 function api:require(lib) 100 function api:require(lib)
100 local f, n = pluginloader.load_code(self.name, lib..".lib.lua"); 101 local f, n = pluginloader.load_code(self.name, lib..".lib.lua");
101 if not f then 102 if not f then
102 f, n = pluginloader.load_code(lib, lib..".lib.lua"); 103 f, n = pluginloader.load_code(lib, lib..".lib.lua");