Fixed handling of QUITs and NICKs.

This commit is contained in:
Jeremy Fincher 2004-12-13 05:45:27 +00:00
parent 3b6d40bb24
commit d170a717d3
1 changed files with 14 additions and 10 deletions

View File

@ -110,8 +110,8 @@ class ChannelLogger(callbacks.Privmsg):
def __init__(self): def __init__(self):
self.__parent = super(ChannelLogger, self) self.__parent = super(ChannelLogger, self)
self.__parent.__init__() self.__parent.__init__()
self.lastMsg = None self.lastMsgs = {}
self.laststate = None self.lastStates = {}
self.logs = {} self.logs = {}
world.flushers.append(self.flush) world.flushers.append(self.flush)
@ -124,20 +124,24 @@ class ChannelLogger(callbacks.Privmsg):
def __call__(self, irc, msg): def __call__(self, irc, msg):
try: try:
if msg.args and irc.isChannel(msg.args[0]): # I don't know why I put this in, but it doesn't work, because it
super(self.__class__, self).__call__(irc, msg) # doesn't call doNick or doQuit.
if self.lastMsg: # if msg.args and irc.isChannel(msg.args[0]):
self.laststate.addMsg(irc, self.lastMsg) super(self.__class__, self).__call__(irc, msg)
else: if irc in self.lastMsgs:
self.laststate = irc.state.copy() if irc not in self.lastStates:
self.lastStates[irc] = irc.state.copy()
self.lastStates[irc].addMsg(irc, self.lastMsgs[irc])
finally: finally:
# We must make sure this always gets updated. # We must make sure this always gets updated.
self.lastMsg = msg self.lastMsgs[irc] = msg
def reset(self): def reset(self):
for log in self._logs(): for log in self._logs():
log.close() log.close()
self.logs.clear() self.logs.clear()
self.lastMsgs.clear()
self.lastStates.clear()
def _logs(self): def _logs(self):
for logs in self.logs.itervalues(): 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])) '*** %s changes topic to "%s"\n' % (msg.nick, msg.args[1]))
def doQuit(self, irc, msg): 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: if msg.nick in chan.users:
self.doLog(irc, channel, '*** %s has quit IRC\n' % msg.nick) self.doLog(irc, channel, '*** %s has quit IRC\n' % msg.nick)