mirror of
https://github.com/jlu5/PyLink.git
synced 2025-10-14 23:47:22 +02:00
relay: further fixes for persistent channels
Also, merge the 'relay_local' and 'relay_remote' namespaces into one.
This commit is contained in:
parent
e9fe15bd7d
commit
8994811f54
@ -532,14 +532,14 @@ def initialize_channel(irc, channel):
|
|||||||
relay_joins(irc, channel, c.users, c.ts)
|
relay_joins(irc, channel, c.users, c.ts)
|
||||||
|
|
||||||
if 'pylink' in world.services:
|
if 'pylink' in world.services:
|
||||||
world.services['pylink'].add_persistent_channel(irc, 'relay_local', channel)
|
world.services['pylink'].add_persistent_channel(irc, 'relay', channel)
|
||||||
|
|
||||||
def remove_channel(irc, channel):
|
def remove_channel(irc, channel):
|
||||||
"""Destroys a relay channel by parting all of its users."""
|
"""Destroys a relay channel by parting all of its users."""
|
||||||
if irc is None:
|
if irc is None:
|
||||||
return
|
return
|
||||||
|
|
||||||
world.services['pylink'].remove_persistent_channel(channel, 'relay_local', try_part=False)
|
world.services['pylink'].remove_persistent_channel(irc, 'relay', channel, try_part=False)
|
||||||
|
|
||||||
relay = get_relay(irc, channel)
|
relay = get_relay(irc, channel)
|
||||||
if relay and channel in irc.channels:
|
if relay and channel in irc.channels:
|
||||||
@ -720,6 +720,11 @@ def relay_joins(irc, channel, users, ts, targetirc=None, **kwargs):
|
|||||||
if not u:
|
if not u:
|
||||||
continue
|
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)
|
||||||
|
|
||||||
if (remotechan not in remoteirc.channels) or u not in remoteirc.channels[remotechan].users:
|
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
|
# Note: only join users if they aren't already joined. This prevents op floods
|
||||||
# on charybdis from repeated SJOINs sent for one user.
|
# on charybdis from repeated SJOINs sent for one user.
|
||||||
@ -740,11 +745,6 @@ def relay_joins(irc, channel, users, ts, targetirc=None, **kwargs):
|
|||||||
# proto.sjoin() takes its users as a list of (prefix mode characters, UID) pairs.
|
# proto.sjoin() takes its users as a list of (prefix mode characters, UID) pairs.
|
||||||
userpair = (prefixes, u)
|
userpair = (prefixes, u)
|
||||||
|
|
||||||
# Join the service bot on the remote channel persistently.
|
|
||||||
rsbot = remoteirc.get_service_bot(u)
|
|
||||||
if rsbot:
|
|
||||||
rsbot.add_persistent_channel(irc, 'relay_remote', channel, try_join=False)
|
|
||||||
|
|
||||||
queued_users.append(userpair)
|
queued_users.append(userpair)
|
||||||
|
|
||||||
if queued_users:
|
if queued_users:
|
||||||
@ -818,10 +818,10 @@ def relay_part(irc, *args, **kwargs):
|
|||||||
return
|
return
|
||||||
|
|
||||||
# Remove any persistent channel entries from the remote end.
|
# Remove any persistent channel entries from the remote end.
|
||||||
rsbot = remoteirc.get_service_bot(u)
|
rsbot = remoteirc.get_service_bot(remoteuser)
|
||||||
if rsbot:
|
if rsbot:
|
||||||
try:
|
try:
|
||||||
sbot.remove_persistent_channel(irc, 'relay_remote', channel, try_part=False)
|
sbot.remove_persistent_channel(irc, 'relay', channel, try_part=False)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user