From c08d43526735e06eb50ebdfba61c92bbd2b5fa4d Mon Sep 17 00:00:00 2001 From: Jeremy Fincher Date: Fri, 28 Jan 2005 13:58:59 +0000 Subject: [PATCH] Fixed bug in irclib.IrcState's handling of KICK messages; they wouldn't remove the channel if the bot was kicked from it. --- src/irclib.py | 6 +++++- test/test_irclib.py | 7 +++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/irclib.py b/src/irclib.py index 010d6a482..3941354d7 100644 --- a/src/irclib.py +++ b/src/irclib.py @@ -498,7 +498,11 @@ class IrcState(IrcCommandDispatcher): (channel, users) = msg.args[:2] chan = self.channels[channel] for user in users.split(','): - chan.removeUser(user) + if ircutils.strEqual(user, irc.nick): + del self.channels[channel] + return + else: + chan.removeUser(user) def doQuit(self, irc, msg): for channel in self.channels.itervalues(): diff --git a/test/test_irclib.py b/test/test_irclib.py index ca0e4e57d..2fba1484c 100644 --- a/test/test_irclib.py +++ b/test/test_irclib.py @@ -210,6 +210,13 @@ class IrcStateTestCase(SupyTestCase): nick = 'nick' prefix = 'nick!user@host' irc = FakeIrc() + def testKickRemovesChannel(self): + st = irclib.IrcState() + st.channels['#foo'] = irclib.ChannelState() + m = ircmsgs.kick('#foo', self.irc.nick, prefix=self.irc.prefix) + st.addMsg(self.irc, m) + self.failIf('#foo' in st.channels) + def testAddMsgRemovesOpsProperly(self): st = irclib.IrcState() st.channels['#foo'] = irclib.ChannelState()