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

conf: join conf::bot and conf::pylink so that they mean the same thing (#343)

This commit is contained in:
James Lu 2017-03-10 23:21:17 -08:00
parent 3096c54bb8
commit dc298b3182
2 changed files with 26 additions and 4 deletions

24
conf.py
View File

@ -45,6 +45,7 @@ conf = {'bot':
'sidrange': '0##'
})
}
conf['pylink'] = conf['bot']
confname = 'unconfigured'
def validate(condition, errmsg):
@ -58,8 +59,27 @@ def validateConf(conf, logger=None):
"Invalid configuration given: should be type dict, not %s."
% type(conf).__name__)
for section in ('bot', 'servers', 'login', 'logging'):
validate(conf.get(section),"Missing %r section in config." % section)
if 'pylink' in conf and 'bot' in conf:
e = ("Since PyLink 1.2, the 'pylink:' and 'bot:' configuration sections have been condensed "
"into one. You should merge any options under these sections into one 'pylink:' block.")
if logger:
logger.warning(e)
else:
# FIXME: we need a better fallback when log isn't available on first
# start.
print('WARNING: %s' % e)
new_block = conf['bot'].copy()
new_block.update(conf['pylink'])
conf['bot'] = conf['pylink'] = new_block
elif 'pylink' in conf:
conf['bot'] = conf['pylink']
elif 'bot' in conf:
conf['pylink'] = conf['bot']
# TODO: add a migration warning in the next release.
for section in ('pylink', 'servers', 'login', 'logging'):
validate(conf.get(section), "Missing %r section in config." % section)
# Make sure at least one form of authentication is valid.
# Also we'll warn them that login:user/login:password is deprecated

View File

@ -4,7 +4,9 @@
# Note: lines starting with a "#" are comments and will be ignored.
# Note 2: Use SPACES, NOT tabs to indent, or you will get parser errors on start!
bot:
# Defines general settings for the PyLink server. Prior to PyLink 1.2, this configuration block
# was named "bot:".
pylink:
# Sets nick, user/ident, and real name.
nick: PyLink
ident: pylink
@ -633,7 +635,7 @@ automode:
# 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:".
# This option overrides the global "spawn_services" option defined in "pylink:".
#spawn_service: true
games: