From 5b40b5136d4961a821cf30807e776243e41db680 Mon Sep 17 00:00:00 2001 From: Valentin Lorentz Date: Sun, 18 Aug 2019 10:09:11 +0200 Subject: [PATCH] Limit statusmsg prefix stripping to PRIVMSG and NOTICE. --- src/irclib.py | 5 +++-- test/test_irclib.py | 9 +++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/irclib.py b/src/irclib.py index bef88fb7a..280bfefac 100644 --- a/src/irclib.py +++ b/src/irclib.py @@ -882,10 +882,11 @@ class Irc(IrcCommandDispatcher, log.Firewalled): msg.tag('receivedOn', self.network) msg.tag('receivedAt', time.time()) - # Check if the message is addressed to a channel + # Check if the message is sent to a channel if msg.args: channel = msg.args[0] - if not conf.supybot.protocols.irc.strictRfc(): + if msg.command in ('NOTICE', 'PRIVMSG') and \ + not conf.supybot.protocols.irc.strictRfc(): statusmsg_chars = self.state.supported.get('statusmsg', '') channel = channel.lstrip(statusmsg_chars) if not self.isChannel(channel): diff --git a/test/test_irclib.py b/test/test_irclib.py index d00f754be..10622233d 100644 --- a/test/test_irclib.py +++ b/test/test_irclib.py @@ -497,6 +497,15 @@ class IrcTestCase(SupyTestCase): self.irc.feedMsg(ircmsgs.IrcMsg('PRIVMSG +#linux3 :foo bar baz!')) self.assertEqual(self.irc.state.history[-1].channel, None) + # Test msg.channel is set only for PRIVMSG and NOTICE + self.irc.state.supported['statusmsg'] = '+@' + self.irc.feedMsg(ircmsgs.IrcMsg('NOTICE @#linux :foo bar baz!')) + self.assertEqual(self.irc.state.history[-1].channel, '#linux') + self.irc.feedMsg(ircmsgs.IrcMsg('NOTICE @#linux2 :foo bar baz!')) + self.assertEqual(self.irc.state.history[-1].channel, '#linux2') + self.irc.feedMsg(ircmsgs.IrcMsg('MODE @#linux3 +v foo')) + self.assertEqual(self.irc.state.history[-1].channel, None) + def testQuit(self): self.irc.reset() self.irc.feedMsg(ircmsgs.IrcMsg(':someuser JOIN #foo'))