aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2015-04-28 14:18:43 +0100
committerMatthew Wild <mwild1@gmail.com>2015-04-28 14:18:43 +0100
commitb3965a9069b88e0e39cb7b5a5a62850807511f58 (patch)
tree3850822a7782935a3d52a7e2223eb110bfcd3ba2 /core
parentbe7107c0ab7c74824c1f52d668efa87f4ff1fbee (diff)
downloadprosody-b3965a9069b88e0e39cb7b5a5a62850807511f58.tar.gz
prosody-b3965a9069b88e0e39cb7b5a5a62850807511f58.zip
moduleapi: New methods for modules to conveniently wrap events
Diffstat (limited to 'core')
-rw-r--r--core/moduleapi.lua12
1 files changed, 12 insertions, 0 deletions
diff --git a/core/moduleapi.lua b/core/moduleapi.lua
index 71e19e01..f3326295 100644
--- a/core/moduleapi.lua
+++ b/core/moduleapi.lua
@@ -120,6 +120,18 @@ function api:unhook(event, handler)
return self:unhook_object_event((hosts[self.host] or prosody).events, event, handler);
end
+function api:wrap_object_event(events_object, event, handler)
+ return self:hook_object_event(assert(events_object.wrappers, "no wrappers"), event, handler);
+end
+
+function api:wrap_event(event, handler)
+ return self:wrap_object_event((hosts[self.host] or prosody).events, event, handler);
+end
+
+function api:wrap_global(event, handler)
+ return self:hook_object_event(prosody.events, event, handler, priority);
+end
+
function api:require(lib)
local f, n = pluginloader.load_code(self.name, lib..".lib.lua", self.environment);
if not f then