StarRailCopilot/tasks/rogue/utils.py
Hengyu 14bf3c81b4 Fix: miss judge choose blessing page sometimes;
Add wait until blessing stable function;
2023-08-11 17:37:55 +08:00

19 lines
601 B
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import re
REGEX_PUNCTUATION = re.compile(r'[ ,.\'"“”,。:!??·•—/()()「」『』【】《》]')
def parse_name(n):
n = REGEX_PUNCTUATION.sub('', str(n)).lower()
return n
def get_regex_from_keyword_name(keyword, attr_name):
string = ""
for instance in keyword.instances.values():
if hasattr(instance, attr_name):
for name in instance.__getattribute__(attr_name):
string += f"{name}|"
# some pattern contain each other, make sure each pattern end with "-" or the end of string
return f"(?:({string[:-1]})(?:-|$))?"