comparison participant.py @ 172:64a0e9636ae6

removed encoding.py, charsets handling is now in irclib and custom charsets can be set per server in the configuration file Signed-off-by: Charly COSTE <changaco@changaco.net>
author Charly COSTE <changaco@changaco.net>
date Tue, 02 Feb 2010 20:19:50 +0100
parents e0eea72ea493
children c158ad24ef3c
comparison
equal deleted inserted replaced
171:489c157d9e82 172:64a0e9636ae6
16 16
17 17
18 import re 18 import re
19 from time import sleep 19 from time import sleep
20 20
21 from encoding import *
22 from irclib import ServerNotConnectedError, ServerConnection 21 from irclib import ServerNotConnectedError, ServerConnection
23 import muc 22 import muc
24 xmpp = muc.xmpp 23 xmpp = muc.xmpp
25 del muc 24 del muc
26 25
315 314
316 315
317 def sayOnXMPP(self, message): 316 def sayOnXMPP(self, message):
318 try: 317 try:
319 if isinstance(self.xmpp_c, xmpp.client.Client): 318 if isinstance(self.xmpp_c, xmpp.client.Client):
320 self.muc.say(auto_decode(message)) 319 self.muc.say(message)
321 elif not isinstance(self.irc_connection, ServerConnection): 320 elif not isinstance(self.irc_connection, ServerConnection):
322 if message[:4] == '/me ': 321 if message[:4] == '/me ':
323 self.bridge.xmpp_room.say('* '+self.nickname+' '+auto_decode(message[4:])) 322 self.bridge.xmpp_room.say('* '+self.nickname+' '+message[4:])
324 else: 323 else:
325 self.bridge.xmpp_room.say('<'+self.nickname+'> '+auto_decode(message)) 324 self.bridge.xmpp_room.say('<'+self.nickname+'> '+message)
326 except EncodingException: 325 except EncodingException:
327 self.bridge.say('[Warning] "'+self.nickname+'" is sending messages using an unknown encoding', log=True) 326 self.bridge.say('[Warning] "'+self.nickname+'" is sending messages using an unknown encoding', log=True)
328 327
329 328
330 def sayOnXMPPTo(self, to, message): 329 def sayOnXMPPTo(self, to, message):
331 try: 330 try:
332 if isinstance(self.xmpp_c, xmpp.client.Client): 331 if isinstance(self.xmpp_c, xmpp.client.Client):
333 self.muc.sayTo(to, auto_decode(message)) 332 self.muc.sayTo(to, message)
334 elif not isinstance(self.irc_connection, ServerConnection): 333 elif not isinstance(self.irc_connection, ServerConnection):
335 if self.bridge.mode != 'normal': 334 if self.bridge.mode != 'normal':
336 self.bridge.getParticipant(to).sayOnXMPPTo(self.nickname, 'Sorry but cross-protocol private messages are disabled in '+self.bridge.mode+' mode.') 335 self.bridge.getParticipant(to).sayOnXMPPTo(self.nickname, 'Sorry but cross-protocol private messages are disabled in '+self.bridge.mode+' mode.')
337 else: 336 else:
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.') 337 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.')
347 self._close_irc_connection(message) 346 self._close_irc_connection(message)
348 347
349 348
350 def _close_xmpp_connection(self, message): 349 def _close_xmpp_connection(self, message):
351 if isinstance(self.xmpp_c, xmpp.client.Client): 350 if isinstance(self.xmpp_c, xmpp.client.Client):
352 self.muc.leave(auto_decode(message)) 351 self.muc.leave(message)
353 self.xmpp_c = None 352 self.xmpp_c = None
354 self.bridge.bot.close_xmpp_connection(self.nickname) 353 self.bridge.bot.close_xmpp_connection(self.nickname)
355 354
356 355
357 def _close_irc_connection(self, message): 356 def _close_irc_connection(self, message):