first commit
This commit is contained in:
commit
efa5080897
127 changed files with 18610 additions and 0 deletions
16
backend/app/template_message_validator.py
Normal file
16
backend/app/template_message_validator.py
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
import re
|
||||
|
||||
PLACEHOLDER_PATTERN = re.compile(r"\{#(?:var|num)#\}")
|
||||
|
||||
|
||||
def message_matches_template(template_text: str, message: str) -> bool:
|
||||
message = message.strip()
|
||||
if not message:
|
||||
return False
|
||||
parts = PLACEHOLDER_PATTERN.split(template_text.strip())
|
||||
pattern = ""
|
||||
for index, part in enumerate(parts):
|
||||
pattern += re.escape(part)
|
||||
if index < len(parts) - 1:
|
||||
pattern += r".+?"
|
||||
return re.fullmatch(pattern, message, flags=re.DOTALL) is not None
|
||||
Loading…
Add table
Add a link
Reference in a new issue