From eb6117da4fa0d0e118988677406ff3d02e60e85b Mon Sep 17 00:00:00 2001 From: James Vega Date: Mon, 22 Dec 2008 02:20:37 +0000 Subject: [PATCH] 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. --- src/callbacks.py | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/src/callbacks.py b/src/callbacks.py index 9ad4857ca..1f9ee8087 100644 --- a/src/callbacks.py +++ b/src/callbacks.py @@ -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))