Fixed bug in irclib.IrcState's handling of KICK messages; they wouldn't remove the channel if the bot was kicked from it.

This commit is contained in:
Jeremy Fincher 2005-01-28 13:58:59 +00:00
parent 5fd6bbb52d
commit c08d435267
2 changed files with 12 additions and 1 deletions

View File

@ -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():

View File

@ -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()