Mercurial > xib
comparison bridge.py @ 137:9f39cead20cb
reduced duplication of error messages
Signed-off-by: Charly COSTE <changaco@changaco.net>
author | Charly COSTE <changaco@changaco.net> |
---|---|
date | Sat, 16 Jan 2010 17:01:17 +0100 |
parents | 922858915907 |
children | 38eb220142a1 |
comparison
equal
deleted
inserted
replaced
136:7dc6a1764c4f | 137:9f39cead20cb |
---|---|
231 p._close_irc_connection('Bridge is switching to limited mode') | 231 p._close_irc_connection('Bridge is switching to limited mode') |
232 | 232 |
233 if new_mode[-8:] == '-limited': | 233 if new_mode[-8:] == '-limited': |
234 # to {normal,bypass}-limited | 234 # to {normal,bypass}-limited |
235 self.irc_connections_limit = i | 235 self.irc_connections_limit = i |
236 self.bot.error('===> Bridge is switching to limited mode. Limit seems to be '+str(self.irc_connections_limit)+' on "'+self.irc_server+'".') | 236 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+'".', log=True) |
237 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+'".') | |
238 xmpp_participants_nicknames = self.get_participants_nicknames_list(protocols=['xmpp']) | 237 xmpp_participants_nicknames = self.get_participants_nicknames_list(protocols=['xmpp']) |
239 self.say('[Info] Participants on XMPP: '+' '.join(xmpp_participants_nicknames), on_xmpp=False) | 238 self.say('[Info] Participants on XMPP: '+' '.join(xmpp_participants_nicknames), on_xmpp=False) |
240 return | 239 return |
241 | 240 |
242 elif new_mode == 'minimal': | 241 elif new_mode == 'minimal': |
255 # From bypass to * | 254 # From bypass to * |
256 for p in self.participants: | 255 for p in self.participants: |
257 if p.nickname != p.duplicate_nickname: | 256 if p.nickname != p.duplicate_nickname: |
258 p.leave('Bridge is switching to '+new_mode+' mode') | 257 p.leave('Bridge is switching to '+new_mode+' mode') |
259 | 258 |
260 self.bot.error('===> Bridge is switching from '+old_mode+' to '+new_mode+' mode.') | 259 self.say('[Notice] Bridge is switching from '+old_mode+' to '+new_mode+' mode.', log=True) |
261 self.say('[Notice] Bridge is switching from '+old_mode+' to '+new_mode+' mode.') | |
262 | 260 |
263 | 261 |
264 def getParticipant(self, nickname): | 262 def getParticipant(self, nickname): |
265 """Returns a participant object if there is a participant using nickname in the bridge. Raises a NoSuchParticipantException otherwise.""" | 263 """Returns a participant object if there is a participant using nickname in the bridge. Raises a NoSuchParticipantException otherwise.""" |
266 self.lock.acquire() | 264 self.lock.acquire() |
372 | 370 |
373 # Recreate the bridge | 371 # Recreate the bridge |
374 self.init2() | 372 self.init2() |
375 | 373 |
376 | 374 |
377 def say(self, message, on_irc=True, on_xmpp=True): | 375 def say(self, message, on_irc=True, on_xmpp=True, log=False): |
378 """Make the bot say something.""" | 376 """Make the bot say something.""" |
379 if message[0] != '[': | 377 if message[0] != '[': |
380 raise Exception('[Internal Error] message does not start with "["') | 378 raise Exception('[Internal Error] message does not start with "["') |
379 if log: | |
380 self.bot.error(message+' ('+str(self)+')') | |
381 if self.say_level == self.__class__._nothing: | 381 if self.say_level == self.__class__._nothing: |
382 return | 382 return |
383 level = re.findall('^\[(Info|Notice|Warning|Error)\]', message) | 383 level = re.findall('^\[(Info|Notice|Warning|Error)\]', message) |
384 if len(level) == 0: | 384 if len(level) == 0: |
385 raise Exception('[Internal Error] unknown message importance "'+re.findall('^\[([^[\]]+)', message)[0]+'"') | 385 raise Exception('[Internal Error] unknown message importance "'+re.findall('^\[([^[\]]+)', message)[0]+'"') |