Comparison

core/moduleapi.lua @ 7947:24170d74b00b

core: Split some very long lines [luacheck]
author Kim Alvefur <zash@zash.se>
date Sat, 04 Mar 2017 17:49:48 +0100
parent 7646:6210dfaec84f
child 7950:f91e7ec9654e
child 7975:c64ddee9d671
comparison
equal deleted inserted replaced
7945:1f4a0e0b7167 7947:24170d74b00b
113 xmlns, name, handler, priority = nil, xmlns, name, handler; 113 xmlns, name, handler, priority = nil, xmlns, name, handler;
114 elseif not (handler and name) then 114 elseif not (handler and name) then
115 self:log("warn", "Error: Insufficient parameters to module:hook_stanza()"); 115 self:log("warn", "Error: Insufficient parameters to module:hook_stanza()");
116 return; 116 return;
117 end 117 end
118 return self:hook("stanza/"..(xmlns and (xmlns..":") or "")..name, function (data) return handler(data.origin, data.stanza, data); end, priority); 118 return self:hook("stanza/"..(xmlns and (xmlns..":") or "")..name,
119 function (data) return handler(data.origin, data.stanza, data); end, priority);
119 end 120 end
120 api.hook_stanza = api.hook_tag; -- COMPAT w/pre-0.9 121 api.hook_stanza = api.hook_tag; -- COMPAT w/pre-0.9
121 122
122 function api:unhook(event, handler) 123 function api:unhook(event, handler)
123 return self:unhook_object_event((hosts[self.host] or prosody).events, event, handler); 124 return self:unhook_object_event((hosts[self.host] or prosody).events, event, handler);
185 local default_path_components = { self.host, self.name }; 186 local default_path_components = { self.host, self.name };
186 for i = 1, paths.n do 187 for i = 1, paths.n do
187 local path = paths[i]; 188 local path = paths[i];
188 if path:sub(1,1) ~= "/" then -- Prepend default components 189 if path:sub(1,1) ~= "/" then -- Prepend default components
189 local n_components = select(2, path:gsub("/", "%1")); 190 local n_components = select(2, path:gsub("/", "%1"));
190 path = (n_components<#default_path_components and "/" or "")..t_concat(default_path_components, "/", 1, #default_path_components-n_components).."/"..path; 191 path = (n_components<#default_path_components and "/" or "")
192 ..t_concat(default_path_components, "/", 1, #default_path_components-n_components).."/"..path;
191 end 193 end
192 local shared = shared_data[path]; 194 local shared = shared_data[path];
193 if not shared then 195 if not shared then
194 shared = {}; 196 shared = {};
195 if path:match("%-cache$") then 197 if path:match("%-cache$") then