From f548e17c8053a617ca675372f2354e83ead1d6b1 Mon Sep 17 00:00:00 2001 From: Tulir Asokan Date: Tue, 5 Feb 2019 12:27:19 +0200 Subject: [PATCH] Fix regex flag args --- maubot/handlers/command.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/maubot/handlers/command.py b/maubot/handlers/command.py index bc984f9..f9ae155 100644 --- a/maubot/handlers/command.py +++ b/maubot/handlers/command.py @@ -330,13 +330,14 @@ def passive(regex: Union[str, Pattern], *, msgtypes: Sequence[MessageType] = (Me case_insensitive: bool = False, multiline: bool = False, dot_all: bool = False ) -> PassiveCommandHandlerDecorator: if not isinstance(regex, Pattern): - regex = re.compile(regex) - if case_insensitive: - regex.flags |= re.IGNORECASE - if multiline: - regex.flags |= re.MULTILINE - if dot_all: - regex.flags |= re.DOTALL + flags = re.RegexFlag.UNICODE + if case_insensitive: + flags |= re.IGNORECASE + if multiline: + flags |= re.MULTILINE + if dot_all: + flags |= re.DOTALL + regex = re.compile(regex, flags=flags) def decorator(func: CommandHandlerFunc) -> CommandHandlerFunc: combine = None