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

Move _expandPUID into PyLinkNetworkCoreWithUtils

This commit is contained in:
James Lu 2017-08-30 00:56:18 -07:00
parent 5b941daf4d
commit 4a363aee50
2 changed files with 20 additions and 21 deletions

View File

@ -1210,6 +1210,26 @@ class PyLinkNetworkCoreWithUtils(PyLinkNetworkCore):
uid, nick)
self.call_hooks([self.sid, 'SAVE', {'target': uid}])
def _expandPUID(self, uid):
"""
Returns the nick or server name for the given UID/SID. This method helps support protocol
modules that use PUIDs internally, as they must convert them to talk with the uplink.
"""
# TODO: stop hardcoding @ as separator
if '@' in uid:
if uid in self.users:
# UID exists and has a @ in it, meaning it's a PUID (orignick@counter style).
# Return this user's nick accordingly.
nick = self.users[uid].nick
log.debug('(%s) Mangling target PUID %s to nick %s', self.name, uid, nick)
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
utils._proto_utils_class = PyLinkNetworkCoreWithUtils # Used by compatibility wrappers
class IRCNetwork(PyLinkNetworkCoreWithUtils):
@ -1706,7 +1726,6 @@ class Channel(structures.DeprecatedAttributesObject, structures.CamelCaseToSnake
return sorted(result, key=self.sort_prefixes)
IrcChannel = Channel
class PUIDGenerator():
"""
Pseudo UID Generator module, using a prefix and a simple counter.

View File

@ -322,26 +322,6 @@ class IRCCommonProtocol(IRCNetwork):
"""Sends a RFC1459-style raw command from the given sender."""
self.send(':%s %s' % (self._expandPUID(source), msg), **kwargs)
def _expandPUID(self, uid):
"""
Returns the nick or server name for the given UID/SID. This method helps support protocol
modules that use PUIDs internally, as they must convert them to talk with the uplink.
"""
# TODO: stop hardcoding @ as separator
if '@' in uid:
if uid in self.users:
# UID exists and has a @ in it, meaning it's a PUID (orignick@counter style).
# Return this user's nick accordingly.
nick = self.users[uid].nick
log.debug('(%s) Mangling target PUID %s to nick %s', self.name, uid, nick)
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):
COMMAND_TOKENS = {}