irclib: Fix crash when MOTD is sent again later in the connection.

This can happen with this ZNC module: https://wiki.znc.in/Missingmotd
or if a plugin sends a 'MOTD' command.
This commit is contained in:
Valentin Lorentz 2020-09-19 17:08:52 +02:00
parent 0a6bb49fe6
commit 5d80b2eec9
2 changed files with 16 additions and 1 deletions

View File

@ -515,6 +515,8 @@ class IrcStateFsm(object):
self._transition(irc, msg, self.States.INIT_MOTD, [ self._transition(irc, msg, self.States.INIT_MOTD, [
self.States.INIT_CAP_NEGOTIATION, self.States.INIT_CAP_NEGOTIATION,
self.States.INIT_WAITING_MOTD, self.States.INIT_WAITING_MOTD,
self.States.CONNECTED,
self.States.CONNECTED_SASL,
]) ])
def on_end_motd(self, irc, msg): def on_end_motd(self, irc, msg):
@ -522,7 +524,9 @@ class IrcStateFsm(object):
self._transition(irc, msg, self.States.CONNECTED, [ self._transition(irc, msg, self.States.CONNECTED, [
self.States.INIT_CAP_NEGOTIATION, self.States.INIT_CAP_NEGOTIATION,
self.States.INIT_WAITING_MOTD, self.States.INIT_WAITING_MOTD,
self.States.INIT_MOTD self.States.INIT_MOTD,
self.States.CONNECTED,
self.States.CONNECTED_SASL,
]) ])
def on_shutdown(self, irc, msg): def on_shutdown(self, irc, msg):

View File

@ -858,6 +858,17 @@ class IrcTestCase(SupyTestCase):
self.irc.feedMsg(msg2) self.irc.feedMsg(msg2)
self.assertEqual(list(self.irc.state.history), [msg1, msg2]) self.assertEqual(list(self.irc.state.history), [msg1, msg2])
def testMultipleMotd(self):
self.irc.reset()
self.irc.feedMsg(ircmsgs.IrcMsg(command='422'))
self.irc.feedMsg(ircmsgs.IrcMsg(command='422'))
self.irc.feedMsg(ircmsgs.IrcMsg(command='375', args=['nick']))
self.irc.feedMsg(ircmsgs.IrcMsg(command='372', args=['nick', 'some message']))
self.irc.feedMsg(ircmsgs.IrcMsg(command='376', args=['nick']))
def testMsgChannel(self): def testMsgChannel(self):
self.irc.reset() self.irc.reset()