# HG changeset patch # User Charly COSTE # Date 1263569450 -3600 # Node ID 46af7f2744a9e201c502f4c6eabae69c2d7c16fa # Parent 52d94261a406bad64935c2c49244571df41d66c8 added irclib.ServerConnection.left_channels Signed-off-by: Charly COSTE diff --git a/bridge.py b/bridge.py --- a/bridge.py +++ b/bridge.py @@ -283,11 +283,13 @@ class Bridge: if left_protocol == 'xmpp': was_on_both = False elif left_protocol == 'irc': - try: + if isinstance(p.irc_connection, ServerConnection): p.irc_connection.join(self.irc_room) - except: - p._close_irc_connection(leave_message) - p.createDuplicateOnIRC() + else: + c = self.bot.irc.get_connection(self.irc_server, self.irc_port, p.duplicate_nickname) + if not (c and self.irc_room in c.left_channels): + p._close_irc_connection(leave_message) + p.createDuplicateOnIRC() return elif p.protocol == 'irc': diff --git a/irclib.py b/irclib.py --- a/irclib.py +++ b/irclib.py @@ -415,6 +415,7 @@ class ServerConnection(Connection): self.port = port self.nickname = nickname self.lock = threading.RLock() + self.left_channels = [] def __str__(self): @@ -782,6 +783,8 @@ class ServerConnection(Connection): def join(self, channel, key=""): """Send a JOIN command.""" + if channel in self.left_channels: + self.left_channels.remove(channel) self.send_raw("JOIN %s%s" % (channel, (key and (" " + key)))) def kick(self, channel, nick, comment=""): @@ -849,8 +852,11 @@ class ServerConnection(Connection): def part(self, channels, message=""): """Send a PART command.""" if isinstance(channels, basestring): + self.left_channels.append(channels) self.send_raw("PART " + channels + (message and (" " + message))) else: + for channel in channels: + self.left_channels.append(channel) self.send_raw("PART " + ",".join(channels) + (message and (" " + message))) def pass_(self, password):