support !... as "one or more", show "not enough args" error
This commit is contained in:
parent
1d9621022c
commit
264e544ce5
1 changed files with 13 additions and 7 deletions
|
@ -83,12 +83,14 @@ class Module(ModuleManager.BaseModule):
|
||||||
chunk = server.get_user(args[0])
|
chunk = server.get_user(args[0])
|
||||||
n = 1
|
n = 1
|
||||||
error = "Unknown nickname"
|
error = "Unknown nickname"
|
||||||
elif spec_type == "word" and args:
|
elif spec_type == "word":
|
||||||
chunk = args[0]
|
if args:
|
||||||
|
chunk = args[0]
|
||||||
n = 1
|
n = 1
|
||||||
elif spec_type == "...":
|
elif spec_type == "...":
|
||||||
chunk = " ".join(args)
|
if args:
|
||||||
n = len(args)
|
chunk = " ".join(args)
|
||||||
|
n = max(1, len(args))
|
||||||
|
|
||||||
options.append([chunk, n, error])
|
options.append([chunk, n, error])
|
||||||
return options
|
return options
|
||||||
|
@ -122,10 +124,8 @@ class Module(ModuleManager.BaseModule):
|
||||||
spec_type = spec_types[i]
|
spec_type = spec_types[i]
|
||||||
raw_spec_type = raw_spec_types[i]
|
raw_spec_type = raw_spec_types[i]
|
||||||
|
|
||||||
if error and not first_error:
|
|
||||||
first_error = error
|
|
||||||
|
|
||||||
if chunk:
|
if not chunk == None:
|
||||||
if "~" in raw_spec_type:
|
if "~" in raw_spec_type:
|
||||||
kwargs[raw_spec_type.split("~", 1)[1]] = chunk
|
kwargs[raw_spec_type.split("~", 1)[1]] = chunk
|
||||||
|
|
||||||
|
@ -135,6 +135,12 @@ class Module(ModuleManager.BaseModule):
|
||||||
chunk = [spec_type, chunk]
|
chunk = [spec_type, chunk]
|
||||||
found = chunk
|
found = chunk
|
||||||
break
|
break
|
||||||
|
elif not error and n > 0:
|
||||||
|
error = "Not enough arguments"
|
||||||
|
|
||||||
|
if error and not first_error:
|
||||||
|
first_error = error
|
||||||
|
|
||||||
out.append(found)
|
out.append(found)
|
||||||
|
|
||||||
if not optional and not found:
|
if not optional and not found:
|
||||||
|
|
Loading…
Reference in a new issue