3
0
mirror of https://github.com/jlu5/PyLink.git synced 2024-12-26 04:32:51 +01:00

protocols: s/_getNick/_getUid/g

The old function name _getNick was a bit misleading, as the function converted nicks to UIDs, not the other way around..
This commit is contained in:
James Lu 2016-04-08 22:21:37 -07:00
parent 248c0cbb78
commit 62c8cd2405
2 changed files with 12 additions and 12 deletions

View File

@ -44,7 +44,7 @@ class TS6BaseProtocol(Protocol):
else: else:
return sname # Fall back to given text instead of None return sname # Fall back to given text instead of None
def _getNick(self, target): def _getUid(self, target):
"""Converts a nick argument to its matching UID. This differs from irc.nickToUid() """Converts a nick argument to its matching UID. This differs from irc.nickToUid()
in that it returns the original text instead of None, if no matching nick is found.""" in that it returns the original text instead of None, if no matching nick is found."""
target = self.irc.nickToUid(target) or target target = self.irc.nickToUid(target) or target
@ -221,7 +221,7 @@ class TS6BaseProtocol(Protocol):
numeric = sender_server numeric = sender_server
else: else:
# Sender is a user. # Sender is a user.
numeric = self._getNick(sender) numeric = self._getUid(sender)
# parseTS6Args() will raise IndexError if the TS6 sender prefix is missing. # parseTS6Args() will raise IndexError if the TS6 sender prefix is missing.
except IndexError: except IndexError:
@ -269,7 +269,7 @@ class TS6BaseProtocol(Protocol):
"""Handles incoming KICKs.""" """Handles incoming KICKs."""
# :70MAAAAAA KICK #test 70MAAAAAA :some reason # :70MAAAAAA KICK #test 70MAAAAAA :some reason
channel = utils.toLower(self.irc, args[0]) channel = utils.toLower(self.irc, args[0])
kicked = self._getNick(args[1]) kicked = self._getUid(args[1])
self.handle_part(kicked, 'KICK', [channel, args[2]]) self.handle_part(kicked, 'KICK', [channel, args[2]])
return {'channel': channel, 'target': kicked, 'text': args[2]} return {'channel': channel, 'target': kicked, 'text': args[2]}

View File

@ -505,7 +505,7 @@ class UnrealProtocol(TS6BaseProtocol):
def handle_privmsg(self, source, command, args): def handle_privmsg(self, source, command, args):
# Convert nicks to UIDs, where they exist. # Convert nicks to UIDs, where they exist.
target = self._getNick(args[0]) target = self._getUid(args[0])
# We use lowercase channels internally, but uppercase UIDs. # We use lowercase channels internally, but uppercase UIDs.
if utils.isChannel(target): if utils.isChannel(target):
target = utils.toLower(self.irc, target) target = utils.toLower(self.irc, target)
@ -687,7 +687,7 @@ class UnrealProtocol(TS6BaseProtocol):
def handle_svsmode(self, numeric, command, args): def handle_svsmode(self, numeric, command, args):
"""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._getNick(args[0]) target = self._getUid(args[0])
modes = args[1:] modes = args[1:]
parsedmodes = utils.parseModes(self.irc, target, modes) parsedmodes = utils.parseModes(self.irc, target, modes)
@ -718,7 +718,7 @@ class UnrealProtocol(TS6BaseProtocol):
# Get the target and the account name being set. 0 for accountname # Get the target and the account name being set. 0 for accountname
# indicates a logout. # indicates a logout.
target = self._getNick(args[0]) target = self._getUid(args[0])
try: try:
account = args[2] account = args[2]
if account == '0': if account == '0':
@ -769,7 +769,7 @@ class UnrealProtocol(TS6BaseProtocol):
# The second argument is the ACTUAL nick requested. # The second argument is the ACTUAL nick requested.
# The actual WHOIS handling is done protocol-independently by coreplugin. # The actual WHOIS handling is done protocol-independently by coreplugin.
return {'target': self._getNick(args[-1])} return {'target': self._getUid(args[-1])}
def handle_setident(self, numeric, command, args): def handle_setident(self, numeric, command, args):
"""Handles SETIDENT, used for self ident changes.""" """Handles SETIDENT, used for self ident changes."""
@ -797,14 +797,14 @@ class UnrealProtocol(TS6BaseProtocol):
def handle_chgident(self, numeric, command, args): def handle_chgident(self, numeric, command, args):
"""Handles CHGIDENT, used for denoting ident changes.""" """Handles CHGIDENT, used for denoting ident changes."""
# <- :GL CHGIDENT GL test # <- :GL CHGIDENT GL test
target = self._getNick(args[0]) target = self._getUid(args[0])
self.irc.users[target].ident = newident = args[1] self.irc.users[target].ident = newident = args[1]
return {'target': target, 'newident': newident} return {'target': target, 'newident': newident}
def handle_chghost(self, numeric, command, args): def handle_chghost(self, numeric, command, args):
"""Handles CHGHOST, used for denoting hostname changes.""" """Handles CHGHOST, used for denoting hostname changes."""
# <- :GL CHGHOST GL some.host # <- :GL CHGHOST GL some.host
target = self._getNick(args[0]) target = self._getUid(args[0])
self.irc.users[target].host = newhost = args[1] self.irc.users[target].host = newhost = args[1]
# When SETHOST or CHGHOST is used, modes +xt are implicitly set on the # When SETHOST or CHGHOST is used, modes +xt are implicitly set on the
@ -816,14 +816,14 @@ class UnrealProtocol(TS6BaseProtocol):
def handle_chgname(self, numeric, command, args): def handle_chgname(self, numeric, command, args):
"""Handles CHGNAME, used for denoting real name/gecos changes.""" """Handles CHGNAME, used for denoting real name/gecos changes."""
# <- :GL CHGNAME GL :afdsafasf # <- :GL CHGNAME GL :afdsafasf
target = self._getNick(args[0]) target = self._getUid(args[0])
self.irc.users[target].realname = newgecos = args[1] self.irc.users[target].realname = newgecos = args[1]
return {'target': target, 'newgecos': newgecos} return {'target': target, 'newgecos': newgecos}
def handle_invite(self, numeric, command, args): def handle_invite(self, numeric, command, args):
"""Handles incoming INVITEs.""" """Handles incoming INVITEs."""
# <- :GL INVITE PyLink-devel :#a # <- :GL INVITE PyLink-devel :#a
target = self._getNick(args[0]) target = self._getUid(args[0])
channel = args[1].lower() channel = args[1].lower()
# We don't actually need to process this; it's just something plugins/hooks can use # We don't actually need to process this; it's just something plugins/hooks can use
return {'target': target, 'channel': channel} return {'target': target, 'channel': channel}
@ -833,7 +833,7 @@ class UnrealProtocol(TS6BaseProtocol):
# <- :GL| KILL GLolol :hidden-1C620195!GL| (test) # <- :GL| KILL GLolol :hidden-1C620195!GL| (test)
# Use ts6_common's handle_kill, but coerse UIDs to nicks first. # Use ts6_common's handle_kill, but coerse UIDs to nicks first.
new_args = [self._getNick(args[0])] new_args = [self._getUid(args[0])]
new_args.extend(args[1:]) new_args.extend(args[1:])
return super().handle_kill(numeric, command, new_args) return super().handle_kill(numeric, command, new_args)