From 5d80b2eec9bbfe4332073bb126d9a407dea034f9 Mon Sep 17 00:00:00 2001 From: Valentin Lorentz Date: Sat, 19 Sep 2020 17:08:52 +0200 Subject: [PATCH] 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. --- src/irclib.py | 6 +++++- test/test_irclib.py | 11 +++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/irclib.py b/src/irclib.py index 14f57aea8..f8140fdae 100644 --- a/src/irclib.py +++ b/src/irclib.py @@ -515,6 +515,8 @@ class IrcStateFsm(object): self._transition(irc, msg, self.States.INIT_MOTD, [ self.States.INIT_CAP_NEGOTIATION, self.States.INIT_WAITING_MOTD, + self.States.CONNECTED, + self.States.CONNECTED_SASL, ]) def on_end_motd(self, irc, msg): @@ -522,7 +524,9 @@ class IrcStateFsm(object): self._transition(irc, msg, self.States.CONNECTED, [ self.States.INIT_CAP_NEGOTIATION, 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): diff --git a/test/test_irclib.py b/test/test_irclib.py index ca7ea0d97..2ddabe276 100644 --- a/test/test_irclib.py +++ b/test/test_irclib.py @@ -858,6 +858,17 @@ class IrcTestCase(SupyTestCase): self.irc.feedMsg(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): self.irc.reset()