Fix parsing of 004 message for supported umodes/chanmodes

Signed-off-by: James McCoy <jamessan@users.sourceforge.net>
This commit is contained in:
James McCoy 2011-11-07 18:58:27 +08:00 committed by Valentin Lorentz
parent 72077c8c97
commit d9531d2d29
2 changed files with 10 additions and 3 deletions

View File

@ -406,10 +406,10 @@ class IrcState(IrcCommandDispatcher):
"""Handles parsing the 004 reply """Handles parsing the 004 reply
Supported user and channel modes are cached""" Supported user and channel modes are cached"""
# msg.args = [nick, server, ircd-version, umodes, modes, # msg.args = [server, ircd-version, umodes, modes,
# modes that require arguments? (non-standard)] # modes that require arguments? (non-standard)]
self.supported['umodes'] = msg.args[3] self.supported['umodes'] = msg.args[2]
self.supported['chanmodes'] = msg.args[4] self.supported['chanmodes'] = msg.args[3]
_005converters = utils.InsensitivePreservingDict({ _005converters = utils.InsensitivePreservingDict({
'modes': int, 'modes': int,

View File

@ -290,6 +290,13 @@ class IrcStateTestCase(SupyTestCase):
state.addMsg(self.irc, ircmsgs.IrcMsg(':irc.inet.tele.dk 005 adkwbot WALLCHOPS KNOCK EXCEPTS INVEX MODES=4 MAXCHANNELS=20 MAXBANS=beI:100 MAXTARGETS=4 NICKLEN=9 TOPICLEN=120 KICKLEN=90 :are supported by this server')) state.addMsg(self.irc, ircmsgs.IrcMsg(':irc.inet.tele.dk 005 adkwbot WALLCHOPS KNOCK EXCEPTS INVEX MODES=4 MAXCHANNELS=20 MAXBANS=beI:100 MAXTARGETS=4 NICKLEN=9 TOPICLEN=120 KICKLEN=90 :are supported by this server'))
self.assertEqual(state.supported['maxbans'], 100) self.assertEqual(state.supported['maxbans'], 100)
def testSupportedUmodes(self):
state = irclib.IrcState()
state.addMsg(self.irc, ircmsgs.IrcMsg(':charm.oftc.net 004 charm.oftc.net hybrid-7.2.2+oftc1.6.8 CDGPRSabcdfgiklnorsuwxyz biklmnopstveI bkloveI'))
self.assertEqual(state.supported['umodes'], 'CDGPRSabcdfgiklnorsuwxyz')
self.assertEqual(state.supported['chanmodes'],
'biklmnopstveI')
def testEmptyTopic(self): def testEmptyTopic(self):
state = irclib.IrcState() state = irclib.IrcState()
state.addMsg(self.irc, ircmsgs.topic('#foo')) state.addMsg(self.irc, ircmsgs.topic('#foo'))