import re from functools import cache from config import user_config def contains_forbidden_term(comment): matcher = build_matcher() return matcher.search(comment) is not None @cache def build_matcher(): regex_string = '' for word in user_config['Env']['blacklist']: regex_string += f"{word}|" return re.compile(regex_string.removesuffix('|'))