diff --git a/asyncoperations.lua b/asyncoperations.lua index 682b410..4049ca9 100644 --- a/asyncoperations.lua +++ b/asyncoperations.lua @@ -33,6 +33,9 @@ end function meta:part(channel) self:send("PART %s", channel) + if self.track_users then + self.channels[channel] = nil + end end function meta:trackUsers(b) diff --git a/init.lua b/init.lua index e28e9b3..53acac7 100644 --- a/init.lua +++ b/init.lua @@ -170,6 +170,33 @@ handlers["PART"] = function(o, prefix, channel, reason) o:invoke("OnPart", user, channel, reason) end +handlers["QUIT"] = function(o, prefix, msg) + local user = parsePrefix(prefix) + if o.track_users then + for channel, v in pairs(o.channels) do + v.users[user.nick] = nil + end + end + o:invoke("OnQuit", user, msg) +end + +handlers["NICK"] = function(o, prefix, newnick) + local user = parsePrefix(prefix) + if o.track_users then + for channel, v in pairs(o.channels) do + local users = v.users + local oldinfo = users[user.nick] + if oldinfo then + users[newnick] = oldinfo + users[user.nick] = nil + o:invoke("NickChange", user, newnick, channel) + end + end + else + o:invoke("NickChange", user, newnick) + end +end + --NAMES list handlers["353"] = function(o, prefix, me, chanType, channel, names) if o.track_users then