From d4cac026d43de49b378d16b57b7d9a89a92ea397 Mon Sep 17 00:00:00 2001 From: Valentin Lorentz Date: Sun, 4 Aug 2019 21:28:45 +0200 Subject: [PATCH] Remove '+' from the default chantypes. It's more likely to be a statusmsg than chantype. --- src/ircutils.py | 6 +++--- test/test_ircutils.py | 6 ++++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/ircutils.py b/src/ircutils.py index 010648105..8a87e66fc 100644 --- a/src/ircutils.py +++ b/src/ircutils.py @@ -143,7 +143,7 @@ def areNicks(s, strictRfc=True, nicklen=None): nick = functools.partial(isNick, strictRfc=strictRfc, nicklen=nicklen) return all(map(nick, s.split(','))) -def isChannel(s, chantypes='#&+!', channellen=50): +def isChannel(s, chantypes='#&!', channellen=50): """s => bool Returns True if s is a valid IRC channel name.""" return s and \ @@ -153,13 +153,13 @@ def isChannel(s, chantypes='#&+!', channellen=50): len(s) <= channellen and \ len(s.split(None, 1)) == 1 -def areChannels(s, chantypes='#&+!',channellen=50): +def areChannels(s, chantypes='#&!', channellen=50): """Like 'isChannel(x)' but for comma-separated list.""" chan = functools.partial(isChannel, chantypes=chantypes, channellen=channellen) return all(map(chan, s.split(','))) -def areReceivers(s, strictRfc=True, nicklen=None, chantypes='#&+!', +def areReceivers(s, strictRfc=True, nicklen=None, chantypes='#&!', channellen=50): """Like 'isNick(x) or isChannel(x)' but for comma-separated list.""" nick = functools.partial(isNick, strictRfc=strictRfc, nicklen=nicklen) diff --git a/test/test_ircutils.py b/test/test_ircutils.py index 8d762584c..8d77629e1 100644 --- a/test/test_ircutils.py +++ b/test/test_ircutils.py @@ -75,11 +75,13 @@ class FunctionsTestCase(SupyTestCase): def testIsChannel(self): self.failUnless(ircutils.isChannel('#')) self.failUnless(ircutils.isChannel('&')) - self.failUnless(ircutils.isChannel('+')) + self.failIf(ircutils.isChannel('+')) + self.failUnless(ircutils.isChannel('+', chantypes='#&+!')) self.failUnless(ircutils.isChannel('!')) self.failUnless(ircutils.isChannel('#foo')) self.failUnless(ircutils.isChannel('&foo')) - self.failUnless(ircutils.isChannel('+foo')) + self.failIf(ircutils.isChannel('+foo')) + self.failUnless(ircutils.isChannel('+foo', chantypes='#&+!')) self.failUnless(ircutils.isChannel('!foo')) self.failIf(ircutils.isChannel('#foo bar')) self.failIf(ircutils.isChannel('#foo,bar'))