comparison bridge.py @ 97:c71861491968

bridge.addParticipant improvements Signed-off-by: Charly COSTE <changaco@changaco.net>
author Charly COSTE <changaco@changaco.net>
date Sun, 04 Oct 2009 13:43:03 +0200
parents bfa32b017fc9
children 6289ac5a2db7
comparison
equal deleted inserted replaced
96:dd7e1b935894 97:c71861491968
131 self.bot.error('===> Debug: not adding self ('+self.bot.nickname+') to bridge "'+str(self)+'"', debug=True) 131 self.bot.error('===> Debug: not adding self ('+self.bot.nickname+') to bridge "'+str(self)+'"', debug=True)
132 return 132 return
133 try: 133 try:
134 p = self.getParticipant(nickname) 134 p = self.getParticipant(nickname)
135 if p.protocol != from_protocol: 135 if p.protocol != from_protocol:
136 if from_protocol == 'irc' and isinstance(p.irc_connection, ServerConnection) and p.irc_connection.really_connected == True or from_protocol == 'xmpp' and isinstance(p.muc, xmpp.muc) and p.muc.connected == True: 136 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):
137 return 137 return
138 self.bot.error('===> Debug: "'+nickname+'" is on both sides of bridge "'+str(self)+'"', debug=True) 138 self.bot.error('===> Debug: "'+nickname+'" is on both sides of bridge "'+str(self)+'"', debug=True)
139 self.say('[Warning] The nickname "'+nickname+'" is used on both sides of the bridge, please avoid that if possible') 139 self.say('[Warning] The nickname "'+nickname+'" is used on both sides of the bridge, please avoid that if possible')
140 if isinstance(p.irc_connection, ServerConnection): 140 if isinstance(p.irc_connection, ServerConnection):
141 p.irc_connection.close('') 141 p.irc_connection.close('')
147 if p.xmpp_c != 'both': 147 if p.xmpp_c != 'both':
148 p.xmpp_c = 'both' 148 p.xmpp_c = 'both'
149 return 149 return
150 except NoSuchParticipantException: 150 except NoSuchParticipantException:
151 pass 151 pass
152 self.lock.acquire()
152 self.bot.error('===> Debug: adding participant "'+nickname+'" from "'+from_protocol+'" to bridge "'+str(self)+'"', debug=True) 153 self.bot.error('===> Debug: adding participant "'+nickname+'" from "'+from_protocol+'" to bridge "'+str(self)+'"', debug=True)
153 try: 154 try:
154 p = participant(self, from_protocol, nickname) 155 p = participant(self, from_protocol, nickname)
155 except IOError: 156 except IOError:
156 self.bot.error('===> Debug: IOError while adding participant "'+nickname+'" from "'+from_protocol+'" to bridge "'+str(self)+'", reconnectiong ...', debug=True) 157 self.bot.error('===> Debug: IOError while adding participant "'+nickname+'" from "'+from_protocol+'" to bridge "'+str(self)+'", reconnectiong ...', debug=True)
158 except: 159 except:
159 self.bot.error('===> Debug: unknown error while adding participant "'+nickname+'" from "'+from_protocol+'" to bridge "'+str(self)+'"', debug=True) 160 self.bot.error('===> Debug: unknown error while adding participant "'+nickname+'" from "'+from_protocol+'" to bridge "'+str(self)+'"', debug=True)
160 traceback.print_exc() 161 traceback.print_exc()
161 return 162 return
162 self.participants.append(p) 163 self.participants.append(p)
164 self.lock.release()
163 if self.mode != 'normal' and from_protocol == 'xmpp': 165 if self.mode != 'normal' and from_protocol == 'xmpp':
164 xmpp_participants_nicknames = self.get_participants_nicknames_list(protocols=['xmpp']) 166 xmpp_participants_nicknames = self.get_participants_nicknames_list(protocols=['xmpp'])
165 self.say('[Info] Participants on XMPP: '+' '.join(xmpp_participants_nicknames), on_xmpp=False) 167 self.say('[Info] Participants on XMPP: '+' '.join(xmpp_participants_nicknames), on_xmpp=False)
166 return p 168 return p
167 169