mirror of
https://github.com/jlu5/PyLink.git
synced 2024-11-23 19:19:31 +01:00
Split fantasy prefix definitions into service-specific blocks
Closes #426. This makes the pylink::prefix (aka bot::prefix) option only affect the main PyLink bot, and deprecates the pylink::prefixes::<...> options. As the bot: config block is no longer checked, this commit depends on commit 45ed5b962e215763f7659631d1b98a5031dbab92 (ref #343) to alias it to conf::pylink.
This commit is contained in:
parent
fb626c8a97
commit
bf42109d81
@ -15,18 +15,23 @@ pylink:
|
|||||||
# Server description (shown in /links, /whois, etc.)
|
# Server description (shown in /links, /whois, etc.)
|
||||||
serverdesc: PyLink Server
|
serverdesc: PyLink Server
|
||||||
|
|
||||||
# Sets the default fantasy command prefix for calling commands inside channels
|
# Sets the fantasy command prefix for the main PyLink bot. To configure fantasy prefixes for
|
||||||
# (requires fantasy plugin).
|
# other service bots, add or modify the "prefix:" option in the configuration section of each
|
||||||
|
# plugin.
|
||||||
|
# Note: prior to PyLink 1.2, defining a prefix here made it global for all service bots. This
|
||||||
|
# was removed because it called all bots in a channel at once (even if they have conflicting
|
||||||
|
# commands), which usually led to one successful reply and a string of "Command not found"
|
||||||
|
# errors.
|
||||||
prefix: "&"
|
prefix: "&"
|
||||||
|
|
||||||
# Determines whether the bot will reply to commands prefixed with its nick
|
# Whether service bots will respond to commands prefixes with their nick.
|
||||||
# (case sensitive and requires the fantasy plugin).
|
|
||||||
respondtonick: true
|
respondtonick: true
|
||||||
|
|
||||||
# Custom fantasy command prefixes for other service bots if they are loaded
|
# Custom prefixes for other service bots if they are loaded. Note: this is deprecated
|
||||||
# (requires fantasy plugin).
|
# since PyLink 1.2 in favour of adding prefixes into each plugin's configuration block
|
||||||
prefixes:
|
# itself (see the "prefix:" option in the "games:" block in this case).
|
||||||
games: "@"
|
#prefixes:
|
||||||
|
# games: "@"
|
||||||
|
|
||||||
# Determines whether hideoper modes should be respected in WHOIS replies.
|
# Determines whether hideoper modes should be respected in WHOIS replies.
|
||||||
# Defaults to true if not specified.
|
# Defaults to true if not specified.
|
||||||
@ -638,10 +643,17 @@ automode:
|
|||||||
# This option overrides the global "spawn_services" option defined in "pylink:".
|
# This option overrides the global "spawn_services" option defined in "pylink:".
|
||||||
#spawn_service: true
|
#spawn_service: true
|
||||||
|
|
||||||
|
# Defines a fantasy prefix for the Automode bot (requires spawn_services to be set and the
|
||||||
|
# fantasy plugin to be loaded).
|
||||||
|
prefix: "@"
|
||||||
|
|
||||||
games:
|
games:
|
||||||
# Sets the nick of the Games service, if you're using it. This defaults to "games" if not defined.
|
# Sets the nick of the Games service, if you're using it. This defaults to "games" if not defined.
|
||||||
nick: Games
|
nick: Games
|
||||||
|
|
||||||
|
# Defines a fantasy prefix for the Games bot.
|
||||||
|
prefix: "./"
|
||||||
|
|
||||||
stats:
|
stats:
|
||||||
# Determines the time format that the Stats plugin should use for showing dates + times.
|
# Determines the time format that the Stats plugin should use for showing dates + times.
|
||||||
# Defaults to "%a, %d %b %Y %H:%M:%S +0000" (the RFC 2812 standard) if not specified.
|
# Defaults to "%a, %d %b %Y %H:%M:%S +0000" (the RFC 2812 standard) if not specified.
|
||||||
|
@ -29,11 +29,10 @@ def handle_fantasy(irc, source, command, args):
|
|||||||
servuid = sbot.uids.get(irc.name)
|
servuid = sbot.uids.get(irc.name)
|
||||||
if servuid in irc.channels[channel].users:
|
if servuid in irc.channels[channel].users:
|
||||||
|
|
||||||
# Try to look up a prefix specific for this bot in
|
# Look up a string prefix for this bot in either its own configuration block, or
|
||||||
# bot: prefixes: <botname>, falling back to the default prefix if not
|
# in bot::prefixes::<botname>.
|
||||||
# specified.
|
prefixes = [conf.conf.get(botname, {}).get('prefix',
|
||||||
prefixes = [conf.conf['bot'].get('prefixes', {}).get(botname) or
|
conf.conf['bot'].get('prefixes', {}).get(botname))]
|
||||||
conf.conf['bot'].get('prefix')]
|
|
||||||
|
|
||||||
# If responding to nick is enabled, add variations of the current nick
|
# If responding to nick is enabled, add variations of the current nick
|
||||||
# to the prefix list: "<nick>," and "<nick>:"
|
# to the prefix list: "<nick>," and "<nick>:"
|
||||||
@ -43,14 +42,12 @@ def handle_fantasy(irc, source, command, args):
|
|||||||
prefixes += [nick+',', nick+':']
|
prefixes += [nick+',', nick+':']
|
||||||
|
|
||||||
if not any(prefixes):
|
if not any(prefixes):
|
||||||
# We finished with an empty prefixes list, meaning fantasy is misconfigured!
|
# No prefixes were set, so skip.
|
||||||
log.warning("(%s) Fantasy prefix for bot %s was not set in configuration - "
|
|
||||||
"fantasy commands will not work!", irc.name, botname)
|
|
||||||
continue
|
continue
|
||||||
|
|
||||||
lowered_text = irc.toLower(orig_text)
|
lowered_text = irc.toLower(orig_text)
|
||||||
for prefix in prefixes: # Cycle through the prefixes list we finished with.
|
for prefix in filter(None, prefixes): # Cycle through the prefixes list we finished with.
|
||||||
if prefix and lowered_text.startswith(prefix):
|
if lowered_text.startswith(prefix):
|
||||||
|
|
||||||
# Cut off the length of the prefix from the text.
|
# Cut off the length of the prefix from the text.
|
||||||
text = orig_text[len(prefix):]
|
text = orig_text[len(prefix):]
|
||||||
|
Loading…
Reference in New Issue
Block a user