Mercurial > xib
changeset 63:71508f22edb4
Fixed unjustified switching to limited mode
Signed-off-by: Charly COSTE <changaco@changaco.net>
author | Charly COSTE <changaco@changaco.net> |
---|---|
date | Sat, 29 Aug 2009 21:57:49 +0200 |
parents | 61491895c607 |
children | 8fc496eaa17b |
files | bot.py bridge.py irclib.py participant.py |
diffstat | 4 files changed, 14 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/bot.py +++ b/bot.py @@ -446,6 +446,8 @@ class bot(Thread): if event.eventtype() == 'disconnect': # TODO: lock self.bridges for thread safety for bridge in self.bridges: + if connection.server != bridge.irc_server: + continue try: bridge.getParticipant(connection.get_nickname()) if bridge.mode == 'normal':
--- a/bridge.py +++ b/bridge.py @@ -266,7 +266,7 @@ class bridge: if p.protocol == 'xmpp': i += 1 if p.irc_connection != None: - p.irc_connection.close('Bridge is switching to limited mode') + p.irc_connection.close('Bridge is switching to limited mode', volontary=True) p.irc_connection = None self.irc_connections_limit = i self.bot.error('===> Bridge is switching to limited mode. Limit seems to be '+str(self.irc_connections_limit)+' on "'+self.irc_server+'".') @@ -289,7 +289,7 @@ class bridge: # Close IRC connection if not used by an other bridge, just leave the room otherwise self.irc_connection.used_by -= 1 if self.irc_connection.used_by < 1: - self.irc_connection.close('Removing bridge') + self.irc_connection.close('Removing bridge', volontary=True) else: self.irc_connection.part('Removing bridge') del self.irc_connection
--- a/irclib.py +++ b/irclib.py @@ -494,14 +494,14 @@ class ServerConnection(Connection): self.nick_callbacks.append(callback) - def close(self, message): + def close(self, message, volontary=False): """Close the connection. This method closes the connection permanently; after it has been called, the object is unusable. """ - self.disconnect(message) + self.disconnect(message, volontary) self.irclibobj._remove_connection(self) def _get_socket(self): @@ -690,7 +690,7 @@ class ServerConnection(Connection): """Send a CTCP REPLY command.""" self.notice(target, "\001%s\001" % parameter) - def disconnect(self, message=""): + def disconnect(self, message="", volontary=False): """Hang up the connection. Arguments: @@ -712,7 +712,9 @@ class ServerConnection(Connection): pass self.socket = None self.lock.release() - self._handle_event(Event("disconnect", self.server, "", [message])) + + if volontary == False: + self._handle_event(Event("disconnect", self.server, "", [message])) def globops(self, text): """Send a GLOBOPS command."""
--- a/participant.py +++ b/participant.py @@ -82,19 +82,19 @@ class participant: self.bridge.bot.error('===> Debug: "'+self.nickname+'" is already used in the IRC chan of bridge "'+str(self.bridge)+'"', debug=True) self.bridge.say('[Warning] The nickname "'+self.nickname+'" is used on both rooms or reserved on the IRC server, please avoid that if possible') if self.irc_connection != None: - self.irc_connection.close('') + self.irc_connection.close('', volontary=True) self.irc_connection = None elif error == 'erroneusnickname': self.bridge.bot.error('===> Debug: "'+self.nickname+'" got "erroneusnickname" on bridge "'+str(self.bridge)+'"', debug=True) self.bridge.say('[Warning] The nickname "'+self.nickname+'" contains unauthorized characters and cannot be used in the IRC channel, please avoid that if possible') if self.irc_connection != None: - self.irc_connection.close('') + self.irc_connection.close('', volontary=True) self.irc_connection = None elif error == 'nicknametoolong': self.bridge.bot.error('===> Debug: "'+self.nickname+'" got "nicknametoolong" on bridge "'+str(self.bridge)+'"', debug=True) self.bridge.say('[Warning] The nickname "'+self.nickname+'" is too long (limit seems to be '+str(arguments[0])+') and cannot be used in the IRC channel, please avoid that if possible') if self.irc_connection != None: - self.irc_connection.close('') + self.irc_connection.close('', volontary=True) self.irc_connection = None @@ -195,7 +195,7 @@ class participant: if self.irc_connection != None: self.irc_connection.used_by -= 1 if self.irc_connection.used_by < 1: - self.irc_connection.close(message) + self.irc_connection.close(message, volontary=True) self.irc_connection = None self.nickname = None