3
0
mirror of https://github.com/jlu5/PyLink.git synced 2024-11-30 14:49:28 +01:00

relay: fix variable confusion when managing service bots

We should be checking for service bot presence locally, and applying changes on the *remote* network.
This commit is contained in:
James Lu 2018-05-09 21:32:02 -07:00
parent 0c19b3719e
commit f3c2149d7a

View File

@ -702,6 +702,9 @@ def relay_joins(irc, channel, users, ts, targetirc=None, **kwargs):
to that specific network.
"""
log.debug('(%s) relay.relay_joins: called on %r with users %r, targetirc=%s', irc.name, channel,
['%s/%s' % (user, irc.get_friendly_name(user)) for user in users], targetirc)
if ts < 750000:
current_ts = int(time.time())
log.debug('(%s) relay: resetting too low TS value of %s on %s to %s', irc.name, ts, users, current_ts)
@ -731,9 +734,9 @@ def relay_joins(irc, channel, users, ts, targetirc=None, **kwargs):
continue
# Join the service bot on the remote channel persistently.
rsbot = remoteirc.get_service_bot(u)
if rsbot:
rsbot.add_persistent_channel(irc, 'relay', channel, try_join=False)
sbot = irc.get_service_bot(user)
if sbot:
sbot.add_persistent_channel(remoteirc, 'relay', remotechan, try_join=False)
if (remotechan not in remoteirc.channels) or u not in remoteirc.channels[remotechan].users:
# Note: only join users if they aren't already joined. This prevents op floods
@ -828,10 +831,10 @@ def relay_part(irc, *args, **kwargs):
return
# Remove any persistent channel entries from the remote end.
rsbot = remoteirc.get_service_bot(remoteuser)
if rsbot:
sbot = irc.get_service_bot(user)
if sbot:
try:
sbot.remove_persistent_channel(irc, 'relay', channel, try_part=False)
sbot.remove_persistent_channel(remoteirc, 'relay', remotechan, try_part=False)
except KeyError:
pass