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

ServiceBot: make displaying unknown command errors optional

Closes #441.
This commit is contained in:
James Lu 2017-03-28 22:18:51 -07:00
parent 4cd71d12ef
commit 5d10ee39be
2 changed files with 13 additions and 1 deletions

View File

@ -68,6 +68,9 @@ pylink:
#plugin_dirs: ["~/my-plugins", "~/pylink-contrib-modules/plugins"]
#protocol_dirs: ["~/pylink-contrib-modules/protocols"]
# Determines whether we should show unknown command errors for service bots. Defaults to True.
#show_unknown_commands: 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
@ -685,6 +688,10 @@ automode:
# block.
#respond_to_nick: true
# Determines whether we should show unknown command errors for this service bot. Defaults to True.
# This overrides the "show_unknown_commands" option in the "pylink:" config block.
#show_unknown_commands: 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

@ -335,7 +335,12 @@ class ServiceBot():
cmd = cmd_args[0].lower()
cmd_args = cmd_args[1:]
if cmd not in self.commands:
if cmd and not cmd.startswith('\x01'):
# XXX: we really need abstraction for this kind of config fetching...
show_unknown_cmds = irc.serverdata.get('%s_show_unknown_commands' % self.name,
conf.conf.get(self.name, {}).get('show_unknown_commands',
conf.conf['pylink'].get('show_unknown_commands', True)))
if cmd and show_unknown_cmds and not cmd.startswith('\x01'):
# Ignore empty commands and invalid command errors from CTCPs.
self.reply(irc, 'Error: Unknown command %r.' % cmd)
log.info('(%s/%s) Received unknown command %r from %s', irc.name, self.name, cmd, irc.getHostmask(source))