comparison mod_discoitems/mod_discoitems.lua @ 78:ae91c98b7e4c

mod_discoitems: Initial commit.
author Waqas Hussain <waqas20@gmail.com>
date Sun, 01 Nov 2009 18:14:42 +0500
parents
children
comparison
equal deleted inserted replaced
77:85b8622ccffd 78:ae91c98b7e4c
1 -- mod_discoitems.lua
2 --
3 -- In the config, you can add:
4 --
5 -- disco_items = {
6 -- {"proxy.eu.jabber.org", "Jabber.org SOCKS5 service"};
7 -- {"conference.jabber.org", "The Jabber.org MUC"};
8 -- };
9 --
10
11 local st = require "util.stanza";
12
13 local result_query = st.stanza("query", {xmlns="http://jabber.org/protocol/disco#items"});
14 for _, item in ipairs(module:get_option("disco_items") or {}) do
15 result_query:tag("item", {jid=item[1], name=item[2]}):up();
16 end
17
18 module:hook('iq/host/http://jabber.org/protocol/disco#items:query', function(event)
19 local stanza = event.stanza;
20 local query = stanza.tags[1];
21 if stanza.attr.type == 'get' and not query.attr.node then
22 event.origin.send(st.reply(stanza):add_child(result_query));
23 return true;
24 end
25 end, 100);