mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-01-11 12:42:34 +01:00
Embed formatArgumentError in Commands._callCommand.
This allows it to utilize getCommandHelp which means that plugins which define their own getCommandHelp will no longer have broken help responses when ArgumentError exceptions are raised.
This commit is contained in:
parent
338a899782
commit
eb6117da4f
@ -353,17 +353,6 @@ def tokenize(s, channel=None):
|
||||
except ValueError, e:
|
||||
raise SyntaxError, str(e)
|
||||
|
||||
def formatArgumentError(method, name=None):
|
||||
if name is None:
|
||||
name = method.__name__
|
||||
if hasattr(method, '__doc__') and method.__doc__:
|
||||
if conf.get(conf.supybot.reply.showSimpleSyntax, dynamic.channel):
|
||||
return getSyntax(method, name=name)
|
||||
else:
|
||||
return getHelp(method, name=name)
|
||||
else:
|
||||
return 'Invalid arguments for %s.' % method.__name__
|
||||
|
||||
def formatCommand(command):
|
||||
return ' '.join(command)
|
||||
|
||||
@ -1185,8 +1174,11 @@ class Commands(BasePlugin):
|
||||
except (getopt.GetoptError, ArgumentError), e:
|
||||
self.log.debug('Got %s, giving argument error.',
|
||||
utils.exnToString(e))
|
||||
method = self.getCommandMethod(command)
|
||||
irc.reply(formatArgumentError(method, name=formatCommand(command)))
|
||||
help = self.getCommandHelp(command)
|
||||
if help.endswith('command has no help.'):
|
||||
irc.error('Invalid arguments for %s.' % method.__name__)
|
||||
else:
|
||||
irc.reply(help)
|
||||
except (SyntaxError, Error), e:
|
||||
self.log.debug('Error return: %s', utils.exnToString(e))
|
||||
irc.error(str(e))
|
||||
|
Loading…
Reference in New Issue
Block a user