diff options
| author | 2019-09-30 10:15:12 +0100 | |
|---|---|---|
| committer | 2019-09-30 10:15:12 +0100 | |
| commit | 0a1a3551a208b31a4972b7ba02a94569ee78dc0c (patch) | |
| tree | ebe9fd6c3f029e4161042687acf51ca70e3659e9 /modules/commands/__init__.py | |
| parent | 'restat' -> 'restart' (diff) | |
| signature | ||
support "$-" for alias arg, meaning "0 or more args"
Diffstat (limited to 'modules/commands/__init__.py')
| -rw-r--r-- | modules/commands/__init__.py | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/modules/commands/__init__.py b/modules/commands/__init__.py index 1a3587b0..7c1d8ff5 100644 --- a/modules/commands/__init__.py +++ b/modules/commands/__init__.py @@ -8,7 +8,7 @@ from . import outs COMMAND_METHOD = "command-method" 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", "draft/message-tags-0.2") @@ -66,14 +66,18 @@ class Module(ModuleManager.BaseModule): def _alias_arg_replace(self, s, args_split): for match in REGEX_ARG_NUMBER.finditer(s): - index = int(match.group(1)) - continuous = match.group(2) == "-" + if match.group(1): + index = int(match.group(1)) + continuous = match.group(2) == "-" + else: + index = -1 + continuous = True if index >= len(args_split): raise IndexError("Unknown alias arg index") if continuous: - replace = " ".join(args_split[index:]) + replace = " ".join(args_split[min(index, 0):]) else: replace = args_split[index] s = s.replace(match.group(0), replace) |
