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.
|
# Now, for normal handling.
|
||||||
channel = msg.args[0]
|
channel = msg.args[0]
|
||||||
if conf.get(conf.supybot.reply.whenNotCommand, channel):
|
if conf.get(conf.supybot.reply.whenNotCommand, channel):
|
||||||
command = tokens and tokens[0] or ''
|
if len(tokens) >= 2:
|
||||||
irc.errorInvalid('command', command, repr=False)
|
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:
|
else:
|
||||||
if tokens:
|
if tokens:
|
||||||
# echo [] will get us an empty token set, but there's no need
|
# echo [] will get us an empty token set, but there's no need
|
||||||
|
@ -35,12 +35,21 @@ class MiscTestCase(ChannelPluginTestCase):
|
|||||||
'Channel', 'Dict', 'User', 'String')
|
'Channel', 'Dict', 'User', 'String')
|
||||||
def testReplyWhenNotCommand(self):
|
def testReplyWhenNotCommand(self):
|
||||||
try:
|
try:
|
||||||
original = str(conf.supybot.reply.whenNotCommand)
|
original = conf.supybot.reply.whenNotCommand()
|
||||||
conf.supybot.reply.whenNotCommand.set('True')
|
conf.supybot.reply.whenNotCommand.setValue(True)
|
||||||
self.prefix = 'somethingElse!user@host.domain.tld'
|
self.prefix = 'somethingElse!user@host.domain.tld'
|
||||||
|
self.assertRegexp('foo', 'not.*command')
|
||||||
self.assertRegexp('foo bar baz', 'not.*command')
|
self.assertRegexp('foo bar baz', 'not.*command')
|
||||||
finally:
|
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:
|
# if network:
|
||||||
# def testNotReplyWhenRegexpsMatch(self):
|
# def testNotReplyWhenRegexpsMatch(self):
|
||||||
|
Loading…
Reference in New Issue
Block a user