Skip to content

Commit

Permalink
Fix splitting arguments when command has newlines
Browse files Browse the repository at this point in the history
  • Loading branch information
tulir committed Nov 17, 2019
1 parent acd0872 commit bb45218
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions maubot/handlers/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ def __init__(self, name: str, label: str = None, *, required: bool = False,
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():],
Expand All @@ -299,7 +299,7 @@ def match(self, val: str, **kwargs) -> Tuple[str, Any]:
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
Expand All @@ -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


Expand Down

0 comments on commit bb45218

Please sign in to comment.