comparison mod_adhoc/mod_adhoc.lua @ 28:b9d063dd16d5

mod_adhoc, mod_adhoc_cmd_ping: Code cleanup
author Florian Zeitz <florob@babelmonkeys.de>
date Fri, 09 Oct 2009 21:47:20 +0200
parents 2be8bcce5b18
children
comparison
equal deleted inserted replaced
26:1fb5b8c20004 28:b9d063dd16d5
14 if stanza.attr.type == "get" and stanza.tags[1].attr.node and stanza.tags[1].attr.node == "http://jabber.org/protocol/commands" then 14 if stanza.attr.type == "get" and stanza.tags[1].attr.node and stanza.tags[1].attr.node == "http://jabber.org/protocol/commands" then
15 reply = st.reply(stanza); 15 reply = st.reply(stanza);
16 reply:tag("query", {xmlns="http://jabber.org/protocol/disco#items", node="http://jabber.org/protocol/commands"}) 16 reply:tag("query", {xmlns="http://jabber.org/protocol/disco#items", node="http://jabber.org/protocol/commands"})
17 for i = 1, #commands do 17 for i = 1, #commands do
18 -- module:log("info", "adding command %s", commands[i].name); 18 -- module:log("info", "adding command %s", commands[i].name);
19 reply:tag("item", {name=commands[i].name, node=commands[i].node, jid=module:get_host()}); 19 reply:tag("item", {name=commands[i].name, node=commands[i].node, jid=module:get_host()});
20 reply:up(); 20 reply:up();
21 end 21 end
22 origin.send(reply); 22 origin.send(reply);
23 return true; 23 return true;
24 end 24 end
41 end, 500); 41 end, 500);
42 42
43 local _G = _G; 43 local _G = _G;
44 local t_remove = _G.table.remove; 44 local t_remove = _G.table.remove;
45 module:hook("item-removed/adhoc", function (event) 45 module:hook("item-removed/adhoc", function (event)
46 module:log("debug", "Remove function called");
47 for i = 1, #commands do 46 for i = 1, #commands do
48 if commands[i].node == event.item.node then 47 if commands[i].node == event.item.node then
49 t_remove(commands, i); 48 t_remove(commands, i);
49 break;
50 end 50 end
51 end 51 end
52 end, 500); 52 end, 500);