mirror of
https://github.com/jlu5/PyLink.git
synced 2025-01-12 13:12:36 +01:00
relay: rework kill->kick forwarding to send from the sender network's subservers
This makes the kick message a lot neater. Before: * net1.relay has kicked GL/net1 from #test ((net2.relay) KILL FWD from GL/net2: test) After: * net2.relay has kicked GL/net1 from #test (KILL FWD from GL/net2: test)
This commit is contained in:
parent
a98dd36810
commit
c3bb0f7aca
@ -1934,25 +1934,39 @@ def handle_kill(irc, numeric, command, args):
|
|||||||
del relayusers[realuser]
|
del relayusers[realuser]
|
||||||
else:
|
else:
|
||||||
# Otherwise, forward kills as kicks where applicable.
|
# Otherwise, forward kills as kicks where applicable.
|
||||||
for remotechan in origirc.users[realuser[1]].channels.copy():
|
for homechan in origirc.users[realuser[1]].channels.copy():
|
||||||
localchan = get_remote_channel(origirc, irc, remotechan)
|
localchan = get_remote_channel(origirc, irc, homechan)
|
||||||
|
|
||||||
if localchan:
|
if localchan:
|
||||||
# Forward kills as kicks in all channels that the sender has CLAIM access to.
|
# Forward kills as kicks in all channels that the sender has CLAIM access to.
|
||||||
if check_claim(irc, localchan, numeric):
|
if check_claim(irc, localchan, numeric):
|
||||||
rsid = get_relay_server_sid(origirc, irc)
|
target_nick = origirc.get_friendly_name(realuser[1])
|
||||||
log.debug('(%s) relay.handle_kill: forwarding kill to %s/%s@%s as '
|
|
||||||
'kick on %s', irc.name, realuser[1],
|
|
||||||
origirc.get_friendly_name(realuser[1]), realuser[0], remotechan)
|
|
||||||
|
|
||||||
origirc.kick(rsid, remotechan, realuser[1], fwd_reason)
|
def _relay_kill_to_kick(origirc, remoteirc, rtarget):
|
||||||
origirc.call_hooks([rsid, 'RELAY_KILLFORWARD_KICK',
|
# Forward as a kick to each present relay client
|
||||||
{'target': realuser[1], 'channel': remotechan, 'text': fwd_reason,
|
remotechan = get_remote_channel(origirc, remoteirc, homechan)
|
||||||
'parse_as': 'KICK'}])
|
rsender = get_relay_server_sid(remoteirc, irc, spawn_if_missing=False) or \
|
||||||
|
remoteirc.sid
|
||||||
|
log.debug('(%s) relay.handle_kill: forwarding kill to %s/%s@%s as '
|
||||||
|
'kick to %s/%s@%s on %s', irc.name, realuser[1],
|
||||||
|
target_nick, realuser[0],
|
||||||
|
rtarget, remoteirc.get_friendly_name(rtarget), remoteirc.name,
|
||||||
|
remotechan)
|
||||||
|
remoteirc.kick(rsender, remotechan, rtarget, fwd_reason)
|
||||||
|
|
||||||
|
iterate_all_present(origirc, realuser[1], _relay_kill_to_kick)
|
||||||
|
|
||||||
|
# Then, forward to the home network.
|
||||||
|
hsender = get_relay_server_sid(origirc, irc, spawn_if_missing=False) or \
|
||||||
|
homeirc.sid
|
||||||
|
log.debug('(%s) relay.handle_kill: forwarding kill to %s/%s@%s as '
|
||||||
|
'kick on %s', irc.name, realuser[1], target_nick,
|
||||||
|
realuser[0], homechan)
|
||||||
|
origirc.kick(hsender, homechan, realuser[1], fwd_reason)
|
||||||
|
|
||||||
# If we have no access in a channel, rejoin the target.
|
# If we have no access in a channel, rejoin the target.
|
||||||
else:
|
else:
|
||||||
modes = get_prefix_modes(origirc, irc, remotechan, realuser[1])
|
modes = get_prefix_modes(origirc, irc, homechan, realuser[1])
|
||||||
log.debug('(%s) relay.handle_kill: rejoining target userpair: (%r, %r)', irc.name, modes, realuser)
|
log.debug('(%s) relay.handle_kill: rejoining target userpair: (%r, %r)', irc.name, modes, realuser)
|
||||||
# Set times_tagged=1 to forcetag the target when they return.
|
# Set times_tagged=1 to forcetag the target when they return.
|
||||||
client = get_remote_user(origirc, irc, realuser[1], times_tagged=1)
|
client = get_remote_user(origirc, irc, realuser[1], times_tagged=1)
|
||||||
|
Loading…
Reference in New Issue
Block a user