3
0
mirror of https://github.com/jlu5/PyLink.git synced 2024-11-24 03:29:28 +01:00

Allow disabling dynamic channels via a new "join_empty_channels" option

This commit is contained in:
James Lu 2018-10-27 18:48:12 -07:00
parent 94a345423e
commit 77febfe69f
3 changed files with 14 additions and 3 deletions

View File

@ -141,6 +141,8 @@ def _services_dynamic_part(irc, channel):
if irc.has_cap('visible-state-only'): if irc.has_cap('visible-state-only'):
# No-op on bot-only servers. # No-op on bot-only servers.
return 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 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): if all(irc.get_service_bot(u) for u in irc.channels[channel].users):

View File

@ -80,6 +80,11 @@ pylink:
# of all database-enabled plugins to take effect. # of all database-enabled plugins to take effect.
#save_delay: 300 #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: login:
# NOTE: for users migrating from PyLink < 1.1, the old login:user/login:password settings # 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 # have been deprecated. We strongly recommend migrating to the new "accounts:" block below, as

View File

@ -150,7 +150,7 @@ class ServiceBot():
else: else:
raise NotImplementedError("Network specific plugins not supported yet.") 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 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'). 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 marked persistent). This option is automatically *disabled* on networks
where we cannot monitor channels that we're not in (e.g. Clientbot). where we cannot monitor channels that we're not in (e.g. Clientbot).
Before PyLink 2.0-alpha3, this function implicitly marks channels i Before PyLink 2.0-alpha3, this function implicitly marked channels it
receives to be persistent - this is no longer the case! receives to be persistent. This behaviour is no longer the case.
""" """
uid = self.uids.get(irc.name) uid = self.uids.get(irc.name)
if uid is None: if uid is None:
@ -173,6 +173,10 @@ class ServiceBot():
if irc.has_cap('visible-state-only'): if irc.has_cap('visible-state-only'):
# Disable dynamic channel joining on networks where we can't monitor channels for joins. # Disable dynamic channel joining on networks where we can't monitor channels for joins.
ignore_empty = False 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. # Specify modes to join the services bot with.
joinmodes = irc.get_service_option(self.name, 'joinmodes', default='') joinmodes = irc.get_service_option(self.name, 'joinmodes', default='')