diff --git a/files/helpers/const.py b/files/helpers/const.py index f33567c5c..83a5334ef 100644 --- a/files/helpers/const.py +++ b/files/helpers/const.py @@ -24,6 +24,15 @@ AJ_REPLACEMENTS = { "too": '$#3$3', 'to': "too", '$#3$3': 'to', + + '$#3$3': 'to', + '$#3$3': 'to', + '$#3$3': 'to', + + 'she': 'they', + 'her': 'they', + 'he': 'they', + 'him': 'they', } SLURS = { @@ -43,8 +52,8 @@ SLURS = { "kill yourself": "keep yourself safe", "kys": "keep yourself safe", "kyle": "Kylie", - "nig": "I LOVE BIG BLACK COCK IN MY BUSSY", - "nigger": "I LOVE BIG BLACK COCK IN MY BUSSY", + "nig": "🏀", + "nigger": "🏀", "rapist": "male feminist", "steve akins": "penny verity oaken", "trannie": "🚂🚃🚃", @@ -181,6 +190,9 @@ def censor_slurs(body: str, logged_user) -> str: if not logged_user or logged_user.slurreplacer: body = SLUR_REGEX.sub(sub_matcher, body) return body +def censor_slurs2(body: str) -> str: + return SLUR_REGEX.sub(sub_matcher, body) + BADGES = { 1: { 'name': 'Alpha User', diff --git a/files/routes/comments.py b/files/routes/comments.py index f83868b87..47853447e 100644 --- a/files/routes/comments.py +++ b/files/routes/comments.py @@ -195,8 +195,11 @@ def api_comment(v): body += f"\n\n![]({url})" - for k, l in AJ_REPLACEMENTS.items(): body = body.replace(k, l) - body = body.upper() + if v.agendaposter: + for k, l in AJ_REPLACEMENTS.items(): body = body.replace(k, l) + body = body.replace('I ', f'@{v.username}') + body = censor_slurs2(body).upper().replace(' ME ', f'@{v.username}') + body_html = sanitize(CustomRenderer().render(mistletoe.Document(body))) if v.marseyawarded and len(list(re.finditer('>[^<\s+]|[^>\s+]<', body_html))) > 0: return {"error":"You can only type marseys!"}, 403 @@ -646,8 +649,11 @@ def edit_comment(cid, v): for i in re.finditer('^(https:\/\/.*\.(png|jpg|jpeg|gif|webp|PNG|JPG|JPEG|GIF|WEBP|9999))', body, re.MULTILINE): if "wikipedia" not in i.group(1): body = body.replace(i.group(1), f'![]({i.group(1)})') - for k, l in AJ_REPLACEMENTS.items(): body = body.replace(k, l) - body = body.upper() + if v.agendaposter: + for k, l in AJ_REPLACEMENTS.items(): body = body.replace(k, l) + body = body.replace('I ', f'@{v.username}') + body = censor_slurs2(body).upper().replace(' ME ', f'@{v.username}') + body_html = sanitize(CustomRenderer().render(mistletoe.Document(body))) if v.marseyawarded and len(list(re.finditer('>[^<\s+]|[^>\s+]<', body_html))) > 0: return {"error":"You can only type marseys!"}, 403 diff --git a/files/routes/posts.py b/files/routes/posts.py index 4bf685516..05d289592 100644 --- a/files/routes/posts.py +++ b/files/routes/posts.py @@ -249,8 +249,11 @@ def edit_post(pid, v): elif len(body) > 140: return {"error":"You have to type less than 140 characters!"}, 403 if title != p.title: - for k, l in AJ_REPLACEMENTS.items(): title = title.replace(k, l) - title = title.upper() + if v.agendaposter: + for k, l in AJ_REPLACEMENTS.items(): title = title.replace(k, l) + title = title.replace('I ', f'@{v.username}') + title = censor_slurs2(title).upper().replace(' ME ', f'@{v.username}') + title_html = filter_title(title) if v.marseyawarded and len(list(re.finditer('>[^<\s+]|[^>\s+]<', title_html))) > 0: return {"error":"You can only type marseys!"}, 403 p.title = title @@ -260,8 +263,10 @@ def edit_post(pid, v): for i in re.finditer('^(https:\/\/.*\.(png|jpg|jpeg|gif|webp|PNG|JPG|JPEG|GIF|WEBP|9999))', body, re.MULTILINE): if "wikipedia" not in i.group(1): body = body.replace(i.group(1), f'![]({i.group(1)})') - for k, l in AJ_REPLACEMENTS.items(): body = body.replace(k, l) - body = body.upper() + if v.agendaposter: + for k, l in AJ_REPLACEMENTS.items(): body = body.replace(k, l) + body = body.replace('I ', f'@{v.username}') + body = censor_slurs2(body).upper().replace(' ME ', f'@{v.username}') body_html = sanitize(CustomRenderer().render(mistletoe.Document(body))) @@ -540,8 +545,12 @@ def submit_post(v): title = request.values.get("title", "").strip() url = request.values.get("url", "").strip() - for k, l in AJ_REPLACEMENTS.items(): title = title.replace(k, l) - title = title.upper() + + if v.agendaposter: + for k, l in AJ_REPLACEMENTS.items(): title = title.replace(k, l) + title = title.replace('I ', f'@{v.username}') + title = censor_slurs2(title).upper().replace(' ME ', f'@{v.username}') + title_html = filter_title(title) body = request.values.get("body", "").strip() @@ -721,8 +730,10 @@ def submit_post(v): options.append(i.group(1)) body = body.replace(i.group(0), "") - for k, l in AJ_REPLACEMENTS.items(): body = body.replace(k, l) - body = body.upper() + if v.agendaposter: + for k, l in AJ_REPLACEMENTS.items(): body = body.replace(k, l) + body = body.replace('I ', f'@{v.username}') + body = censor_slurs2(body).upper().replace(' ME ', f'@{v.username}') body_html = sanitize(CustomRenderer().render(mistletoe.Document(body)))