From 0d2fbc330d13af3697ee0e98be48cb2573d3ebd0 Mon Sep 17 00:00:00 2001 From: James Lu Date: Tue, 18 Aug 2015 02:44:27 -0700 Subject: [PATCH] relay: fix "Left all shared channels" quits for KICK handling --- plugins/relay.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/plugins/relay.py b/plugins/relay.py index 4309457..1c6abf7 100644 --- a/plugins/relay.py +++ b/plugins/relay.py @@ -364,6 +364,7 @@ def handle_kick(irc, source, command, args): # Don't allow kicks to the PyLink client to be relayed. if relay is None or target == irc.pseudoclient.uid: return + origuser = getLocalUser(irc, target) for name, remoteirc in utils.networkobjects.items(): if irc.name == name or not remoteirc.connected.is_set(): continue @@ -402,7 +403,7 @@ def handle_kick(irc, source, command, args): return if not real_target: - return + continue # Propogate the kick! if real_kicker: log.debug('(%s) Relay kick: Kicking %s from channel %s via %s on behalf of %s/%s', irc.name, real_target, remotechan,real_kicker, kicker, irc.name) @@ -411,7 +412,7 @@ def handle_kick(irc, source, command, args): else: # Kick originated from a server, or the kicker isn't in any # common channels with the target relay network. - log.debug('(%s) Relay kick: Kicking %s from channel %s via %s on behalf of %s/%s', irc.name, real_target, remotechan,remoteirc.sid, kicker, irc.name) + log.debug('(%s) Relay kick: Kicking %s from channel %s via %s on behalf of %s/%s', irc.name, real_target, remotechan, remoteirc.sid, kicker, irc.name) try: if kicker in irc.servers: kname = irc.servers[kicker].name @@ -423,9 +424,13 @@ def handle_kick(irc, source, command, args): remoteirc.proto.kickServer(remoteirc, remoteirc.sid, remotechan, real_target, text) - if isRelayClient(irc, target) and not irc.users[target].channels: - remoteuser = getLocalUser(irc, target) - del relayusers[remoteuser][irc.name] + # If the target isn't on any channels, quit them. + if origuser and origuser[0] != remoteirc.name and not remoteirc.users[real_target].channels: + del relayusers[origuser][remoteirc.name] + remoteirc.proto.quitClient(remoteirc, real_target, 'Left all shared channels.') + + if origuser and not irc.users[target].channels: + del relayusers[origuser][irc.name] irc.proto.quitClient(irc, target, 'Left all shared channels.') utils.add_hook(handle_kick, 'KICK')