# HG changeset patch # User Charly COSTE # Date 1251587914 -7200 # Node ID 8fc496eaa17b3edbbc46a415309c16bd28a9eff0 # Parent 71508f22edb46b41768250c275e9eab7be244c30 Handle IRC "nickcollision" event Signed-off-by: Charly COSTE diff --git a/bot.py b/bot.py --- a/bot.py +++ b/bot.py @@ -462,6 +462,9 @@ class bot(Thread): if event.eventtype() == 'nicknameinuse': connection._call_nick_callbacks('nicknameinuse') return + if event.eventtype() == 'nickcollision': + connection._call_nick_callbacks('nickcollision') + return if event.eventtype() == 'erroneusnickname': connection._call_nick_callbacks('erroneusnickname') return diff --git a/bridge.py b/bridge.py --- a/bridge.py +++ b/bridge.py @@ -84,6 +84,9 @@ class bridge: if error == 'nicknameinuse': self.bot.error('[Error] "'+self.bot.nickname+'" is already used in the IRC chan or reserved on the IRC server of bridge "'+str(self)+'"') raise Exception('[Error] "'+self.bot.nickname+'" is already used in the IRC chan or reserved on the IRC server of bridge "'+str(self)+'"') + if error == 'nickcollision': + self.bot.error('[Error] "'+self.bot.nickname+'" is already used or reserved on the IRC server of bridge "'+str(self)+'"') + raise Exception('[Error] "'+self.bot.nickname+'" is already used or reserved on the IRC server of bridge "'+str(self)+'"') elif error == 'erroneusnickname': self.bot.error('[Error] "'+self.bot.nickname+'" got "erroneusnickname" on bridge "'+str(self)+'"') raise Exception('[Error] "'+self.bot.nickname+'" got "erroneusnickname" on bridge "'+str(self)+'"') @@ -266,7 +269,7 @@ class bridge: if p.protocol == 'xmpp': i += 1 if p.irc_connection != None: - p.irc_connection.close('Bridge is switching to limited mode', volontary=True) + p.irc_connection.close('Bridge is switching to limited mode') p.irc_connection = None self.irc_connections_limit = i self.bot.error('===> Bridge is switching to limited mode. Limit seems to be '+str(self.irc_connections_limit)+' on "'+self.irc_server+'".') @@ -289,7 +292,7 @@ class bridge: # Close IRC connection if not used by an other bridge, just leave the room otherwise self.irc_connection.used_by -= 1 if self.irc_connection.used_by < 1: - self.irc_connection.close('Removing bridge', volontary=True) + self.irc_connection.close('Removing bridge') else: self.irc_connection.part('Removing bridge') del self.irc_connection diff --git a/irclib.py b/irclib.py --- a/irclib.py +++ b/irclib.py @@ -494,7 +494,7 @@ class ServerConnection(Connection): self.nick_callbacks.append(callback) - def close(self, message, volontary=False): + def close(self, message, volontary=True): """Close the connection. This method closes the connection permanently; after it has diff --git a/participant.py b/participant.py --- a/participant.py +++ b/participant.py @@ -82,19 +82,25 @@ class participant: self.bridge.bot.error('===> Debug: "'+self.nickname+'" is already used in the IRC chan of bridge "'+str(self.bridge)+'"', debug=True) self.bridge.say('[Warning] The nickname "'+self.nickname+'" is used on both rooms or reserved on the IRC server, please avoid that if possible') if self.irc_connection != None: - self.irc_connection.close('', volontary=True) + self.irc_connection.close('') + self.irc_connection = None + elif error == 'nickcollision': + self.bridge.bot.error('===> Debug: "'+self.nickname+'" is already used or reserved on the IRC server of bridge "'+str(self.bridge)+'"', debug=True) + self.bridge.say('[Warning] The nickname "'+self.nickname+'" is already used or reserved on the IRC server, please avoid that if possible') + if self.irc_connection != None: + self.irc_connection.close('') self.irc_connection = None elif error == 'erroneusnickname': self.bridge.bot.error('===> Debug: "'+self.nickname+'" got "erroneusnickname" on bridge "'+str(self.bridge)+'"', debug=True) self.bridge.say('[Warning] The nickname "'+self.nickname+'" contains unauthorized characters and cannot be used in the IRC channel, please avoid that if possible') if self.irc_connection != None: - self.irc_connection.close('', volontary=True) + self.irc_connection.close('') self.irc_connection = None elif error == 'nicknametoolong': self.bridge.bot.error('===> Debug: "'+self.nickname+'" got "nicknametoolong" on bridge "'+str(self.bridge)+'"', debug=True) self.bridge.say('[Warning] The nickname "'+self.nickname+'" is too long (limit seems to be '+str(arguments[0])+') and cannot be used in the IRC channel, please avoid that if possible') if self.irc_connection != None: - self.irc_connection.close('', volontary=True) + self.irc_connection.close('') self.irc_connection = None @@ -195,7 +201,7 @@ class participant: if self.irc_connection != None: self.irc_connection.used_by -= 1 if self.irc_connection.used_by < 1: - self.irc_connection.close(message, volontary=True) + self.irc_connection.close(message) self.irc_connection = None self.nickname = None