mirror of
https://github.com/jlu5/PyLink.git
synced 2025-02-02 23:54:08 +01:00
unreal: rewrite/condense usermode change handling to be more consistent
Consistently call _check_oper_status_change() and _check_cloak_change() through a _handle_umode() wrapper. Also, handle the real portion of the mode change given in SVS2MODE.
This commit is contained in:
parent
e13f2fdbb0
commit
4ec1727888
@ -698,8 +698,9 @@ class UnrealProtocol(TS6BaseProtocol):
|
|||||||
self.updateTS(numeric, channel, their_ts)
|
self.updateTS(numeric, channel, their_ts)
|
||||||
return {'target': channel, 'modes': parsedmodes, 'channeldata': oldobj}
|
return {'target': channel, 'modes': parsedmodes, 'channeldata': oldobj}
|
||||||
else:
|
else:
|
||||||
# User mode change: pass those on to IRCS2SProtocol's handle_mode()
|
# User mode change
|
||||||
super().handle_mode(numeric, 'MODE', args)
|
target = self._get_UID(args[0])
|
||||||
|
return self._handle_umode(target, self.parse_modes(target, args[1:]))
|
||||||
|
|
||||||
def _check_cloak_change(self, uid, parsedmodes):
|
def _check_cloak_change(self, uid, parsedmodes):
|
||||||
"""
|
"""
|
||||||
@ -739,25 +740,17 @@ class UnrealProtocol(TS6BaseProtocol):
|
|||||||
"""Handles SVSMODE, used by services for setting user modes on others."""
|
"""Handles SVSMODE, used by services for setting user modes on others."""
|
||||||
# <- :source SVSMODE target +usermodes
|
# <- :source SVSMODE target +usermodes
|
||||||
target = self._get_UID(args[0])
|
target = self._get_UID(args[0])
|
||||||
modes = args[1:]
|
|
||||||
|
|
||||||
parsedmodes = self.parse_modes(target, modes)
|
return self._handle_umode(target, self.parse_modes(target, args[1:]))
|
||||||
self.apply_modes(target, parsedmodes)
|
|
||||||
|
|
||||||
# If +x/-x is being set, update cloaked host info.
|
|
||||||
self._check_cloak_change(target, parsedmodes)
|
|
||||||
|
|
||||||
return {'target': target, 'modes': parsedmodes}
|
|
||||||
|
|
||||||
def handle_svs2mode(self, sender, command, args):
|
def handle_svs2mode(self, sender, command, args):
|
||||||
"""
|
"""
|
||||||
Handles SVS2MODE, which sets services login information on the given target.
|
Handles SVS2MODE, which sets services login information on the given target.
|
||||||
"""
|
"""
|
||||||
# Once again this syntax is inconsistent and poorly documented. +d sets a
|
# In a nutshell: check for the +d argument: if it's an integer, ignore
|
||||||
# "services stamp" that some services packages use as an account name field,
|
# it and set the user's account name to their nick. Otherwise, treat the
|
||||||
# while others simply use for tracking the login time? In a nutshell: check
|
# parameter as the new account name (this is known as logging in AS some account,
|
||||||
# for the +d argument: if it's an integer, ignore it and set accountname to
|
# which is supported by atheme and Anope 2.x).
|
||||||
# the user's nick. Otherwise, treat the parameter as a nick.
|
|
||||||
|
|
||||||
# Logging in (with account info, atheme):
|
# Logging in (with account info, atheme):
|
||||||
# <- :NickServ SVS2MODE GL +rd GL
|
# <- :NickServ SVS2MODE GL +rd GL
|
||||||
@ -823,17 +816,27 @@ class UnrealProtocol(TS6BaseProtocol):
|
|||||||
return
|
return
|
||||||
|
|
||||||
self.call_hooks([target, 'CLIENT_SERVICES_LOGIN', {'text': account}])
|
self.call_hooks([target, 'CLIENT_SERVICES_LOGIN', {'text': account}])
|
||||||
|
# The internal mode +d used for services stamps clashes with the DEAF mode, so don't parse it as
|
||||||
|
# an actual mode mode parsing.
|
||||||
|
return self._handle_umode(target, [mode for mode in parsedmodes if mode[0][-1] != 'd'])
|
||||||
|
|
||||||
def handle_umode2(self, numeric, command, args):
|
def _handle_umode(self, target, parsedmodes):
|
||||||
|
"""Internal helper function to parse umode changes."""
|
||||||
|
if not parsedmodes:
|
||||||
|
return
|
||||||
|
|
||||||
|
self.apply_modes(target, parsedmodes)
|
||||||
|
|
||||||
|
self._check_oper_status_change(target, parsedmodes)
|
||||||
|
self._check_cloak_change(target, parsedmodes)
|
||||||
|
|
||||||
|
return {'target': target, 'modes': parsedmodes}
|
||||||
|
|
||||||
|
def handle_umode2(self, source, command, args):
|
||||||
"""Handles UMODE2, used to set user modes on oneself."""
|
"""Handles UMODE2, used to set user modes on oneself."""
|
||||||
# <- :GL UMODE2 +W
|
# <- :GL UMODE2 +W
|
||||||
parsedmodes = self.parse_modes(numeric, args)
|
target = self._get_UID(source)
|
||||||
self.apply_modes(numeric, parsedmodes)
|
return self._handle_umode(target, self.parse_modes(target, args))
|
||||||
|
|
||||||
self._check_oper_status_change(numeric, parsedmodes)
|
|
||||||
self._check_cloak_change(numeric, parsedmodes)
|
|
||||||
|
|
||||||
return {'target': numeric, 'modes': parsedmodes}
|
|
||||||
|
|
||||||
def handle_topic(self, numeric, command, args):
|
def handle_topic(self, numeric, command, args):
|
||||||
"""Handles the TOPIC command."""
|
"""Handles the TOPIC command."""
|
||||||
|
Loading…
Reference in New Issue
Block a user