From d7766d54d5ffd1c71bb4ec2d8a23ceea9f18de5e Mon Sep 17 00:00:00 2001 From: James Lu Date: Sat, 7 Oct 2017 20:06:48 -0700 Subject: [PATCH] clientbot: check for nick collisions with virtual clients on NICK Closes #535. --- protocols/clientbot.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/protocols/clientbot.py b/protocols/clientbot.py index d023f11..3e7190d 100644 --- a/protocols/clientbot.py +++ b/protocols/clientbot.py @@ -977,21 +977,25 @@ class ClientbotWrapperProtocol(IRCCommonProtocol): def handle_nick(self, source, command, args): """Handles NICK changes.""" # <- :GL|!~GL@127.0.0.1 NICK :GL_ + newnick = args[0] if not self.connected.is_set(): # We haven't properly logged on yet, so any initial NICK should be treated as a forced # nick change for us. For example, this clause is used to handle forced nick changes # sent by ZNC, when the login nick and the actual IRC nick of the bouncer differ. - self.pseudoclient.nick = args[0] + self.pseudoclient.nick = newnick log.debug('(%s) Pre-auth FNC: Changing our nick to %s', self.name, args[0]) return elif source == self.pseudoclient.uid: self._nick_fails = 0 # Our last nick change succeeded. oldnick = self.users[source].nick - self.users[source].nick = args[0] - return {'newnick': args[0], 'oldnick': oldnick} + # Check for any nick collisions with existing virtual clients. + self._check_nick_collision(newnick) + self.users[source].nick = newnick + + return {'newnick': newnick, 'oldnick': oldnick} def handle_part(self, source, command, args): """