mirror of
https://github.com/jlu5/PyLink.git
synced 2024-11-01 09:19:23 +01:00
unreal: rework services login handling
This should now support SVS2MODE without account info, used by Anope versions < 2.0? Also, the protocol module no longer stores umode +r as an actual user mode, as doing so isn't needed.
Closes #296.
(cherry picked from commit 97d09c5015
)
This commit is contained in:
parent
4e3d209831
commit
bc5a508cd7
@ -718,33 +718,55 @@ class UnrealProtocol(TS6BaseProtocol):
|
|||||||
|
|
||||||
def handle_svs2mode(self, sender, command, args):
|
def handle_svs2mode(self, sender, command, args):
|
||||||
"""
|
"""
|
||||||
Handles SVS2MODE, which sets services login information, and user modes on
|
Handles SVS2MODE, which sets services login information on the given target.
|
||||||
the given target.
|
|
||||||
"""
|
"""
|
||||||
# Logging in:
|
# Logging in (with account info, atheme):
|
||||||
# <- :NickServ SVS2MODE GL +rd GL
|
# <- :NickServ SVS2MODE GL +rd GL
|
||||||
|
|
||||||
# Logging out:
|
# Logging in (without account info, anope):
|
||||||
|
# <- :NickServ SVS2MODE 001WCO6YK +r
|
||||||
|
|
||||||
|
# Logging out (atheme):
|
||||||
# <- :NickServ SVS2MODE GL -r+d 0
|
# <- :NickServ SVS2MODE GL -r+d 0
|
||||||
|
|
||||||
# Logging in to account from a different nick:
|
# Logging in to account from a different nick:
|
||||||
# <- :NickServ SVS2MODE somenick +d GL
|
# <- :NickServ SVS2MODE somenick +d GL
|
||||||
|
|
||||||
# Handle the mode part first, the same was as SVSMODE.
|
# Logging in to account from a different nick (anope):
|
||||||
mode_hook = self.handle_svsmode(sender, command, args)
|
# <- :NickServ SVS2MODE 001SALZ01 +d GL
|
||||||
self.irc.callHooks([sender, 'SVSMODE', mode_hook])
|
# <- :NickServ SVS2MODE 001SALZ01 +r
|
||||||
|
|
||||||
# Get the target and the account name being set. 0 for accountname
|
|
||||||
# indicates a logout.
|
|
||||||
target = self._getUid(args[0])
|
target = self._getUid(args[0])
|
||||||
|
parsedmodes = self.irc.parseModes(target, args[1:])
|
||||||
|
|
||||||
|
if ('+r', None) in parsedmodes:
|
||||||
|
# Umode +r is being set (log in)
|
||||||
try:
|
try:
|
||||||
|
# Try to get the account name (mode argument for +d)
|
||||||
account = args[2]
|
account = args[2]
|
||||||
if account == '0':
|
|
||||||
account = ''
|
|
||||||
except IndexError:
|
except IndexError:
|
||||||
# No services account change, ignore
|
# If one doesn't exist, make it the same as the nick, but only if the account name
|
||||||
return
|
# wasn't set already.
|
||||||
|
if not self.irc.users[target].services_account:
|
||||||
|
account = self.irc.getFriendlyName(target)
|
||||||
else:
|
else:
|
||||||
|
return
|
||||||
|
elif ('-r', None) in parsedmodes:
|
||||||
|
# Umode -r being set.
|
||||||
|
|
||||||
|
if not self.irc.users[target].services_account:
|
||||||
|
# User already has no account; ignore.
|
||||||
|
return
|
||||||
|
|
||||||
|
account = ''
|
||||||
|
elif ('+d', None) in parsedmodes:
|
||||||
|
# Nick identification status wasn't changed, but services account was.
|
||||||
|
account = args[2]
|
||||||
|
if account == '0': # 0 means logout
|
||||||
|
account = ''
|
||||||
|
else:
|
||||||
|
return
|
||||||
|
|
||||||
self.irc.callHooks([target, 'CLIENT_SERVICES_LOGIN', {'text': account}])
|
self.irc.callHooks([target, 'CLIENT_SERVICES_LOGIN', {'text': account}])
|
||||||
|
|
||||||
def handle_umode2(self, numeric, command, args):
|
def handle_umode2(self, numeric, command, args):
|
||||||
|
Loading…
Reference in New Issue
Block a user