plugins/invited.lua

changeset 82
ec22d6deb6c0
parent 38
e1479af7ec9a
equal deleted inserted replaced
81:f86c79cabc75 82:ec22d6deb6c0
1 local xmlns_muc = "http://jabber.org/protocol/muc";
2 local xmlns_muc_user = xmlns_muc .. "#user";
3 local xmlns_jxc = "jabber:x:conference";
4
1 function riddim.plugins.invited(bot) 5 function riddim.plugins.invited(bot)
2 bot:hook("message", function(event) 6 bot:hook("message", function(event)
3 local x = event.stanza:get_child("x", "http://jabber.org/protocol/muc#user"); 7 local x = event.stanza:get_child("x", xmlns_muc_user);
4 if x then -- XEP 45 8 if x then -- XEP 45
5 local invite = x:get_child("invite"); 9 local invite = x:get_child("invite");
6 if invite then 10 if invite then
7 bot:join_room(event.stanza.attr.from); 11 bot:join_room(event.stanza.attr.from);
8 end 12 end
9 else -- try XEP 249 13 else -- try XEP 249
10 x = event.stanza:get_child("x", "jabber:x:conference"); 14 x = event.stanza:get_child("x", xmlns_jxc);
11 if x and x.attr.jid then 15 if x and x.attr.jid then
12 bot:join_room(x.attr.jid); 16 bot:join_room(x.attr.jid);
13 end 17 end
14 end 18 end
15 end); 19 end);

mercurial