3
0
mirror of https://github.com/jlu5/PyLink.git synced 2024-12-25 04:02:45 +01:00

clientbot: fix message recognition treating nick prefixes without ident@host as servers

This commit is contained in:
James Lu 2017-01-09 21:02:56 -08:00
parent 7fe65e1f8a
commit 602f35cb70

View File

@ -320,7 +320,7 @@ class ClientbotWrapperProtocol(Protocol):
else: else:
return # Nothing changed return # Nothing changed
def _getUid(self, nick, ident='unknown', host='unknown.host'): def _getUid(self, nick, ident=None, host=None):
""" """
Fetches the UID for the given nick, creating one if it does not already exist. Fetches the UID for the given nick, creating one if it does not already exist.
@ -337,7 +337,8 @@ class ClientbotWrapperProtocol(Protocol):
log.debug('(%s) Nick-colliding virtual client %s/%s', self.irc.name, idsource, nick) log.debug('(%s) Nick-colliding virtual client %s/%s', self.irc.name, idsource, nick)
self.irc.callHooks([self.irc.sid, 'CLIENTBOT_NICKCOLLIDE', {'target': idsource, 'parse_as': 'SAVE'}]) self.irc.callHooks([self.irc.sid, 'CLIENTBOT_NICKCOLLIDE', {'target': idsource, 'parse_as': 'SAVE'}])
idsource = self.spawnClient(nick, ident, host, server=self.irc.uplink, realname=FALLBACK_REALNAME).uid idsource = self.spawnClient(nick, ident or 'unknown', host or 'unknown',
server=self.irc.uplink, realname=FALLBACK_REALNAME).uid
return idsource return idsource
@ -387,14 +388,18 @@ class ClientbotWrapperProtocol(Protocol):
# PyLink as a services framework expects UIDs and SIDs for everything. Since we connect # PyLink as a services framework expects UIDs and SIDs for everything. Since we connect
# as a bot here, there's no explicit user introduction, so we're going to generate # as a bot here, there's no explicit user introduction, so we're going to generate
# pseudo-uids and pseudo-sids as we see prefixes. # pseudo-uids and pseudo-sids as we see prefixes.
if '!' not in sender: if ('!' not in sender) and '.' in sender:
# Sender is a server name. # Sender is a server name. XXX: make this check more foolproof
idsource = self._getSid(sender) idsource = self._getSid(sender)
if idsource not in self.irc.servers: if idsource not in self.irc.servers:
idsource = self.spawnServer(sender, internal=False) idsource = self.spawnServer(sender, internal=False)
else: else:
# Sender is a nick!user@host prefix. Split it into its relevant parts. # Sender is a either a nick or a nick!user@host prefix. Split it into its relevant parts.
nick, ident, host = utils.splitHostmask(sender) try:
nick, ident, host = utils.splitHostmask(sender)
except ValueError:
ident = host = None # Set ident and host as null for now.
nick = sender # Treat the sender prefix we received as a nick.
idsource = self._getUid(nick, ident, host) idsource = self._getUid(nick, ident, host)
try: try: