Fix regex flag args

This commit is contained in:
Tulir Asokan 2019-02-05 12:27:19 +02:00
parent a57df919f5
commit f548e17c80

View File

@ -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 case_insensitive: bool = False, multiline: bool = False, dot_all: bool = False
) -> PassiveCommandHandlerDecorator: ) -> PassiveCommandHandlerDecorator:
if not isinstance(regex, Pattern): if not isinstance(regex, Pattern):
regex = re.compile(regex) flags = re.RegexFlag.UNICODE
if case_insensitive: if case_insensitive:
regex.flags |= re.IGNORECASE flags |= re.IGNORECASE
if multiline: if multiline:
regex.flags |= re.MULTILINE flags |= re.MULTILINE
if dot_all: if dot_all:
regex.flags |= re.DOTALL flags |= re.DOTALL
regex = re.compile(regex, flags=flags)
def decorator(func: CommandHandlerFunc) -> CommandHandlerFunc: def decorator(func: CommandHandlerFunc) -> CommandHandlerFunc:
combine = None combine = None