Comparison

mod_track_muc_joins/mod_track_muc_joins.lua @ 2264:463e43dc0c4d

mod_track_muc_joins: Keep the nickname around
author Kim Alvefur <zash@zash.se>
date Sun, 31 Jul 2016 17:59:13 +0200
parent 2158:de3fb9d2673c
child 2274:43e647b8dd9f
comparison
equal deleted inserted replaced
2263:92af641fcf48 2264:463e43dc0c4d
1 local jid_bare = require "util.jid".bare; 1 local jid_bare = require "util.jid".bare;
2 local jid_split = require "util.jid".split;
2 local sessions = prosody.full_sessions; 3 local sessions = prosody.full_sessions;
3 4
4 module:hook("presence/full", function (event) 5 module:hook("presence/full", function (event)
5 local stanza = event.stanza; 6 local stanza = event.stanza;
6 local session = sessions[stanza.attr.to]; 7 local session = sessions[stanza.attr.to];
10 local muc_x = stanza:get_child("x", "http://jabber.org/protocol/muc#user"); 11 local muc_x = stanza:get_child("x", "http://jabber.org/protocol/muc#user");
11 if not muc_x then return end -- Not MUC related 12 if not muc_x then return end -- Not MUC related
12 13
13 local from_jid = stanza.attr.from; 14 local from_jid = stanza.attr.from;
14 local room = jid_bare(from_jid); 15 local room = jid_bare(from_jid);
16 local nick = jid_split(from_jid);
15 local joined = stanza.attr.type; 17 local joined = stanza.attr.type;
16 if joined == nil then 18 if joined == nil then
17 joined = true; 19 joined = nick;
18 elseif joined == "unavailable" then 20 elseif joined == "unavailable" then
19 joined = nil; 21 joined = nil;
20 else 22 else
21 -- Ignore errors and whatever 23 -- Ignore errors and whatever
22 return; 24 return;