irclib: Don't error when 004 is missing umodes and chanmodes.

This commit is contained in:
Valentin Lorentz 2020-07-05 19:45:08 +02:00
parent 76edd3189c
commit 0284ed9ebd
2 changed files with 14 additions and 3 deletions

View File

@ -624,9 +624,14 @@ class IrcState(IrcCommandDispatcher, log.Firewalled):
Supported user and channel modes are cached"""
# msg.args = [nick, server, ircd-version, umodes, modes,
# modes that require arguments? (non-standard)]
self.ircd = msg.args[2] if len(msg.args) >= 3 else msg.args[1]
self.supported['umodes'] = frozenset(msg.args[3])
self.supported['chanmodes'] = frozenset(msg.args[4])
self.ircd = msg.args[2] if len(msg.args) > 2 else msg.args[1]
# The conditionals are for Twitch, which doesn't send umodes or
# chanmodes.
if len(msg.args) > 3:
self.supported['umodes'] = frozenset(msg.args[3])
if len(msg.args) > 4:
self.supported['chanmodes'] = frozenset(msg.args[4])
_005converters = utils.InsensitivePreservingDict({
'modes': lambda s: int(s) if s else None, # it's optional

View File

@ -387,6 +387,12 @@ class IrcStateTestCase(SupyTestCase):
self.assertEqual(state.supported['chanmodes'],
frozenset('biklmnopstveI'))
def testShort004(self):
state = irclib.IrcState()
state.addMsg(self.irc, ircmsgs.IrcMsg(':coulomb.oftc.net 004 testnick coulomb.oftc.net hybrid-7.2.2+oftc1.6.8'))
self.assertNotIn('umodes', state.supported)
self.assertNotIn('chanmodes', state.supported)
def testEmptyTopic(self):
state = irclib.IrcState()
state.addMsg(self.irc, ircmsgs.topic('#foo'))