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

fantasy: make responding to nick a per-service configuration option (#343)

This also renames the "respondtonick" option to "respond_to_nick", deprecating the former name.
This commit is contained in:
James Lu 2017-03-26 14:03:31 -07:00
parent f497044777
commit ce0c84266e
2 changed files with 20 additions and 6 deletions

View File

@ -24,12 +24,14 @@ pylink:
# errors.
prefix: "&"
# Whether service bots will respond to commands prefixes with their nick.
respondtonick: true
# Determines whether PyLink service bots will respond to commands prefixed with their nick
# (requires the fantasy plugin). Prior to PyLink 1.2, this option was named "respondtonick";
# it was renamed for consistency. This defaults to false.
#respond_to_nick: true
# Custom prefixes for other service bots if they are loaded. Note: this is deprecated
# since PyLink 1.2 in favour of adding prefixes into each plugin's configuration block
# itself (see the "prefix:" option in the "games:" block in this case).
# itself (see the "prefix:" option in the "games:" block for this example).
#prefixes:
# games: "@"
@ -674,9 +676,15 @@ automode:
#spawn_service: true
# Defines a fantasy prefix for the Automode bot (requires spawn_services to be set and the
# fantasy plugin to be loaded).
# fantasy plugin to be loaded). This overrides the "prefix" option in the "pylink:" config
# block.
prefix: "@"
# Determines whether this bot should respond to its nick (requires spawn_services to be set and the
# fantasy plugin to be loaded). This overrides the "respond_to_nick" option in the "pylink:" config
# block.
#respond_to_nick: 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

@ -9,8 +9,6 @@ def handle_fantasy(irc, source, command, args):
# Break if the IRC network isn't ready.
return
respondtonick = conf.conf['bot'].get("respondtonick")
channel = args['target']
orig_text = args['text']
@ -25,6 +23,14 @@ def handle_fantasy(irc, source, command, args):
for botname, sbot in world.services.copy().items():
if botname not in world.services: # Bot was removed during iteration
continue
# Check respond to nick options in this order:
# 1) The service specific "respond_to_nick" option
# 2) The global "pylink::respond_to_nick" option
# 3) The (deprecated) global "bot::respondtonick" option.
respondtonick = conf.conf.get(botname, {}).get('respond_to_nick',
conf.conf['pylink'].get("respond_to_nick", conf.conf['bot'].get("respondtonick")))
log.debug('(%s) fantasy: checking bot %s', irc.name, botname)
servuid = sbot.uids.get(irc.name)
if servuid in irc.channels[channel].users: