mirror of
https://github.com/jlu5/PyLink.git
synced 2024-12-25 04:02:45 +01:00
clientbot: rewrite _get_UID nick collision handling to be less confusing
This commit is contained in:
parent
85ac0bb80a
commit
84ff797b5f
@ -355,20 +355,22 @@ class ClientbotWrapperProtocol(IRCCommonProtocol):
|
|||||||
Limited (internal) nick collision checking is done here to prevent Clientbot users from
|
Limited (internal) nick collision checking is done here to prevent Clientbot users from
|
||||||
being confused with virtual clients, and vice versa."""
|
being confused with virtual clients, and vice versa."""
|
||||||
self._check_puid_collision(nick)
|
self._check_puid_collision(nick)
|
||||||
|
|
||||||
idsource = self.nick_to_uid(nick)
|
idsource = self.nick_to_uid(nick)
|
||||||
is_internal = self.is_internal_client(idsource)
|
|
||||||
|
|
||||||
# If this sender isn't known or it is one of our virtual clients, spawn a new one.
|
if self.is_internal_client(idsource) and self.pseudoclient and idsource != self.pseudoclient.uid:
|
||||||
# This also takes care of any nick collisions caused by new, Clientbot users
|
# We got a message from a client with the same nick as an internal client.
|
||||||
# taking the same nick as one of our virtual clients, and will force the virtual client to lose.
|
# Fire a virtual nick collision to prevent mixing senders.
|
||||||
if (not idsource) or (is_internal and self.pseudoclient and idsource != self.pseudoclient.uid):
|
|
||||||
if idsource:
|
|
||||||
log.debug('(%s) Nick-colliding virtual client %s/%s', self.name, idsource, nick)
|
log.debug('(%s) Nick-colliding virtual client %s/%s', self.name, idsource, nick)
|
||||||
self.call_hooks([self.sid, 'CLIENTBOT_NICKCOLLIDE', {'target': idsource, 'parse_as': 'SAVE'}])
|
self.call_hooks([self.sid, 'SAVE', {'target': idsource}])
|
||||||
|
|
||||||
|
# Clear the UID for this nick and spawn a new client for the nick that was just freed.
|
||||||
|
idsource = None
|
||||||
|
|
||||||
|
if idsource is None:
|
||||||
|
# If this sender doesn't already exist, spawn a new client.
|
||||||
idsource = self.spawn_client(nick, ident or 'unknown', host or 'unknown',
|
idsource = self.spawn_client(nick, ident or 'unknown', host or 'unknown',
|
||||||
server=self.uplink, realname=FALLBACK_REALNAME).uid
|
server=self.uplink, realname=FALLBACK_REALNAME).uid
|
||||||
|
|
||||||
return idsource
|
return idsource
|
||||||
|
|
||||||
def parse_message_tags(self, data):
|
def parse_message_tags(self, data):
|
||||||
|
Loading…
Reference in New Issue
Block a user