Skip to content

Instantly share code, notes, and snippets.

@zeen
Created August 10, 2009 12:40
Show Gist options
  • Save zeen/165168 to your computer and use it in GitHub Desktop.
Save zeen/165168 to your computer and use it in GitHub Desktop.
-- mod_discoitems.lua
--
-- In the config, you can add:
--
-- disco_items = {
-- {"conference.jabber.org", "The Jabber.org MUC"};
-- {"muc.example.com", "An example 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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment