mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-26 20:59:27 +01:00
src/irclib: Handle IRCds which use a MAXLIST-style value for the MAXBANS 005 key.
This commit is contained in:
parent
0880a07b72
commit
bd31b7f596
@ -400,7 +400,6 @@ class IrcState(IrcCommandDispatcher):
|
||||
_005converters = utils.InsensitivePreservingDict({
|
||||
'modes': int,
|
||||
'keylen': int,
|
||||
'maxbans': int,
|
||||
'nicklen': int,
|
||||
'userlen': int,
|
||||
'hostlen': int,
|
||||
@ -425,6 +424,34 @@ class IrcState(IrcCommandDispatcher):
|
||||
return dict(zip('ovh', s))
|
||||
_005converters['prefix'] = _prefixParser
|
||||
del _prefixParser
|
||||
def _maxlistParser(s):
|
||||
modes = ''
|
||||
limits = []
|
||||
pairs = s.split(',')
|
||||
for pair in pairs:
|
||||
(mode, limit) = pair.split(':', 1)
|
||||
modes += mode
|
||||
limits += (int(limit),) * len(mode)
|
||||
return dict(zip(modes, limits))
|
||||
_005converters['maxlist'] = _maxlistParser
|
||||
del _maxlistParser
|
||||
def _maxbansParser(s):
|
||||
# IRCd using a MAXLIST style string (IRCNet)
|
||||
if ':' in s:
|
||||
modes = ''
|
||||
limits = []
|
||||
pairs = s.split(',')
|
||||
for pair in pairs:
|
||||
(mode, limit) = pair.split(':', 1)
|
||||
modes += mode
|
||||
limits += (int(limit),) * len(mode)
|
||||
d = dict(zip(modes, limits))
|
||||
assert 'b' in d
|
||||
return d['b']
|
||||
else:
|
||||
return int(s)
|
||||
_005converters['maxbans'] = _maxbansParser
|
||||
del _maxbansParser
|
||||
def do005(self, irc, msg):
|
||||
for arg in msg.args[1:-1]: # 0 is nick, -1 is "are supported"
|
||||
if '=' in arg:
|
||||
|
@ -284,6 +284,12 @@ class IrcStateTestCase(SupyTestCase):
|
||||
self.assertEqual(state.supported['prefix']['o'], '@')
|
||||
self.assertEqual(state.supported['prefix']['v'], '+')
|
||||
|
||||
def testIRCNet005(self):
|
||||
state = irclib.IrcState()
|
||||
# Testing IRCNet's misuse of MAXBANS
|
||||
state.addMsg(self.irc, ircmsgs.IrcMsg(':irc.inet.tele.dk 005 adkwbot WALLCHOPS KNOCK EXCEPTS INVEX MODES=4 MAXCHANNELS=20 MAXBANS=beI:100 MAXTARGETS=4 NICKLEN=9 TOPICLEN=120 KICKLEN=90 :are supported by this server'))
|
||||
self.assertEqual(state.supported['maxbans'], 100)
|
||||
|
||||
def testEmptyTopic(self):
|
||||
state = irclib.IrcState()
|
||||
state.addMsg(self.irc, ircmsgs.topic('#foo'))
|
||||
|
Loading…
Reference in New Issue
Block a user