comparison bridge.py @ 64:8fc496eaa17b

Handle IRC "nickcollision" event Signed-off-by: Charly COSTE <changaco@changaco.net>
author Charly COSTE <changaco@changaco.net>
date Sun, 30 Aug 2009 01:18:34 +0200
parents 71508f22edb4
children 6c4b841144f6
comparison
equal deleted inserted replaced
63:71508f22edb4 64:8fc496eaa17b
82 self.bot.error('===> Debug: successfully connected on IRC side of bridge "'+str(self)+'"', debug=True) 82 self.bot.error('===> Debug: successfully connected on IRC side of bridge "'+str(self)+'"', debug=True)
83 self.say('[Notice] bridge "'+str(self)+'" is running in '+self.mode+' mode', on_xmpp=False) 83 self.say('[Notice] bridge "'+str(self)+'" is running in '+self.mode+' mode', on_xmpp=False)
84 if error == 'nicknameinuse': 84 if error == 'nicknameinuse':
85 self.bot.error('[Error] "'+self.bot.nickname+'" is already used in the IRC chan or reserved on the IRC server of bridge "'+str(self)+'"') 85 self.bot.error('[Error] "'+self.bot.nickname+'" is already used in the IRC chan or reserved on the IRC server of bridge "'+str(self)+'"')
86 raise Exception('[Error] "'+self.bot.nickname+'" is already used in the IRC chan or reserved on the IRC server of bridge "'+str(self)+'"') 86 raise Exception('[Error] "'+self.bot.nickname+'" is already used in the IRC chan or reserved on the IRC server of bridge "'+str(self)+'"')
87 if error == 'nickcollision':
88 self.bot.error('[Error] "'+self.bot.nickname+'" is already used or reserved on the IRC server of bridge "'+str(self)+'"')
89 raise Exception('[Error] "'+self.bot.nickname+'" is already used or reserved on the IRC server of bridge "'+str(self)+'"')
87 elif error == 'erroneusnickname': 90 elif error == 'erroneusnickname':
88 self.bot.error('[Error] "'+self.bot.nickname+'" got "erroneusnickname" on bridge "'+str(self)+'"') 91 self.bot.error('[Error] "'+self.bot.nickname+'" got "erroneusnickname" on bridge "'+str(self)+'"')
89 raise Exception('[Error] "'+self.bot.nickname+'" got "erroneusnickname" on bridge "'+str(self)+'"') 92 raise Exception('[Error] "'+self.bot.nickname+'" got "erroneusnickname" on bridge "'+str(self)+'"')
90 elif error == 'nicknametoolong': 93 elif error == 'nicknametoolong':
91 self.bot.error('[Error] "'+self.bot.nickname+'" got "nicknametoolong" on bridge "'+str(self)+'", limit seems to be '+str(arguments[0])) 94 self.bot.error('[Error] "'+self.bot.nickname+'" got "nicknametoolong" on bridge "'+str(self)+'", limit seems to be '+str(arguments[0]))
264 i = 0 267 i = 0
265 for p in self.participants: 268 for p in self.participants:
266 if p.protocol == 'xmpp': 269 if p.protocol == 'xmpp':
267 i += 1 270 i += 1
268 if p.irc_connection != None: 271 if p.irc_connection != None:
269 p.irc_connection.close('Bridge is switching to limited mode', volontary=True) 272 p.irc_connection.close('Bridge is switching to limited mode')
270 p.irc_connection = None 273 p.irc_connection = None
271 self.irc_connections_limit = i 274 self.irc_connections_limit = i
272 self.bot.error('===> Bridge is switching to limited mode. Limit seems to be '+str(self.irc_connections_limit)+' on "'+self.irc_server+'".') 275 self.bot.error('===> Bridge is switching to limited mode. Limit seems to be '+str(self.irc_connections_limit)+' on "'+self.irc_server+'".')
273 self.say('[Warning] Bridge is switching to limited mode, it means that it will be transparent for XMPP users but not for IRC users, this is due to the IRC servers\' per-IP-address connections\' limit number which seems to be '+str(self.irc_connections_limit)+' on "'+self.irc_server+'".') 276 self.say('[Warning] Bridge is switching to limited mode, it means that it will be transparent for XMPP users but not for IRC users, this is due to the IRC servers\' per-IP-address connections\' limit number which seems to be '+str(self.irc_connections_limit)+' on "'+self.irc_server+'".')
274 xmpp_participants_nicknames = self.get_participants_nicknames_list(protocols=['xmpp']) 277 xmpp_participants_nicknames = self.get_participants_nicknames_list(protocols=['xmpp'])
287 del self.participants 290 del self.participants
288 291
289 # Close IRC connection if not used by an other bridge, just leave the room otherwise 292 # Close IRC connection if not used by an other bridge, just leave the room otherwise
290 self.irc_connection.used_by -= 1 293 self.irc_connection.used_by -= 1
291 if self.irc_connection.used_by < 1: 294 if self.irc_connection.used_by < 1:
292 self.irc_connection.close('Removing bridge', volontary=True) 295 self.irc_connection.close('Removing bridge')
293 else: 296 else:
294 self.irc_connection.part('Removing bridge') 297 self.irc_connection.part('Removing bridge')
295 del self.irc_connection 298 del self.irc_connection
296 299
297 # Leave XMPP room 300 # Leave XMPP room