This commit is contained in:
Aevann1 2022-02-04 11:15:59 +02:00
parent 53b1a2f862
commit 6a46428d05
8 changed files with 42 additions and 42 deletions

View file

@ -100,7 +100,7 @@ SLURS = {
}
single_words = "|".join([slur.lower() for slur in SLURS.keys()])
SLUR_REGEX = re.compile(rf"(?i)((?<=\s|>)|^)({single_words})((?=[\s<,.]|s[\s<,.])|$)", flags=re.A)
SLUR_REGEX = re.compile(rf"(?i)((?<=\s|>)|^)({single_words})((?=[\s<,.]|s[\s<,.])|$)", re.A)
def sub_matcher(match: re.Match):
return SLURS[match.group(0).lower()]
@ -112,8 +112,8 @@ def censor_slurs(body: str, logged_user):
def torture_ap(body, username):
body = SLUR_REGEX.sub(sub_matcher, body)
for k, l in AJ_REPLACEMENTS.items(): body = body.replace(k, l)
body = re.sub('(^|\s|\n)(i|me) ', rf'\1@{username} ', body, flags=re.I|re.A)
body = re.sub("(^|\s|\n)i'm ", rf'\1@{username} is ', body, flags=re.I|re.A)
body = re.sub('(^|\s|\n)(i|me) ', rf'\1@{username} ', body, re.I|re.A)
body = re.sub("(^|\s|\n)i'm ", rf'\1@{username} is ', body, re.I|re.A)
return body