mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-01-11 12:42:34 +01:00
Give a better error message when a given command isn't found in a plugin.
This commit is contained in:
parent
6ed01d4a87
commit
5c8677cf22
@ -81,8 +81,20 @@ class Misc(callbacks.Plugin):
|
||||
# Now, for normal handling.
|
||||
channel = msg.args[0]
|
||||
if conf.get(conf.supybot.reply.whenNotCommand, channel):
|
||||
command = tokens and tokens[0] or ''
|
||||
irc.errorInvalid('command', command, repr=False)
|
||||
if len(tokens) >= 2:
|
||||
cb = irc.getCallback(tokens[0])
|
||||
if cb:
|
||||
plugin = cb.name()
|
||||
irc.reply(format('The %q plugin is loaded, but there is '
|
||||
'no command named %q in it. Try "list '
|
||||
'%s" to see the commands in the %q '
|
||||
'plugin.', plugin, tokens[1],
|
||||
plugin, plugin))
|
||||
else:
|
||||
irc.errorInvalid('command', tokens[0], repr=False)
|
||||
else:
|
||||
command = tokens and tokens[0] or ''
|
||||
irc.errorInvalid('command', command, repr=False)
|
||||
else:
|
||||
if tokens:
|
||||
# echo [] will get us an empty token set, but there's no need
|
||||
|
@ -35,12 +35,21 @@ class MiscTestCase(ChannelPluginTestCase):
|
||||
'Channel', 'Dict', 'User', 'String')
|
||||
def testReplyWhenNotCommand(self):
|
||||
try:
|
||||
original = str(conf.supybot.reply.whenNotCommand)
|
||||
conf.supybot.reply.whenNotCommand.set('True')
|
||||
original = conf.supybot.reply.whenNotCommand()
|
||||
conf.supybot.reply.whenNotCommand.setValue(True)
|
||||
self.prefix = 'somethingElse!user@host.domain.tld'
|
||||
self.assertRegexp('foo', 'not.*command')
|
||||
self.assertRegexp('foo bar baz', 'not.*command')
|
||||
finally:
|
||||
conf.supybot.reply.whenNotCommand.set(original)
|
||||
conf.supybot.reply.whenNotCommand.setValue(original)
|
||||
|
||||
def testReplyWhenNotCommandButFirstCommandIsPluginName(self):
|
||||
try:
|
||||
original = conf.supybot.reply.whenNotCommand()
|
||||
conf.supybot.reply.whenNotCommand.setValue(True)
|
||||
self.assertRegexp('misc foo', '"list Misc"')
|
||||
finally:
|
||||
conf.supybot.reply.whenNotCommand.setValue(original)
|
||||
|
||||
# if network:
|
||||
# def testNotReplyWhenRegexpsMatch(self):
|
||||
|
Loading…
Reference in New Issue
Block a user