Mercurial > prosody-hg
comparison core/moduleapi.lua @ 6640:859e9af53aa1
moduleapi: New methods for modules to conveniently wrap events
| author | Matthew Wild <mwild1@gmail.com> |
|---|---|
| date | Tue, 28 Apr 2015 14:18:43 +0100 |
| parents | 3003d041c159 |
| children | 0c363fddcdd9 deaa3d66dc2c |
comparison
equal
deleted
inserted
replaced
| 6639:3003d041c159 | 6640:859e9af53aa1 |
|---|---|
| 116 end | 116 end |
| 117 api.hook_stanza = api.hook_tag; -- COMPAT w/pre-0.9 | 117 api.hook_stanza = api.hook_tag; -- COMPAT w/pre-0.9 |
| 118 | 118 |
| 119 function api:unhook(event, handler) | 119 function api:unhook(event, handler) |
| 120 return self:unhook_object_event((hosts[self.host] or prosody).events, event, handler); | 120 return self:unhook_object_event((hosts[self.host] or prosody).events, event, handler); |
| 121 end | |
| 122 | |
| 123 function api:wrap_object_event(events_object, event, handler) | |
| 124 return self:hook_object_event(assert(events_object.wrappers, "no wrappers"), event, handler); | |
| 125 end | |
| 126 | |
| 127 function api:wrap_event(event, handler) | |
| 128 return self:wrap_object_event((hosts[self.host] or prosody).events, event, handler); | |
| 129 end | |
| 130 | |
| 131 function api:wrap_global(event, handler) | |
| 132 return self:hook_object_event(prosody.events, event, handler, priority); | |
| 121 end | 133 end |
| 122 | 134 |
| 123 function api:require(lib) | 135 function api:require(lib) |
| 124 local f, n = pluginloader.load_code(self.name, lib..".lib.lua", self.environment); | 136 local f, n = pluginloader.load_code(self.name, lib..".lib.lua", self.environment); |
| 125 if not f then | 137 if not f then |
