aboutsummaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorGravatar jesopo2019-11-20 18:23:57 +0000
committerGravatar jesopo2019-11-20 18:25:32 +0000
commit352df0fa7502a61e6509ed316c5ef5c072983fd0 (patch)
treed36a2c708ff7bd9d117a94a4e481abf5f3d2d7e0 /modules
parentupdate CHANGELOG.md (diff)
signature
support "$$" as a literal "$" in alias arg replacements
Diffstat (limited to 'modules')
-rw-r--r--modules/aliases.py32
1 files changed, 17 insertions, 15 deletions
diff --git a/modules/aliases.py b/modules/aliases.py
index 4177eab1..3b120370 100644
--- a/modules/aliases.py
+++ b/modules/aliases.py
@@ -7,22 +7,24 @@ SETTING_PREFIX = "command-alias-"
class Module(ModuleManager.BaseModule):
def _arg_replace(self, s, args_split):
- for match in REGEX_ARG_NUMBER.finditer(s):
- if match.group(1):
- index = int(match.group(1))
- continuous = match.group(2) == "-"
- if index >= len(args_split):
- raise IndexError("Unknown alias arg index")
- else:
- index = 0
- continuous = True
+ parts = s.split("$$")
+ for i, part in enumerate(parts):
+ for match in REGEX_ARG_NUMBER.finditer(s):
+ if match.group(1):
+ index = int(match.group(1))
+ continuous = match.group(2) == "-"
+ if index >= len(args_split):
+ raise IndexError("Unknown alias arg index")
+ else:
+ index = 0
+ continuous = True
- if continuous:
- replace = " ".join(args_split[index:])
- else:
- replace = args_split[index]
- s = s.replace(match.group(0), replace)
- return s
+ if continuous:
+ replace = " ".join(args_split[index:])
+ else:
+ replace = args_split[index]
+ parts[i] = part.replace(match.group(0), replace)
+ return "$".join(parts)
def _get_alias(self, server, target, command):
setting = "%s%s" % (SETTING_PREFIX, command)