diff options
author | Matthew Wild <mwild1@gmail.com> | 2009-06-06 16:41:09 +0100 |
---|---|---|
committer | Matthew Wild <mwild1@gmail.com> | 2009-06-06 16:41:09 +0100 |
commit | 114a89b6646b5cfe88cebe83422e84ef9e3d94b7 (patch) | |
tree | d201b9c0d847aeb94abc8233f761a7107c76df73 | |
parent | df5c3bcaafdc7b428adb9d0d0b2929e654855bae (diff) | |
download | prosody-114a89b6646b5cfe88cebe83422e84ef9e3d94b7.tar.gz prosody-114a89b6646b5cfe88cebe83422e84ef9e3d94b7.zip |
modulemanager: Add module:hook([xmlns, ] name, handler) which uses new stanza events
-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 18b511e6..92a50abb 100644 --- a/core/modulemanager.lua +++ b/core/modulemanager.lua @@ -373,6 +373,17 @@ function api:hook(event, handler) (hosts[self.host] or prosody).events.add_handler(event, handler); end +function api:hook_stanza(xmlns, name, handler) + if not handler and type(name) == "function" then + -- If only 2 options then they specified no xmlns + xmlns, name, handler = nil, xmlns, name; + elseif not (handler and name and xmlns) then + module: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); +end + -------------------------------------------------------------------- local actions = {}; |