mirror of
https://github.com/jlu5/PyLink.git
synced 2024-11-01 09:19:23 +01:00
protocols: merge _expandPUID into ircs2s_common
This commit is contained in:
parent
8ddcc4d9a6
commit
78034096a8
@ -42,16 +42,6 @@ class ClientbotWrapperProtocol(IRCCommonProtocol):
|
||||
# are essentially all fatal errors for connections.
|
||||
self.handle_463 = self.handle_464 = self.handle_465 = self.handle_error
|
||||
|
||||
def _expandPUID(self, uid):
|
||||
"""
|
||||
Returns the real nick for the given PUID.
|
||||
"""
|
||||
if uid in self.users:
|
||||
nick = self.users[uid].nick
|
||||
log.debug('(%s) Mangling target PUID %s to nick %s', self.name, uid, nick)
|
||||
return nick
|
||||
return uid
|
||||
|
||||
def post_connect(self):
|
||||
"""Initializes a connection to a server."""
|
||||
# (Re)initialize counter-based pseudo UID generators
|
||||
|
@ -167,6 +167,20 @@ class IRCCommonProtocol(IRCNetwork):
|
||||
"""Sends a RFC 459-style raw command from the given sender."""
|
||||
self.send(':%s %s' % (source, msg), **kwargs)
|
||||
|
||||
def _expandPUID(self, uid):
|
||||
"""
|
||||
Returns the nick for the given UID; this method helps support protocol modules that use
|
||||
PUIDs internally but must send nicks in the server protocol.
|
||||
"""
|
||||
# TODO: stop hardcoding @ as separator
|
||||
if uid in self.users and '@' in uid:
|
||||
# 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
|
||||
return uid
|
||||
|
||||
class IRCS2SProtocol(IRCCommonProtocol):
|
||||
COMMAND_TOKENS = {}
|
||||
|
||||
@ -260,14 +274,6 @@ class IRCS2SProtocol(IRCCommonProtocol):
|
||||
else:
|
||||
raise LookupError("No such PyLink client exists.")
|
||||
|
||||
|
||||
def _expandPUID(self, uid):
|
||||
"""
|
||||
Returns the nick for the given UID; this method helps support protocol modules that use
|
||||
PUIDs internally but must send nicks in the server protocol.
|
||||
"""
|
||||
return uid
|
||||
|
||||
def message(self, numeric, target, text):
|
||||
"""Sends a PRIVMSG from a PyLink client."""
|
||||
if not self.is_internal_client(numeric):
|
||||
|
@ -41,20 +41,6 @@ class UnrealProtocol(TS6BaseProtocol):
|
||||
# Some command aliases
|
||||
self.handle_svskill = self.handle_kill
|
||||
|
||||
def _expandPUID(self, uid):
|
||||
"""
|
||||
Returns the outgoing nick for the given UID. For PUIDs (used to store UID-less
|
||||
3.2 users), this will change the PUID given to the actual user's nick,
|
||||
so that that the older IRCds can understand it.
|
||||
"""
|
||||
if uid in self.users and '@' in uid:
|
||||
# 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
|
||||
return uid
|
||||
|
||||
### OUTGOING COMMAND FUNCTIONS
|
||||
def spawn_client(self, nick, ident='null', host='null', realhost=None, modes=set(),
|
||||
server=None, ip='0.0.0.0', realname=None, ts=None, opertype='IRC Operator',
|
||||
|
Loading…
Reference in New Issue
Block a user