Changeset

78:ae91c98b7e4c

mod_discoitems: Initial commit.
author Waqas Hussain <waqas20@gmail.com>
date Sun, 01 Nov 2009 18:14:42 +0500
parents 77:85b8622ccffd
children 79:34f5818c90e9
files mod_discoitems/mod_discoitems.lua
diffstat 1 files changed, 25 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mod_discoitems/mod_discoitems.lua	Sun Nov 01 18:14:42 2009 +0500
@@ -0,0 +1,25 @@
+-- mod_discoitems.lua
+--
+-- In the config, you can add:
+--
+-- disco_items = {
+--  {"proxy.eu.jabber.org", "Jabber.org SOCKS5 service"};
+--  {"conference.jabber.org", "The Jabber.org MUC"};
+-- };
+--
+
+local st = require "util.stanza";
+
+local result_query = st.stanza("query", {xmlns="http://jabber.org/protocol/disco#items"});
+for _, item in ipairs(module:get_option("disco_items") or {}) do
+	result_query:tag("item", {jid=item[1], name=item[2]}):up();
+end
+
+module:hook('iq/host/http://jabber.org/protocol/disco#items:query', function(event)
+	local stanza = event.stanza;
+	local query = stanza.tags[1];
+	if stanza.attr.type == 'get' and not query.attr.node then
+		event.origin.send(st.reply(stanza):add_child(result_query));
+		return true;
+	end
+end, 100);