diff --git a/coremods/service_support.py b/coremods/service_support.py index 6d23041..6cc6b80 100644 --- a/coremods/service_support.py +++ b/coremods/service_support.py @@ -141,6 +141,8 @@ def _services_dynamic_part(irc, channel): if irc.has_cap('visible-state-only'): # No-op on bot-only servers. return + if irc.serverdata.get('join_empty_channels', conf.conf['pylink'].get('join_empty_channels', False)): + return # If all remaining users in the channel are service bots, make them all part. if all(irc.get_service_bot(u) for u in irc.channels[channel].users): diff --git a/example-conf.yml b/example-conf.yml index 6c78682..2272cff 100644 --- a/example-conf.yml +++ b/example-conf.yml @@ -80,6 +80,11 @@ pylink: # of all database-enabled plugins to take effect. #save_delay: 300 + # Determines whether that service bots should join preconfigured channels even if they are empty. + # This can also be overriden per-network via the "join_empty_channels" variable. + # This defaults to False if not set. + #join_empty_channels: false + login: # NOTE: for users migrating from PyLink < 1.1, the old login:user/login:password settings # have been deprecated. We strongly recommend migrating to the new "accounts:" block below, as diff --git a/utils.py b/utils.py index 8aa6f08..bb6942b 100644 --- a/utils.py +++ b/utils.py @@ -150,7 +150,7 @@ class ServiceBot(): else: raise NotImplementedError("Network specific plugins not supported yet.") - def join(self, irc, channels, ignore_empty=True): + def join(self, irc, channels, ignore_empty=None): """ Joins the given service bot to the given channel(s). "channels" can be an iterable of channel names or the name of a single channel (type 'str'). @@ -160,8 +160,8 @@ class ServiceBot(): marked persistent). This option is automatically *disabled* on networks where we cannot monitor channels that we're not in (e.g. Clientbot). - Before PyLink 2.0-alpha3, this function implicitly marks channels i - receives to be persistent - this is no longer the case! + Before PyLink 2.0-alpha3, this function implicitly marked channels it + receives to be persistent. This behaviour is no longer the case. """ uid = self.uids.get(irc.name) if uid is None: @@ -173,6 +173,10 @@ class ServiceBot(): if irc.has_cap('visible-state-only'): # Disable dynamic channel joining on networks where we can't monitor channels for joins. ignore_empty = False + elif ignore_empty is None: + ignore_empty = not (irc.serverdata.get('join_empty_channels', + conf.conf['pylink'].get('join_empty_channels', + False))) # Specify modes to join the services bot with. joinmodes = irc.get_service_option(self.name, 'joinmodes', default='')