Mercurial > xib
comparison bridge.py @ 12:fd695e2b5283
Fixed bridge mode-switching
Signed-off-by: Charly COSTE <changaco@changaco.net>
author | Charly COSTE <changaco@changaco.net> |
---|---|
date | Mon, 17 Aug 2009 01:05:30 +0200 |
parents | 79b0a7f48a3e |
children | 5aa4399c0530 |
comparison
equal
deleted
inserted
replaced
11:79b0a7f48a3e | 12:fd695e2b5283 |
---|---|
33 self.irc_room = irc_room | 33 self.irc_room = irc_room |
34 self.participants = [] | 34 self.participants = [] |
35 self.mode = mode | 35 self.mode = mode |
36 | 36 |
37 # Join IRC room | 37 # Join IRC room |
38 self.irc_connections_limit = -1 | |
38 self.irc_connection = self.bot.irc.server() | 39 self.irc_connection = self.bot.irc.server() |
39 self.irc_connection.nick_callback = self._irc_nick_callback | 40 self.irc_connection.nick_callback = self._irc_nick_callback |
40 self.irc_connection.bridge = self | 41 self.irc_connection.bridge = self |
41 try: | 42 try: |
42 self.irc_connection.connect(irc_server, irc_port, self.bot.nickname) | 43 self.irc_connection.connect(irc_server, irc_port, self.bot.nickname) |
125 self.bot.error('===> Debug: removing participant "'+nickname+'" from bridge "'+str(self)+'"', debug=True) | 126 self.bot.error('===> Debug: removing participant "'+nickname+'" from bridge "'+str(self)+'"', debug=True) |
126 self.participants.remove(p) | 127 self.participants.remove(p) |
127 p.leave(leave_message) | 128 p.leave(leave_message) |
128 i = 0 | 129 i = 0 |
129 for p in self.participants: | 130 for p in self.participants: |
130 if p.protocol == 'irc': | 131 if p.protocol == 'xmpp': |
131 i += 1 | 132 i += 1 |
132 if protocol == 'xmpp' and self.irc_connections_limit >= i: | 133 if protocol == 'xmpp' and self.irc_connections_limit != -1 and self.irc_connections_limit > i: |
133 self.switchToNormalMode() | 134 self.switchToNormalMode() |
134 del p | 135 del p |
136 if self.mode != 'normal': | |
137 xmpp_participants_nicknames = self.get_xmpp_participants_nicknames_list() | |
138 self.say('[Info] Participants on XMPP: '+' '.join(xmpp_participants_nicknames), on_xmpp=False) | |
135 | 139 |
136 | 140 |
137 def say(self, message, on_irc=True, on_xmpp=True): | 141 def say(self, message, on_irc=True, on_xmpp=True): |
138 if on_xmpp == True: | 142 if on_xmpp == True: |
139 self.xmpp_room.say(message) | 143 self.xmpp_room.say(message) |
166 if p.irc_connection: | 170 if p.irc_connection: |
167 p.irc_connection.closing = True | 171 p.irc_connection.closing = True |
168 p.irc_connection.disconnect('Bridge is switching to limited mode') | 172 p.irc_connection.disconnect('Bridge is switching to limited mode') |
169 p.irc_connection = None | 173 p.irc_connection = None |
170 self.irc_connections_limit = i | 174 self.irc_connections_limit = i |
171 self.bot.error('===> Bridge is switching to limited mode.') | 175 self.bot.error('===> Bridge is switching to limited mode. Limit seems to be '+str(self.irc_connections_limit)+' on "'+self.irc_server+'".') |
172 self.say('[Warning] Bridge is switching to limited mode, it means that it will be transparent for XMPP users but not for IRC users, this is due to the IRC servers\' per-IP-address connections\' limit number.') | 176 self.say('[Warning] Bridge is switching to limited mode, it means that it will be transparent for XMPP users but not for IRC users, this is due to the IRC servers\' per-IP-address connections\' limit number which seems to be '+str(self.irc_connections_limit)+' on "'+self.irc_server+'".') |
173 xmpp_participants_nicknames = self.get_xmpp_participants_nicknames_list() | 177 xmpp_participants_nicknames = self.get_xmpp_participants_nicknames_list() |
174 self.say('[Info] Participants on XMPP: '+' '.join(xmpp_participants_nicknames), on_xmpp=False) | 178 self.say('[Info] Participants on XMPP: '+' '.join(xmpp_participants_nicknames), on_xmpp=False) |
175 | 179 |
176 | 180 |
177 def __str__(self): | 181 def __str__(self): |