blob: 46187926149848180d97468dc73af662972492aa (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
import re
from functools import cache
from config import user_config
def contains_forbidden_term(comment):
matcher = build_matcher()
if comment is None:
return False
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('|'))
|