comparison participant.py @ 219:63289aa1dea7

moved "nicknametoolong" and ServerConnection.really_connected handling to irclib, renamed ServerConnection.really_connected to .logged_in Signed-off-by: Charly COSTE <changaco@changaco.net>
author Charly COSTE <changaco@changaco.net>
date Sun, 07 Mar 2010 12:08:29 +0100
parents fbe40b397f67
children 0d85049ac68d
comparison
equal deleted inserted replaced
218:ca22fdea1c17 219:63289aa1dea7
112 return 112 return
113 self.irc_connection = self.bridge.bot.irc.open_connection(self.bridge.irc_server, self.bridge.irc_port, self.duplicate_nickname) 113 self.irc_connection = self.bridge.bot.irc.open_connection(self.bridge.irc_server, self.bridge.irc_port, self.duplicate_nickname)
114 self.irc_connection.connect(nick_callback=self._irc_nick_callback) 114 self.irc_connection.connect(nick_callback=self._irc_nick_callback)
115 115
116 116
117 def _irc_nick_callback(self, error, arguments=[]): 117 def _irc_nick_callback(self, error):
118 if error == None: 118 if error == None:
119 self.irc_connection.join(self.bridge.irc_room) 119 self.irc_connection.join(self.bridge.irc_room)
120 m = '"'+self.nickname+'" duplicate succesfully created on IRC side of bridge "'+str(self.bridge)+'"' 120 m = '"'+self.nickname+'" duplicate succesfully created on IRC side of bridge "'+str(self.bridge)+'"'
121 if self.nickname != self.duplicate_nickname: 121 if self.nickname != self.duplicate_nickname:
122 m += ' using nickname "'+self.duplicate_nickname+'"' 122 m += ' using nickname "'+self.duplicate_nickname+'"'
155 return 155 return
156 else: 156 else:
157 self.bridge.say(say_levels.warning, 'The nickname "'+self.nickname+'" contains unauthorized characters and cannot be used in the IRC channel', log=True) 157 self.bridge.say(say_levels.warning, 'The nickname "'+self.nickname+'" contains unauthorized characters and cannot be used in the IRC channel', log=True)
158 158
159 elif error == 'nicknametoolong': 159 elif error == 'nicknametoolong':
160 self.bridge.say(say_levels.warning, 'The nickname "'+self.nickname+'" is too long (limit seems to be '+str(arguments[0])+') and cannot be used in the IRC channel', log=True) 160 self.bridge.say(say_levels.warning, 'The nickname "'+self.nickname+'" is too long (limit seems to be '+str(len(self.irc_connection.real_nickname))+') and cannot be used in the IRC channel', log=True)
161 161
162 else: 162 else:
163 self.bridge.say(say_levels.warning, 'unknown error while adding "'+self.nickname+'" to IRC side of bridge', log=True) 163 self.bridge.say(say_levels.warning, 'unknown error while adding "'+self.nickname+'" to IRC side of bridge', log=True)
164 164
165 if isinstance(self.irc_connection, ServerConnection): 165 if isinstance(self.irc_connection, ServerConnection):
338 self.bridge.bot.close_xmpp_connection(self.nickname) 338 self.bridge.bot.close_xmpp_connection(self.nickname)
339 339
340 340
341 def _close_irc_connection(self, message): 341 def _close_irc_connection(self, message):
342 if isinstance(self.irc_connection, ServerConnection): 342 if isinstance(self.irc_connection, ServerConnection):
343 if self.irc_connection.really_connected == True: 343 if self.irc_connection.logged_in:
344 self.irc_connection.part(self.bridge.irc_room, message=message) 344 self.irc_connection.part(self.bridge.irc_room, message=message)
345 self.irc_connection.used_by -= 1 345 self.irc_connection.used_by -= 1
346 if self.irc_connection.used_by < 1: 346 if self.irc_connection.used_by < 1:
347 self.irc_connection.close(message) 347 self.irc_connection.close(message)
348 self.irc_connection = None 348 self.irc_connection = None
349 349
350 350
351 def __str__(self): 351 def __str__(self):
352 r = 'self.protocol='+str(self.protocol)+'\n'+'self.nickname='+str(self.nickname) 352 r = 'self.protocol='+str(self.protocol)+'\n'+'self.nickname='+str(self.nickname)
353 if isinstance(self.irc_connection, ServerConnection): 353 if isinstance(self.irc_connection, ServerConnection):
354 r += '\nself.irc_connection='+str(self.irc_connection)+'\n'+'self.irc_connection.really_connected='+str(self.irc_connection.really_connected) 354 r += '\nself.irc_connection='+str(self.irc_connection)+'\n'+'self.irc_connection.logged_in='+str(self.irc_connection.logged_in)
355 if isinstance(self.xmpp_c, xmpp.client.Client): 355 if isinstance(self.xmpp_c, xmpp.client.Client):
356 r += '\nself.muc.connected='+str(self.muc.connected) 356 r += '\nself.muc.connected='+str(self.muc.connected)
357 return r 357 return r
358 358
359 359