3
0
mirror of https://github.com/jlu5/PyLink.git synced 2024-12-25 04:02:45 +01:00

global: allow configuring channels to exempt from announcements

Closes #453.
This commit is contained in:
James Lu 2018-06-08 18:24:42 -07:00
parent 0edbeb7fad
commit f82ddb5336
2 changed files with 22 additions and 2 deletions

View File

@ -815,6 +815,12 @@ stats:
# $text: the global text
#format: "[$sender@$fullnetwork] $text"
# Configures a set of channel globs to exempt from announcements. You can also add to
# this per network via: servers::<server name>::global_exempt_channels,
# the contents of which will be merged into this list.
#exempt_channels:
# - "#*staff*"
#antispam:
# This block configures the antispam plugin; you don't need this if you aren't using it.
# Antispam is automatically enabled in all channels that it's in, and you can configure

View File

@ -23,14 +23,28 @@ def g(irc, source, args):
global_conf = conf.conf.get('global') or {}
template = string.Template(global_conf.get('format', DEFAULT_FORMAT))
for name, ircd in world.networkobjects.items():
exempt_channels = set(global_conf.get('exempt_channels', set()))
for netname, ircd in world.networkobjects.items():
if ircd.connected.is_set(): # Only attempt to send to connected networks
for channel in ircd.pseudoclient.channels:
local_exempt_channels = exempt_channels | set(ircd.serverdata.get('global_exempt_channels', set()))
skip = False
for exempt in local_exempt_channels:
if irc.match_text(exempt, channel):
log.debug('global: Skipping channel %s%s for exempt %r', netname, channel, exempt)
skip = True
break
if skip:
continue
subst = {'sender': irc.get_friendly_name(source),
'network': irc.name,
'fullnetwork': irc.get_full_network_name(),
'current_channel': channel,
'current_network': ircd.name,
'current_network': netname,
'current_fullnetwork': ircd.get_full_network_name(),
'text': message}