mirror of
https://github.com/jlu5/PyLink.git
synced 2025-02-02 23:54:08 +01:00
relay: implement optional network disconnect announcements
Closes #421.
This commit is contained in:
parent
0ebb52e64f
commit
cd3d795296
@ -584,6 +584,18 @@ relay:
|
|||||||
# silently dropped. This defaults to True for consistency with older releases.
|
# silently dropped. This defaults to True for consistency with older releases.
|
||||||
#accept_weird_senders: false
|
#accept_weird_senders: false
|
||||||
|
|
||||||
|
# Optionally defines a message that should be sent to all leaf channels that a network owns, when
|
||||||
|
# it disconnects. This uses a template string as documented at
|
||||||
|
# https://docs.python.org/3/library/string.html#template-strings, with the following substitutions:
|
||||||
|
# $network: the name of the network that this message is being announced to
|
||||||
|
# $channel: the channel that this message is being announced to
|
||||||
|
# $homenetwork: the name of the network that disconnected
|
||||||
|
# $homechannel: the original name of the channel this message is being announced to
|
||||||
|
# If this option is empty or not set, no announcement is made.
|
||||||
|
#disconnect_announcement: >-
|
||||||
|
# Network $homenetwork has disconnected: $channel will remain open as the link is
|
||||||
|
# re-established, but new links will be disabled.
|
||||||
|
|
||||||
#servprotect:
|
#servprotect:
|
||||||
# This block configures the servprotect plugin; you don't need this if you aren't using it.
|
# This block configures the servprotect plugin; you don't need this if you aren't using it.
|
||||||
|
|
||||||
|
@ -1472,6 +1472,7 @@ utils.add_hook(handle_services_login, 'CLIENT_SERVICES_LOGIN')
|
|||||||
|
|
||||||
def handle_disconnect(irc, numeric, command, args):
|
def handle_disconnect(irc, numeric, command, args):
|
||||||
"""Handles IRC network disconnections (internal hook)."""
|
"""Handles IRC network disconnections (internal hook)."""
|
||||||
|
|
||||||
# Quit all of our users' representations on other nets, and remove
|
# Quit all of our users' representations on other nets, and remove
|
||||||
# them from our relay clients index.
|
# them from our relay clients index.
|
||||||
log.debug('(%s) Grabbing spawnlocks[%s]', irc.name, irc.name)
|
log.debug('(%s) Grabbing spawnlocks[%s]', irc.name, irc.name)
|
||||||
@ -1506,6 +1507,22 @@ def handle_disconnect(irc, numeric, command, args):
|
|||||||
|
|
||||||
spawnlocks_servers[irc.name].release()
|
spawnlocks_servers[irc.name].release()
|
||||||
|
|
||||||
|
# Announce the disconnects to every leaf channel where the disconnected network is the owner
|
||||||
|
announcement = conf.conf.get('relay', {}).get('disconnect_announcement')
|
||||||
|
if announcement:
|
||||||
|
with db_lock:
|
||||||
|
for chanpair, entrydata in db.items():
|
||||||
|
if chanpair[0] == irc.name:
|
||||||
|
for leaf in entrydata['links']:
|
||||||
|
log.debug('(%s) relay: Announcing disconnect to %s%s', irc.name,
|
||||||
|
leaf[0], leaf[1])
|
||||||
|
remoteirc = world.networkobjects.get(leaf[0])
|
||||||
|
if remoteirc and remoteirc.connected.is_set():
|
||||||
|
text = string.Template(announcement).safe_substitute(
|
||||||
|
{'homenetwork': irc.name, 'homechannel': chanpair[1],
|
||||||
|
'network': remoteirc.name, 'channel': leaf[1]})
|
||||||
|
remoteirc.msg(leaf[1], text, loopback=False)
|
||||||
|
|
||||||
utils.add_hook(handle_disconnect, "PYLINK_DISCONNECT")
|
utils.add_hook(handle_disconnect, "PYLINK_DISCONNECT")
|
||||||
|
|
||||||
def nick_collide(irc, target):
|
def nick_collide(irc, target):
|
||||||
|
Loading…
Reference in New Issue
Block a user