# HG changeset patch # User Thilo Cestonaro # Date 1268918165 -3600 # Node ID 8c3bec93087bd0f41dc32cc61c676c96c372b36a # Parent 9663866ca475dbb7b7bf0413f50ebf62f86c3a35 groupchat.lua: make the occupant-left event work tell.lua: double check the room and clear told tellings. diff -r 9663866ca475 -r 8c3bec93087b plugins/groupchat.lua --- a/plugins/groupchat.lua Thu Mar 18 12:51:48 2010 +0100 +++ b/plugins/groupchat.lua Thu Mar 18 14:16:05 2010 +0100 @@ -60,23 +60,21 @@ local occupants = room.occupants; room:hook("presence", function (presence) local nick = presence.nick; - if not occupants[nick] then - if presence.type ~= "unavailable" then - occupants[nick] = { - nick = nick; - jid = presence.stanza.attr.from; - presence = presence.stanza; - }; - if nick == room.nick then - room.bot:event("groupchat/joined", room); - else - room:event("occupant-joined", occupants[nick]); - end + if not occupants[nick] and presence.stanza.attr.type ~= "unavailable" then + occupants[nick] = { + nick = nick; + jid = presence.stanza.attr.from; + presence = presence.stanza; + }; + if nick == room.nick then + room.bot:event("groupchat/joined", room); else - occupants[nick].presence = presence.stanza; - room:event("occupant-left", occupants[nick]); - occupants[nick] = nil; + room:event("occupant-joined", occupants[nick]); end + elseif occupants[nick] and presence.stanza.attr.type == "unavailable" then + occupants[nick].presence = presence.stanza; + room:event("occupant-left", occupants[nick]); + occupants[nick] = nil; end end); self:send(st.presence({to = jid.."/"..nick}));