This commit is contained in:
Aevann1 2022-01-24 01:06:34 +02:00
parent 025713e25b
commit c98ef138a2
22 changed files with 115 additions and 3402 deletions

View file

@ -99,10 +99,10 @@ SLURS = {
single_words = "|".join([slur.lower() for slur in SLURS.keys()])
SLUR_REGEX = re.compile(rf"(?i)((?<=\s|>)|^)({single_words})((?=[\s<,.]|s[\s<,.])|$)")
def sub_matcher(match: re.Match) -> str:
def sub_matcher(match: re.Match):
return SLURS[match.group(0).lower()]
def censor_slurs(body: str, logged_user) -> str:
def censor_slurs(body: str, logged_user):
if not logged_user or logged_user.slurreplacer: body = SLUR_REGEX.sub(sub_matcher, body)
return body