-\r
-local t_insert = table.insert;\r
-local jid_split = require "util.jid".split;\r
-local ipairs = ipairs;\r
-local st = require "util.stanza";\r
-\r
-module "discohelper";\r
-\r
-local function addDiscoItemsHandler(self, jid, func)\r
- if self.item_handlers[jid] then\r
- t_insert(self.item_handlers[jid], func);\r
- else\r
- self.item_handlers[jid] = {func};\r
- end\r
-end\r
-\r
-local function addDiscoInfoHandler(self, jid, func)\r
- if self.info_handlers[jid] then\r
- t_insert(self.info_handlers[jid], func);\r
- else\r
- self.info_handlers[jid] = {func};\r
- end\r
-end\r
-\r
-local function handle(self, stanza)\r
- if stanza.name == "iq" and stanza.tags[1].name == "query" then\r
- local query = stanza.tags[1];\r
- local to = stanza.attr.to;\r
- local from = stanza.attr.from\r
- local node = query.attr.node or "";\r
- local to_node, to_host = jid_split(to);\r
-\r
- local reply = st.reply(stanza):query(query.attr.xmlns);\r
- local handlers;\r
- if query.attr.xmlns == "http://jabber.org/protocol/disco#info" then -- select handler set\r
- handlers = self.info_handlers;\r
- elseif query.attr.xmlns == "http://jabber.org/protocol/disco#items" then\r
- handlers = self.item_handlers;\r
- end\r
+
+local t_insert = table.insert;
+local jid_split = require "util.jid".split;
+local ipairs = ipairs;
+local st = require "util.stanza";
+
+module "discohelper";
+
+local function addDiscoItemsHandler(self, jid, func)
+ if self.item_handlers[jid] then
+ t_insert(self.item_handlers[jid], func);
+ else
+ self.item_handlers[jid] = {func};
+ end
+end
+
+local function addDiscoInfoHandler(self, jid, func)
+ if self.info_handlers[jid] then
+ t_insert(self.info_handlers[jid], func);
+ else
+ self.info_handlers[jid] = {func};
+ end
+end
+
+local function handle(self, stanza)
+ if stanza.name == "iq" and stanza.tags[1].name == "query" then
+ local query = stanza.tags[1];
+ local to = stanza.attr.to;
+ local from = stanza.attr.from
+ local node = query.attr.node or "";
+ local to_node, to_host = jid_split(to);
+
+ local reply = st.reply(stanza):query(query.attr.xmlns);
+ local handlers;
+ if query.attr.xmlns == "http://jabber.org/protocol/disco#info" then -- select handler set
+ handlers = self.info_handlers;
+ elseif query.attr.xmlns == "http://jabber.org/protocol/disco#items" then
+ handlers = self.item_handlers;
+ end