3
0
mirror of https://github.com/jlu5/PyLink.git synced 2024-11-01 01:09:22 +01:00

ServiceBot: implement global and per-service spawn_service(s) options (#403)

This commit is contained in:
James Lu 2017-02-18 12:54:26 -08:00
parent a776aab897
commit 75b5be5baf
2 changed files with 15 additions and 0 deletions

View File

@ -49,6 +49,11 @@ bot:
# even if the command was called in a channel. This defaults to False.
#prefer_private_replies: false
# Determines whether spawning additional services for bots (e.g. Automode, Games) should be
# enabled. This defaults to True, unless a network's protocol module doesn't support spawning
# extra service bots.
#spawn_services: true
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
@ -575,6 +580,11 @@ automode:
# the risk of mode overrides being dropped.
joinmodes: 'o'
# Determines whether a separate service bot should be spawned for this plugin. This defaults to
# True, unless a network's protocol module doesn't support spawning extra service bots.
# This option overrides the global "spawn_services" option defined in "bot:".
#spawn_service: true
games:
# Sets the nick of the Games service, if you're using it. This defaults to "games" if not defined.
nick: Games

View File

@ -487,6 +487,11 @@ def registerService(name, *args, **kwargs):
if name in world.services:
raise ValueError("Service name %s is already bound!" % name)
# Allow disabling service spawning either globally or by service.
elif name != 'pylink' and not (conf.conf.get(name, {}).get('spawn_service',
conf.conf['bot'].get('spawn_services', True))):
return world.services['pylink']
world.services[name] = sbot = ServiceBot(name, *args, **kwargs)
sbot.spawn()
return sbot