3
0
mirror of https://github.com/jlu5/PyLink.git synced 2024-11-01 01:09:22 +01:00

clientbot: ignore missing args in 324 / RPL_CHANNELMODEIS

Fixes #537.
This commit is contained in:
James Lu 2018-06-08 18:45:20 -07:00
parent 180da83b4e
commit 31a0d36990
2 changed files with 12 additions and 7 deletions

View File

@ -768,7 +768,8 @@ class PyLinkNetworkCoreWithUtils(PyLinkNetworkCore):
# Band-aid patch here to prevent bad bans set by Janus forwarding people into invalid channels.
return bool(cls._HOSTMASK_RE.match(text) and '#' not in text)
def _parse_modes(self, args, existing, supported_modes, is_channel=False, prefixmodes=None):
def _parse_modes(self, args, existing, supported_modes, is_channel=False, prefixmodes=None,
ignore_missing_args=False):
"""
parse_modes() core.
@ -839,7 +840,8 @@ class PyLinkNetworkCoreWithUtils(PyLinkNetworkCore):
log.debug('Mode %s: Only has parameter when setting.', mode)
arg = args.pop(0)
except IndexError:
log.warning('(%s) Error while parsing mode %r: mode requires an '
logfunc = log.debug if ignore_missing_args else log.warning
logfunc('(%s) Error while parsing mode %r: mode requires an '
'argument but none was found. (modestring: %r)',
self.name, mode, modestring)
continue # Skip this mode; don't error out completely.
@ -851,7 +853,7 @@ class PyLinkNetworkCoreWithUtils(PyLinkNetworkCore):
return res
def parse_modes(self, target, args):
def parse_modes(self, target, args, ignore_missing_args=False):
"""Parses a modestring list into a list of (mode, argument) tuples.
['+mitl-o', '3', 'person'] => [('+m', None), ('+i', None), ('+t', None), ('+l', '3'), ('-o', 'person')]
"""
@ -880,7 +882,7 @@ class PyLinkNetworkCoreWithUtils(PyLinkNetworkCore):
prefixmodes = self._channels[target].prefixmodes
return self._parse_modes(args, oldmodes, supported_modes, is_channel=is_channel,
prefixmodes=prefixmodes)
prefixmodes=prefixmodes, ignore_missing_args=ignore_missing_args)
def _apply_modes(self, old_modelist, changedmodes, is_channel=False,
prefixmodes=None):

View File

@ -972,7 +972,10 @@ class ClientbotWrapperProtocol(IRCCommonProtocol):
channel = args[1]
modes = args[2:]
log.debug('(%s) Got RPL_CHANNELMODEIS (324) modes %s for %s', self.name, modes, channel)
changedmodes = self.parse_modes(channel, modes)
# Sometimes IRCds suppress arguments to +lk, so ignore missing args
changedmodes = self.parse_modes(channel, modes, ignore_missing_args=True)
self.apply_modes(channel, changedmodes)
def handle_329(self, source, command, args):