changed commands.py to show usage help (if available) when minimum arguments are not met.

This commit is contained in:
jesopo 2016-04-10 17:31:55 +01:00
parent 842de08b47
commit 1750c2b1ec
No known key found for this signature in database
GPG key ID: 0BBDEB2AEFCFFCB3

View file

@ -108,6 +108,10 @@ class Module(object):
args_split = list(filter(None, event["message_split"][args_index:])) args_split = list(filter(None, event["message_split"][args_index:]))
min_args = hook.kwargs.get("min_args") min_args = hook.kwargs.get("min_args")
if min_args and len(args_split) < min_args: if min_args and len(args_split) < min_args:
if "usage" in hook.kwargs:
stderr.write("Not enough arguments, usage: %s %s" % (
command, hook.kwargs["usage"])).send()
else:
stderr.write("Not enough arguments (minimum: %d)" % min_args stderr.write("Not enough arguments (minimum: %d)" % min_args
).send() ).send()
else: else: