comparison bridge.py @ 115:0ae0f8836a7a

split long messages when sending on IRC Signed-off-by: Charly COSTE <changaco@changaco.net>
author Charly COSTE <changaco@changaco.net>
date Sat, 28 Nov 2009 23:33:48 +0100
parents 787e97d62404
children b29fd5696a78
comparison
equal deleted inserted replaced
114:787e97d62404 115:0ae0f8836a7a
131 traceback.print_exc() 131 traceback.print_exc()
132 self.bot.error('[Error] failed to connect to the XMPP room of bridge "'+str(self)+'", stopping bridge', send_to_admins=True) 132 self.bot.error('[Error] failed to connect to the XMPP room of bridge "'+str(self)+'", stopping bridge', send_to_admins=True)
133 self.stop(message='failed to connect to the XMPP room') 133 self.stop(message='failed to connect to the XMPP room')
134 134
135 135
136 def addParticipant(self, from_protocol, nickname, real_jid=None): 136 def addParticipant(self, from_protocol, nickname, real_jid=None, irc_id=None):
137 """Add a participant to the bridge.""" 137 """Add a participant to the bridge."""
138 if (from_protocol == 'irc' and nickname == self.irc_connection.get_nickname()) or (from_protocol == 'xmpp' and nickname == self.xmpp_room.nickname): 138 if (from_protocol == 'irc' and nickname == self.irc_connection.get_nickname()) or (from_protocol == 'xmpp' and nickname == self.xmpp_room.nickname):
139 self.bot.error('===> Debug: not adding self ('+self.bot.nickname+') to bridge "'+str(self)+'"', debug=True) 139 self.bot.error('===> Debug: not adding self ('+self.bot.nickname+') to bridge "'+str(self)+'"', debug=True)
140 return 140 return
141 try: 141 try:
142 p = self.getParticipant(nickname) 142 p = self.getParticipant(nickname)
143 if p.protocol != from_protocol: 143 if p.protocol != from_protocol:
144 if from_protocol == 'irc' and isinstance(p.irc_connection, ServerConnection) and p.irc_connection.really_connected == True or from_protocol == 'xmpp' and isinstance(p.xmpp_c, xmpp.client.Client) and isinstance(p.muc, xmpp.muc): 144 if from_protocol == 'irc' and isinstance(p.irc_connection, ServerConnection) and p.irc_connection.really_connected == True or from_protocol == 'xmpp' and isinstance(p.xmpp_c, xmpp.client.Client) and isinstance(p.muc, xmpp.muc):
145 if irc_id:
146 p.irc_connection.irc_id = irc_id
145 return 147 return
146 self.bot.error('===> Debug: "'+nickname+'" is on both sides of bridge "'+str(self)+'"', debug=True) 148 self.bot.error('===> Debug: "'+nickname+'" is on both sides of bridge "'+str(self)+'"', debug=True)
147 self.say('[Warning] The nickname "'+nickname+'" is used on both sides of the bridge, please avoid that if possible') 149 self.say('[Warning] The nickname "'+nickname+'" is used on both sides of the bridge, please avoid that if possible')
148 if isinstance(p.irc_connection, ServerConnection): 150 if isinstance(p.irc_connection, ServerConnection):
149 p.irc_connection.close('') 151 p.irc_connection.close('')