comparison mod_adhoc/mod_adhoc.lua @ 30:fc4806a98fc4

merge ...
author Thilo Cestonaro <thilo@cestona.ro>
date Fri, 09 Oct 2009 23:23:54 +0200
parents b9d063dd16d5
children
comparison
equal deleted inserted replaced
27:d91cb13ef0ee 30:fc4806a98fc4
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);