Mercurial > xib
comparison participant.py @ 185:6173873c6b0d
minor fix in participant.py, encoding is handled in irclib since cbaab9cc23f8097dbe647d5ea6d982b1c9e49b19
Signed-off-by: Charly COSTE <changaco@changaco.net>
author | Charly COSTE <changaco@changaco.net> |
---|---|
date | Sat, 20 Feb 2010 16:41:25 +0100 |
parents | 102f895347ff |
children | e04410e7e527 |
comparison
equal
deleted
inserted
replaced
184:1e5308a0db55 | 185:6173873c6b0d |
---|---|
272 # should never happen | 272 # should never happen |
273 raise Exception('WTF ?') | 273 raise Exception('WTF ?') |
274 | 274 |
275 | 275 |
276 def sayOnIRC(self, message): | 276 def sayOnIRC(self, message): |
277 try: | 277 bot_say = False |
278 bot_say = False | 278 if message[:4] == '/me ': |
279 if message[:4] == '/me ': | 279 action = True |
280 action = True | 280 message = message[4:] |
281 message = message[4:] | 281 else: |
282 else: | 282 action = False |
283 action = False | 283 if isinstance(self.irc_connection, ServerConnection): |
284 if isinstance(self.irc_connection, ServerConnection): | 284 try: |
285 try: | 285 if action: |
286 if action: | 286 self.irc_connection.action(self.bridge.irc_room, message) |
287 self.irc_connection.action(self.bridge.irc_room, message) | 287 else: |
288 else: | 288 self.irc_connection.privmsg(self.bridge.irc_room, message) |
289 self.irc_connection.privmsg(self.bridge.irc_room, message) | 289 except ServerNotConnectedError: |
290 except ServerNotConnectedError: | 290 self.irc_connection.connect() |
291 self.irc_connection.connect() | |
292 bot_say = True | |
293 elif not isinstance(self.xmpp_c, xmpp.client.Client): | |
294 bot_say = True | 291 bot_say = True |
295 if bot_say: | 292 elif not isinstance(self.xmpp_c, xmpp.client.Client): |
296 if action: | 293 bot_say = True |
297 self.bridge.irc_connection.privmsg(self.bridge.irc_room, '* '+self.nickname+' '+message) | 294 if bot_say: |
298 else: | 295 if action: |
299 self.bridge.irc_connection.privmsg(self.bridge.irc_room, '<'+self.nickname+'> '+message) | 296 self.bridge.irc_connection.privmsg(self.bridge.irc_room, '* '+self.nickname+' '+message) |
300 except EncodingException: | 297 else: |
301 self.bridge.say(say_levels.warning, '"'+self.nickname+'" is sending messages using an unknown encoding', log=True) | 298 self.bridge.irc_connection.privmsg(self.bridge.irc_room, '<'+self.nickname+'> '+message) |
302 | 299 |
303 | 300 |
304 def sayOnIRCTo(self, to, message): | 301 def sayOnIRCTo(self, to, message): |
305 if isinstance(self.irc_connection, ServerConnection): | 302 if isinstance(self.irc_connection, ServerConnection): |
306 try: | 303 self.irc_connection.privmsg(to, message) |
307 self.irc_connection.privmsg(to, message) | |
308 except EncodingException: | |
309 self.bridge.say(say_levels.warning, '"'+self.nickname+'" is sending messages using an unknown encoding', log=True) | |
310 elif not isinstance(self.xmpp_c, xmpp.client.Client): | 304 elif not isinstance(self.xmpp_c, xmpp.client.Client): |
311 if self.bridge.mode != 'normal': | 305 if self.bridge.mode != 'normal': |
312 self.bridge.getParticipant(to).sayOnXMPPTo(self.nickname, 'Sorry but cross-protocol private messages are disabled in '+self.bridge.mode+' mode.') | 306 self.bridge.getParticipant(to).sayOnXMPPTo(self.nickname, 'Sorry but cross-protocol private messages are disabled in '+self.bridge.mode+' mode.') |
313 else: | 307 else: |
314 self.bridge.getParticipant(to).sayOnXMPPTo(self.nickname, 'Sorry but you cannot send cross-protocol private messages because I don\'t have an IRC duplicate with your nickname.') | 308 self.bridge.getParticipant(to).sayOnXMPPTo(self.nickname, 'Sorry but you cannot send cross-protocol private messages because I don\'t have an IRC duplicate with your nickname.') |
315 | 309 |
316 | 310 |
317 def sayOnXMPP(self, message): | 311 def sayOnXMPP(self, message): |
318 try: | 312 if isinstance(self.xmpp_c, xmpp.client.Client): |
319 if isinstance(self.xmpp_c, xmpp.client.Client): | 313 self.muc.say(message) |
320 self.muc.say(message) | 314 elif not isinstance(self.irc_connection, ServerConnection): |
321 elif not isinstance(self.irc_connection, ServerConnection): | 315 if message[:4] == '/me ': |
322 if message[:4] == '/me ': | 316 self.bridge.xmpp_room.say('* '+self.nickname+' '+message[4:]) |
323 self.bridge.xmpp_room.say('* '+self.nickname+' '+message[4:]) | 317 else: |
324 else: | 318 self.bridge.xmpp_room.say('<'+self.nickname+'> '+message) |
325 self.bridge.xmpp_room.say('<'+self.nickname+'> '+message) | |
326 except EncodingException: | |
327 self.bridge.say(say_levels.warning, '"'+self.nickname+'" is sending messages using an unknown encoding', log=True) | |
328 | 319 |
329 | 320 |
330 def sayOnXMPPTo(self, to, message): | 321 def sayOnXMPPTo(self, to, message): |
331 try: | 322 if isinstance(self.xmpp_c, xmpp.client.Client): |
332 if isinstance(self.xmpp_c, xmpp.client.Client): | 323 self.muc.sayTo(to, message) |
333 self.muc.sayTo(to, message) | 324 elif not isinstance(self.irc_connection, ServerConnection): |
334 elif not isinstance(self.irc_connection, ServerConnection): | 325 if self.bridge.mode != 'normal': |
335 if self.bridge.mode != 'normal': | 326 self.bridge.getParticipant(to).sayOnXMPPTo(self.nickname, 'Sorry but cross-protocol private messages are disabled in '+self.bridge.mode+' mode.') |
336 self.bridge.getParticipant(to).sayOnXMPPTo(self.nickname, 'Sorry but cross-protocol private messages are disabled in '+self.bridge.mode+' mode.') | 327 else: |
337 else: | 328 self.bridge.getParticipant(to).sayOnXMPPTo(self.nickname, 'Sorry but you cannot send cross-protocol private messages because I don\'t have an XMPP duplicate with your nickname.') |
338 self.bridge.getParticipant(to).sayOnXMPPTo(self.nickname, 'Sorry but you cannot send cross-protocol private messages because I don\'t have an XMPP duplicate with your nickname.') | |
339 except EncodingException: | |
340 self.bridge.say(say_levels.warning, '"'+self.nickname+'" is sending messages using an unknown encoding', log=True) | |
341 | 329 |
342 | 330 |
343 def leave(self, message): | 331 def leave(self, message): |
344 if message == None: | 332 if message == None: |
345 message = '' | 333 message = '' |