From 4a8220d6877f19fe35ff3c003f96b60d565c9082 Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Sat, 20 Aug 2022 00:12:53 +0200 Subject: [PATCH] make chudtopians immune to chud effects --- files/routes/admin.py | 4 ++-- files/routes/comments.py | 10 +++++----- files/routes/posts.py | 16 ++++++++++------ files/templates/comments.html | 2 +- files/templates/submission.html | 6 +++--- files/templates/submission_listing.html | 4 ++-- 6 files changed, 23 insertions(+), 19 deletions(-) diff --git a/files/routes/admin.py b/files/routes/admin.py index 63ae5c6347..9f603d924b 100644 --- a/files/routes/admin.py +++ b/files/routes/admin.py @@ -1127,7 +1127,7 @@ def approve_post(post_id, v): post = get_post(post_id) - if post.author.id == v.id and post.author.agendaposter and AGENDAPOSTER_PHRASE not in post.body.lower(): + if post.author.id == v.id and post.author.agendaposter and AGENDAPOSTER_PHRASE not in post.body.lower() and post.sub != 'chudtopia': return {"error": "You can't bypass the chud award!"} if not post: @@ -1322,7 +1322,7 @@ def approve_comment(c_id, v): comment = get_comment(c_id) if not comment: abort(404) - if comment.author.id == v.id and comment.author.agendaposter and AGENDAPOSTER_PHRASE not in comment.body.lower(): + if comment.author.id == v.id and comment.author.agendaposter and AGENDAPOSTER_PHRASE not in comment.body.lower() and comment.post.sub != 'chudtopia': return {"error": "You can't bypass the chud award!"} if comment.is_banned: diff --git a/files/routes/comments.py b/files/routes/comments.py index e97e333133..660b0fffd4 100644 --- a/files/routes/comments.py +++ b/files/routes/comments.py @@ -280,13 +280,13 @@ def comment(v): with open(f"snappy_{SITE_NAME}.txt", "a", encoding="utf-8") as f: f.write('\n{[para]}\n' + body) - if v.agendaposter and not v.marseyawarded and parent_post.id not in ADMIGGERS: + if v.agendaposter and not v.marseyawarded and parent_post.id not in ADMIGGERS and parent_post.sub != 'chudtopia': body = torture_ap(body, v.username) body_html = sanitize(body, limit_pings=True) - if parent_post.id not in ADMIGGERS and '!slots' not in body.lower() and '!blackjack' not in body.lower() and '!wordle' not in body.lower() and AGENDAPOSTER_PHRASE not in body.lower(): + if parent_post.id not in ADMIGGERS and '!slots' not in body.lower() and '!blackjack' not in body.lower() and '!wordle' not in body.lower() and AGENDAPOSTER_PHRASE not in body.lower() and parent_post.sub != 'chudtopia': existing = g.db.query(Comment.id).filter(Comment.author_id == v.id, Comment.deleted_utc == 0, Comment.parent_comment_id == parent_comment_id, @@ -416,7 +416,7 @@ def comment(v): n = Notification(comment_id=c_based.id, user_id=v.id) g.db.add(n) - if v.agendaposter and not v.marseyawarded and AGENDAPOSTER_PHRASE not in c.body.lower(): + if v.agendaposter and not v.marseyawarded and AGENDAPOSTER_PHRASE not in c.body.lower() and parent_post.sub != 'chudtopia': c.is_banned = True c.ban_reason = "AutoJanny" @@ -654,7 +654,7 @@ def edit_comment(cid, v): elif v.bird and len(body) > 140: return {"error":"You have to type less than 140 characters!"}, 403 - if v.agendaposter and not v.marseyawarded: + if v.agendaposter and not v.marseyawarded and c.post.sub != 'chudtopia': body = torture_ap(body, v.username) for i in poll_regex.finditer(body): @@ -731,7 +731,7 @@ def edit_comment(cid, v): notif = Notification(comment_id=c.id, user_id=CARP_ID) g.db.add(notif) - if v.agendaposter and not v.marseyawarded and AGENDAPOSTER_PHRASE not in c.body.lower(): + if v.agendaposter and not v.marseyawarded and AGENDAPOSTER_PHRASE not in c.body.lower() and c.post.sub != 'chudtopia': return {"error": f'You have to include "{AGENDAPOSTER_PHRASE}" in your comment!'}, 403 diff --git a/files/routes/posts.py b/files/routes/posts.py index 22cd3b4104..38948e1b3f 100644 --- a/files/routes/posts.py +++ b/files/routes/posts.py @@ -406,7 +406,8 @@ def edit_post(pid, v): return {"error":"You have to type less than 140 characters!"}, 403 if title != p.title: - if v.id == p.author_id and v.agendaposter and not v.marseyawarded: title = torture_ap(title, v.username) + if v.id == p.author_id and v.agendaposter and not v.marseyawarded and p.sub != 'chudtopia': + title = torture_ap(title, v.username) title_html = filter_emojis_only(title, edit=True) @@ -421,7 +422,8 @@ def edit_post(pid, v): body = body.strip() if body != p.body: - if v.id == p.author_id and v.agendaposter and not v.marseyawarded: body = torture_ap(body, v.username) + if v.id == p.author_id and v.agendaposter and not v.marseyawarded and p.sub != 'chudtopia': + body = torture_ap(body, v.username) for i in poll_regex.finditer(body): body = body.replace(i.group(0), "") @@ -459,7 +461,7 @@ def edit_post(pid, v): p.body_html = body_html - if v.id == p.author_id and v.agendaposter and not v.marseyawarded and AGENDAPOSTER_PHRASE not in f'{p.body}{p.title}'.lower(): + if v.id == p.author_id and v.agendaposter and not v.marseyawarded and AGENDAPOSTER_PHRASE not in f'{p.body}{p.title}'.lower() and p.sub != 'chudtopia': return {"error": f'You have to include "{AGENDAPOSTER_PHRASE}" in your post!'}, 403 @@ -717,7 +719,8 @@ def submit_post(v, sub=None): if v.is_suspended: return error("You can't perform this action while banned.") - if v.agendaposter and not v.marseyawarded: title = torture_ap(title, v.username) + if v.agendaposter and not v.marseyawarded and sub != 'chudtopia': + title = torture_ap(title, v.username) title_html = filter_emojis_only(title, graceful=True) @@ -887,7 +890,8 @@ def submit_post(v, sub=None): choices.append(i.group(1)) body = body.replace(i.group(0), "") - if v.agendaposter and not v.marseyawarded: body = torture_ap(body, v.username) + if v.agendaposter and not v.marseyawarded and sub != 'chudtopia': + body = torture_ap(body, v.username) body += process_files() @@ -1010,7 +1014,7 @@ def submit_post(v, sub=None): for x in notify_users: add_notif(cid, x) - if v.agendaposter and not v.marseyawarded and AGENDAPOSTER_PHRASE not in f'{post.body}{post.title}'.lower(): + if v.agendaposter and not v.marseyawarded and AGENDAPOSTER_PHRASE not in f'{post.body}{post.title}'.lower() and sub != 'chudtopia': post.is_banned = True post.ban_reason = "AutoJanny" diff --git a/files/templates/comments.html b/files/templates/comments.html index 4e6a57484e..deed25fcfc 100644 --- a/files/templates/comments.html +++ b/files/templates/comments.html @@ -300,7 +300,7 @@ {% endif %} -
+
{{c.realbody(v) | safe}}
{% if c.parent_submission %} diff --git a/files/templates/submission.html b/files/templates/submission.html index 74b1854365..daeb5b8918 100644 --- a/files/templates/submission.html +++ b/files/templates/submission.html @@ -705,14 +705,14 @@
{% endif %} {% if p.realurl(v) and not v_forbid_deleted %} -

+

{% if p.club %}{{CC}}{% endif %} {% if p.category %}{{help.submission_category_tag(p.category.name, p.category.color_text, p.category.color_bg)}}{% endif %} {% if p.flair %}{{p.flair | safe}}{% endif %} {{p.realtitle(v) | safe}}

{% else %} -

+

{% if p.club %}{{CC}}{% endif %} {% if p.category %}{{help.submission_category_tag(p.category.name, p.category.color_text, p.category.color_bg)}}{% endif %} {% if p.flair %}{{p.flair | safe}}{% endif %} @@ -748,7 +748,7 @@ {% endif %} -
+
{% if p.is_image %}