3
0
mirror of https://github.com/jlu5/PyLink.git synced 2024-11-24 03:29:28 +01:00

relay: remove double iteration when firing the PYLINK_RELAY_JOIN hook

This commit is contained in:
James Lu 2017-07-10 22:36:43 -07:00
parent 5ed4f8bf85
commit 2f87aa63e9

View File

@ -617,7 +617,6 @@ def relay_joins(irc, channel, users, ts, burst=True):
""" """
Relays one or more users' joins from a channel to its relay links. Relays one or more users' joins from a channel to its relay links.
""" """
joined_nets = {}
if ts < 750000: if ts < 750000:
current_ts = int(time.time()) current_ts = int(time.time())
@ -669,20 +668,17 @@ def relay_joins(irc, channel, users, ts, burst=True):
# Look at whether we should relay this join as a regular JOIN, or a SJOIN. # Look at whether we should relay this join as a regular JOIN, or a SJOIN.
# SJOIN will be used if either the amount of users to join is > 1, or there are modes # SJOIN will be used if either the amount of users to join is > 1, or there are modes
# to be set on the joining user. # to be set on the joining user.
rsid = get_remote_sid(remoteirc, irc)
if burst or len(queued_users) > 1 or queued_users[0][0]: if burst or len(queued_users) > 1 or queued_users[0][0]:
modes = get_supported_cmodes(irc, remoteirc, channel, irc.channels[channel].modes) modes = get_supported_cmodes(irc, remoteirc, channel, irc.channels[channel].modes)
rsid = get_remote_sid(remoteirc, irc)
if rsid: if rsid:
remoteirc.sjoin(rsid, remotechan, queued_users, ts=ts, modes=modes) remoteirc.sjoin(rsid, remotechan, queued_users, ts=ts, modes=modes)
else: else:
# A regular JOIN only needs the user and the channel. TS, source SID, etc., can all be omitted. # A regular JOIN only needs the user and the channel. TS, source SID, etc., can all be omitted.
remoteirc.join(queued_users[0][1], remotechan) remoteirc.join(queued_users[0][1], remotechan)
joined_nets[remoteirc] = {'channel': remotechan, 'users': [u[-1] for u in queued_users]} remoteirc.call_hooks([rsid, 'PYLINK_RELAY_JOIN', {'channel': remotechan, 'users': [u[-1] for u in queued_users]}])
for remoteirc, hookdata in joined_nets.items():
# HACK: Announce this JOIN as a special hook on each network, for plugins like Automode.
remoteirc.call_hooks([remoteirc.sid, 'PYLINK_RELAY_JOIN', hookdata])
def relay_part(irc, channel, user): def relay_part(irc, channel, user):
""" """