Mercurial > xib
comparison bridge.py @ 179:f6c6708c6c0e
handle IRC events cannotsendtochan and notonchannel, send unhandled events to bot admins
Signed-off-by: Charly COSTE <changaco@changaco.net>
author | Charly COSTE <changaco@changaco.net> |
---|---|
date | Fri, 12 Feb 2010 14:37:48 +0100 |
parents | bca516d04bdb |
children | 102f895347ff |
comparison
equal
deleted
inserted
replaced
178:891195c47350 | 179:f6c6708c6c0e |
---|---|
73 # Join IRC room | 73 # Join IRC room |
74 self.irc_connection = self.bot.irc.open_connection(self.irc_server, self.irc_port, self.bot.nickname, delay=self.irc_connection_interval) | 74 self.irc_connection = self.bot.irc.open_connection(self.irc_server, self.irc_port, self.bot.nickname, delay=self.irc_connection_interval) |
75 self.irc_connection.connect(nick_callback=self._irc_nick_callback, charsets=self.irc_charsets) | 75 self.irc_connection.connect(nick_callback=self._irc_nick_callback, charsets=self.irc_charsets) |
76 | 76 |
77 self.bot.error('[Notice] bridge "'+str(self)+'" is running in '+self.mode+' mode and a say_level of "'+self.__class__._say_levels[self.say_level]+'"') | 77 self.bot.error('[Notice] bridge "'+str(self)+'" is running in '+self.mode+' mode and a say_level of "'+self.__class__._say_levels[self.say_level]+'"') |
78 | |
79 | |
80 def _join_irc_failed(self): | |
81 self.bot.error('[Error] failed to connect to the IRC chan of bridge "'+str(self)+'", stopping bridge', send_to_admins=True) | |
82 self.stop(message='failed to connect to the IRC chan') | |
78 | 83 |
79 | 84 |
80 def _irc_nick_callback(self, error, arguments=[]): | 85 def _irc_nick_callback(self, error, arguments=[]): |
81 if error == None: | 86 if error == None: |
82 if self.mode == None: | 87 if self.mode == None: |
101 raise Exception('[Error] "'+self.bot.nickname+'" got "nicknametoolong" on bridge "'+str(self)+'", limit seems to be '+str(arguments[0])) | 106 raise Exception('[Error] "'+self.bot.nickname+'" got "nicknametoolong" on bridge "'+str(self)+'", limit seems to be '+str(arguments[0])) |
102 else: | 107 else: |
103 raise Exception('[Error] unknown error for "'+self.bot.nickname+'" on bridge "'+str(self)+'"') | 108 raise Exception('[Error] unknown error for "'+self.bot.nickname+'" on bridge "'+str(self)+'"') |
104 except: | 109 except: |
105 trace = traceback.format_exc() | 110 trace = traceback.format_exc() |
106 self.bot.error('[Error] failed to connect to the IRC chan of bridge "'+str(self)+'", stopping bridge\n'+trace, send_to_admins=True) | 111 self._join_irc_failed() |
107 self.stop(message='failed to connect to the IRC chan') | |
108 | 112 |
109 | 113 |
110 def _RemoteServerNotFound_handler(self): | 114 def _RemoteServerNotFound_handler(self): |
111 server = xmpp.protocol.JID(self.xmpp_room_jid).getDomain() | 115 server = xmpp.protocol.JID(self.xmpp_room_jid).getDomain() |
112 bridges = self.bot.findBridges([server]) | 116 bridges = self.bot.findBridges([server]) |