fix support for non-consuming command spec args

This commit is contained in:
jesopo 2020-01-28 01:23:19 +00:00
parent c831984e20
commit f3c31ec3c1

View file

@ -89,12 +89,12 @@ class Module(ModuleManager.BaseModule):
value = server.get_user(args[0], create=True) value = server.get_user(args[0], create=True)
n = 1 n = 1
elif argument_type.type == "channelonly": elif argument_type.type == "channelonly":
if not channel == None: value = not channel == None
n = 0 n = 0
error = "Command not valid in private message" error = "Command not valid in private message"
elif argument_type.type == "privateonly": elif argument_type.type == "privateonly":
if channel == None: value = channel == None
n = 0 n = 0
error = "Command not valid in private message" error = "Command not valid in private message"
options.append([argument_type, value, n, error]) options.append([argument_type, value, n, error])
@ -109,7 +109,7 @@ class Module(ModuleManager.BaseModule):
current_error = error current_error = error
elif n > len(args): elif n > len(args):
current_error = "Not enough arguments" current_error = "Not enough arguments"
return [argument_type, -1, current_error or "Invalid arguments"] return [None, -1, current_error or "Invalid arguments"]
@utils.hook("preprocess.command") @utils.hook("preprocess.command")
@utils.kwarg("priority", EventManager.PRIORITY_HIGH) @utils.kwarg("priority", EventManager.PRIORITY_HIGH)
@ -153,10 +153,11 @@ class Module(ModuleManager.BaseModule):
else: else:
value = None value = None
out[i] = value if not argument_type == None and spec_argument.consume:
argument_type_name = argument_type.name() out[i] = value
if argument_type_name: argument_type_name = argument_type.name()
out[argument_type_name] = value if argument_type_name:
out[argument_type_name] = value
if not failed: if not failed:
kwargs["spec"] = out kwargs["spec"] = out