Mercurial > xib
comparison bridge.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 | 271c35321497 |
children | c158ad24ef3c |
comparison
equal
deleted
inserted
replaced
171:489c157d9e82 | 172:64a0e9636ae6 |
---|---|
17 | 17 |
18 import re | 18 import re |
19 import threading | 19 import threading |
20 import traceback | 20 import traceback |
21 | 21 |
22 from encoding import * | |
23 from irclib import ServerConnection | 22 from irclib import ServerConnection |
24 import muc | 23 import muc |
25 xmpp = muc.xmpp | 24 xmpp = muc.xmpp |
26 del muc | 25 del muc |
27 | 26 |
41 | 40 |
42 | 41 |
43 class NoSuchParticipantException(Exception): pass | 42 class NoSuchParticipantException(Exception): pass |
44 | 43 |
45 | 44 |
46 def __init__(self, owner_bot, xmpp_room_jid, irc_room, irc_server, mode, say_level, irc_port=6667, irc_connection_interval=1): | 45 def __init__(self, owner_bot, xmpp_room_jid, irc_room, irc_server, mode, say_level, irc_port=6667, irc_connection_interval=1, irc_charsets=None): |
47 """Create a new bridge.""" | 46 """Create a new bridge.""" |
48 self.bot = owner_bot | 47 self.bot = owner_bot |
49 self.irc_server = irc_server | 48 self.irc_server = irc_server |
50 self.irc_port = irc_port | 49 self.irc_port = irc_port |
51 self.irc_room = irc_room.lower() | 50 self.irc_room = irc_room.lower() |
52 self.irc_connection_interval = irc_connection_interval | 51 self.irc_connection_interval = irc_connection_interval |
52 self.irc_charsets = irc_charsets | |
53 self.xmpp_room_jid = xmpp_room_jid | 53 self.xmpp_room_jid = xmpp_room_jid |
54 if hasattr(self.__class__, '_'+say_level): | 54 if hasattr(self.__class__, '_'+say_level): |
55 self.say_level = getattr(self.__class__, '_'+say_level) | 55 self.say_level = getattr(self.__class__, '_'+say_level) |
56 else: | 56 else: |
57 raise Exception('[Error] "'+say_level+'" is not a correct value for a bridge\'s "say_level" attribute') | 57 raise Exception('[Error] "'+say_level+'" is not a correct value for a bridge\'s "say_level" attribute') |
76 | 76 |
77 # Join IRC room | 77 # Join IRC room |
78 try: | 78 try: |
79 self.irc_connections_limit = -1 | 79 self.irc_connections_limit = -1 |
80 self.irc_connection = self.bot.irc.open_connection(self.irc_server, self.irc_port, self.bot.nickname) | 80 self.irc_connection = self.bot.irc.open_connection(self.irc_server, self.irc_port, self.bot.nickname) |
81 self.irc_connection.connect(nick_callback=self._irc_nick_callback) | 81 self.irc_connection.connect(nick_callback=self._irc_nick_callback, charsets=self.irc_charsets) |
82 except: | 82 except: |
83 self.bot.error('[Error] joining IRC room failed') | 83 self.bot.error('[Error] joining IRC room failed') |
84 raise | 84 raise |
85 | 85 |
86 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]+'"') | 86 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]+'"') |