3
0
mirror of https://github.com/jlu5/PyLink.git synced 2025-01-24 03:04:05 +01:00

IRCCommonProtocol: also expand PSIDs in _expandPUID

This commit is contained in:
James Lu 2017-07-04 23:56:12 -07:00
parent 5d4f2149e6
commit 163f0099e7

View File

@ -261,17 +261,23 @@ class IRCCommonProtocol(IRCNetwork):
def _expandPUID(self, uid): def _expandPUID(self, uid):
""" """
Returns the nick for the given UID; this method helps support protocol modules that use Returns the nick or server name for the given UID/SID. This method helps support protocol
PUIDs internally but must send nicks in the server protocol. modules that use PUIDs internally, as they must convert them to talk with the uplink.
""" """
# TODO: stop hardcoding @ as separator # TODO: stop hardcoding @ as separator
if uid in self.users and '@' in uid: if '@' in uid:
# UID exists and has a @ in it, meaning it's a PUID (orignick@counter style). if uid in self.users:
# Return this user's nick accordingly. # UID exists and has a @ in it, meaning it's a PUID (orignick@counter style).
nick = self.users[uid].nick # Return this user's nick accordingly.
log.debug('(%s) Mangling target PUID %s to nick %s', self.name, uid, nick) nick = self.users[uid].nick
return nick log.debug('(%s) Mangling target PUID %s to nick %s', self.name, uid, nick)
return uid return nick
elif uid in self.servers:
# Ditto for servers
sname = self.servers[uid].name
log.debug('(%s) Mangling target PSID %s to server name %s', self.name, uid, sname)
return sname
return uid # Regular UID, no change
class IRCS2SProtocol(IRCCommonProtocol): class IRCS2SProtocol(IRCCommonProtocol):
COMMAND_TOKENS = {} COMMAND_TOKENS = {}
@ -363,7 +369,7 @@ class IRCS2SProtocol(IRCCommonProtocol):
This is mostly used by PyLink internals to check whether the remote link is up.""" This is mostly used by PyLink internals to check whether the remote link is up."""
if self.sid: if self.sid:
self._send_with_prefix(self.sid, 'PING %s' % self.sid) self._send_with_prefix(self.sid, 'PING %s' % self._expandPUID(self.sid))
def quit(self, numeric, reason): def quit(self, numeric, reason):
"""Quits a PyLink client.""" """Quits a PyLink client."""