From bb45218639b93672baf48d8123a8ebfafd325d06 Mon Sep 17 00:00:00 2001 From: Tulir Asokan Date: Sun, 17 Nov 2019 22:31:02 +0200 Subject: [PATCH] Fix splitting arguments when command has newlines --- maubot/handlers/command.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/maubot/handlers/command.py b/maubot/handlers/command.py index 93f1f90..4336650 100644 --- a/maubot/handlers/command.py +++ b/maubot/handlers/command.py @@ -281,7 +281,7 @@ class RegexArgument(Argument): def match(self, val: str, **kwargs) -> Tuple[str, Any]: orig_val = val if not self.pass_raw: - val = val.split(" ")[0] + val = re.split(r"\s", val, 1)[0] match = self.regex.match(val) if match: return (orig_val[:match.start()] + orig_val[match.end():], @@ -299,7 +299,7 @@ class CustomArgument(Argument): if self.pass_raw: return self.matcher(val) orig_val = val - val = val.split(" ")[0] + val = re.split(r"\s", val, 1)[0] res = self.matcher(val) if res: return orig_val[len(val):], res @@ -310,7 +310,7 @@ class SimpleArgument(Argument): def match(self, val: str, **kwargs) -> Tuple[str, Any]: if self.pass_raw: return "", val - res = val.split(" ")[0] + res = re.split(r"\s", val, 1)[0] return val[len(res):], res