support "$-" for alias arg, meaning "0 or more args"
This commit is contained in:
parent
9e66390c35
commit
0a1a3551a2
1 changed files with 8 additions and 4 deletions
|
@ -8,7 +8,7 @@ from . import outs
|
||||||
COMMAND_METHOD = "command-method"
|
COMMAND_METHOD = "command-method"
|
||||||
COMMAND_METHODS = ["PRIVMSG", "NOTICE"]
|
COMMAND_METHODS = ["PRIVMSG", "NOTICE"]
|
||||||
|
|
||||||
REGEX_ARG_NUMBER = re.compile(r"\$(\d+)(-?)")
|
REGEX_ARG_NUMBER = re.compile(r"\$(?:(\d+)(-?)|(-))")
|
||||||
|
|
||||||
MESSAGE_TAGS_CAP = utils.irc.Capability("message-tags",
|
MESSAGE_TAGS_CAP = utils.irc.Capability("message-tags",
|
||||||
"draft/message-tags-0.2")
|
"draft/message-tags-0.2")
|
||||||
|
@ -66,14 +66,18 @@ class Module(ModuleManager.BaseModule):
|
||||||
|
|
||||||
def _alias_arg_replace(self, s, args_split):
|
def _alias_arg_replace(self, s, args_split):
|
||||||
for match in REGEX_ARG_NUMBER.finditer(s):
|
for match in REGEX_ARG_NUMBER.finditer(s):
|
||||||
|
if match.group(1):
|
||||||
index = int(match.group(1))
|
index = int(match.group(1))
|
||||||
continuous = match.group(2) == "-"
|
continuous = match.group(2) == "-"
|
||||||
|
else:
|
||||||
|
index = -1
|
||||||
|
continuous = True
|
||||||
|
|
||||||
if index >= len(args_split):
|
if index >= len(args_split):
|
||||||
raise IndexError("Unknown alias arg index")
|
raise IndexError("Unknown alias arg index")
|
||||||
|
|
||||||
if continuous:
|
if continuous:
|
||||||
replace = " ".join(args_split[index:])
|
replace = " ".join(args_split[min(index, 0):])
|
||||||
else:
|
else:
|
||||||
replace = args_split[index]
|
replace = args_split[index]
|
||||||
s = s.replace(match.group(0), replace)
|
s = s.replace(match.group(0), replace)
|
||||||
|
|
Loading…
Reference in a new issue