Let's make channellen parameterizable as well.

This commit is contained in:
Jeremy Fincher 2004-10-15 11:20:51 +00:00
parent a12d65160e
commit a0c0d833e3

View File

@ -120,18 +120,19 @@ def isNick(s, strictRfc=True, nicklen=None):
ret = len(s) <= nicklen ret = len(s) <= nicklen
return ret return ret
else: else:
# XXX special values to isChannel?
return not isChannel(s) and \ return not isChannel(s) and \
not isUserHostmask(s) and \ not isUserHostmask(s) and \
not ' ' in s and not '!' in s not ' ' in s and not '!' in s
def isChannel(s, chantypes='#&+!'): def isChannel(s, chantypes='#&+!', channellen=50):
"""Returns True if s is a valid IRC channel name.""" """Returns True if s is a valid IRC channel name."""
return s and \ return s and \
len(s) <= 50 and \ ',' not in s and \
',' not in s and \ '\x07' not in s and \
'\x07' not in s and \ s[0] in chantypes and \
s[0] in chantypes and \ len(s) <= channellen and \
len(s.split()) == 1 len(s.split(None, 1)) == 1
_patternCache = {} _patternCache = {}
def _hostmaskPatternEqual(pattern, hostmask): def _hostmaskPatternEqual(pattern, hostmask):