From d170a717d392812be3786cfd15c10451b4899724 Mon Sep 17 00:00:00 2001 From: Jeremy Fincher Date: Mon, 13 Dec 2004 05:45:27 +0000 Subject: [PATCH] Fixed handling of QUITs and NICKs. --- plugins/ChannelLogger.py | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/plugins/ChannelLogger.py b/plugins/ChannelLogger.py index 9d619eba0..ef2423cb5 100644 --- a/plugins/ChannelLogger.py +++ b/plugins/ChannelLogger.py @@ -110,8 +110,8 @@ class ChannelLogger(callbacks.Privmsg): def __init__(self): self.__parent = super(ChannelLogger, self) self.__parent.__init__() - self.lastMsg = None - self.laststate = None + self.lastMsgs = {} + self.lastStates = {} self.logs = {} world.flushers.append(self.flush) @@ -124,20 +124,24 @@ class ChannelLogger(callbacks.Privmsg): def __call__(self, irc, msg): try: - if msg.args and irc.isChannel(msg.args[0]): - super(self.__class__, self).__call__(irc, msg) - if self.lastMsg: - self.laststate.addMsg(irc, self.lastMsg) - else: - self.laststate = irc.state.copy() + # I don't know why I put this in, but it doesn't work, because it + # doesn't call doNick or doQuit. + # if msg.args and irc.isChannel(msg.args[0]): + super(self.__class__, self).__call__(irc, msg) + if irc in self.lastMsgs: + if irc not in self.lastStates: + self.lastStates[irc] = irc.state.copy() + self.lastStates[irc].addMsg(irc, self.lastMsgs[irc]) finally: # We must make sure this always gets updated. - self.lastMsg = msg + self.lastMsgs[irc] = msg def reset(self): for log in self._logs(): log.close() self.logs.clear() + self.lastMsgs.clear() + self.lastStates.clear() def _logs(self): for logs in self.logs.itervalues(): @@ -296,7 +300,7 @@ class ChannelLogger(callbacks.Privmsg): '*** %s changes topic to "%s"\n' % (msg.nick, msg.args[1])) def doQuit(self, irc, msg): - for (channel, chan) in self.laststate.channels.iteritems(): + for (channel, chan) in self.lastStates[irc].channels.iteritems(): if msg.nick in chan.users: self.doLog(irc, channel, '*** %s has quit IRC\n' % msg.nick)