From f82ddb533634a531899b582563f62bdfff18f1bb Mon Sep 17 00:00:00 2001 From: James Lu Date: Fri, 8 Jun 2018 18:24:42 -0700 Subject: [PATCH] global: allow configuring channels to exempt from announcements Closes #453. --- example-conf.yml | 6 ++++++ plugins/global.py | 18 ++++++++++++++++-- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/example-conf.yml b/example-conf.yml index 57e0a99..20023b4 100644 --- a/example-conf.yml +++ b/example-conf.yml @@ -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::::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 diff --git a/plugins/global.py b/plugins/global.py index f867816..c2d9f66 100644 --- a/plugins/global.py +++ b/plugins/global.py @@ -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}