Mercurial > xib
changeset 131:46af7f2744a9
added irclib.ServerConnection.left_channels
Signed-off-by: Charly COSTE <changaco@changaco.net>
author | Charly COSTE <changaco@changaco.net> |
---|---|
date | Fri, 15 Jan 2010 16:30:50 +0100 |
parents | 52d94261a406 |
children | 6a6885dbed25 |
files | bridge.py irclib.py |
diffstat | 2 files changed, 12 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- 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':
--- 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):