forked from rDrama/rDrama
parent
c17da3bb86
commit
757e7ed96b
|
@ -1,6 +1,5 @@
|
||||||
import re
|
import re
|
||||||
from .config.const import *
|
from .config.const import *
|
||||||
from .regex import NOT_IN_CODE_OR_LINKS
|
|
||||||
|
|
||||||
tranny = f'<img loading="lazy" data-bs-toggle="tooltip" alt=":marseytrain:" title=":marseytrain:" src="{SITE_FULL_IMAGES}/e/marseytrain.webp">'
|
tranny = f'<img loading="lazy" data-bs-toggle="tooltip" alt=":marseytrain:" title=":marseytrain:" src="{SITE_FULL_IMAGES}/e/marseytrain.webp">'
|
||||||
trannie = f'<img loading="lazy" data-bs-toggle="tooltip" alt=":!marseytrain:" title=":!marseytrain:" src="{SITE_FULL_IMAGES}/e/marseytrain.webp">'
|
trannie = f'<img loading="lazy" data-bs-toggle="tooltip" alt=":!marseytrain:" title=":!marseytrain:" src="{SITE_FULL_IMAGES}/e/marseytrain.webp">'
|
||||||
|
@ -107,9 +106,8 @@ PROFANITIES = {
|
||||||
|
|
||||||
slur_single_words = "|".join([slur.lower() for slur in SLURS.keys()])
|
slur_single_words = "|".join([slur.lower() for slur in SLURS.keys()])
|
||||||
profanity_single_words = "|".join([profanity.lower() for profanity in PROFANITIES.keys()])
|
profanity_single_words = "|".join([profanity.lower() for profanity in PROFANITIES.keys()])
|
||||||
|
slur_regex = re.compile(f"<[^>]*>|{slur_single_words}", flags=re.I|re.A)
|
||||||
slur_regex = re.compile(f"(<[^>]*>|{slur_single_words})" + NOT_IN_CODE_OR_LINKS, flags=re.I|re.A)
|
profanity_regex = re.compile(f"<[^>]*>|{profanity_single_words}", flags=re.I|re.A)
|
||||||
profanity_regex = re.compile(f"(<[^>]*>|{profanity_single_words})" + NOT_IN_CODE_OR_LINKS, flags=re.I|re.A)
|
|
||||||
|
|
||||||
SLURS_FOR_REPLACING = {}
|
SLURS_FOR_REPLACING = {}
|
||||||
for k, val in SLURS.items():
|
for k, val in SLURS.items():
|
||||||
|
@ -152,6 +150,9 @@ def sub_matcher_profanities(match):
|
||||||
def censor_slurs_profanities(body, logged_user, is_plain=False):
|
def censor_slurs_profanities(body, logged_user, is_plain=False):
|
||||||
if not body: return ""
|
if not body: return ""
|
||||||
|
|
||||||
|
if '<pre>' in body or '<code>' in body:
|
||||||
|
return body
|
||||||
|
|
||||||
if not logged_user or logged_user == 'chat' or logged_user.slurreplacer:
|
if not logged_user or logged_user == 'chat' or logged_user.slurreplacer:
|
||||||
body = slur_regex.sub(sub_matcher_slurs, body)
|
body = slur_regex.sub(sub_matcher_slurs, body)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue