From 4394021b66cf0cd261db0e6b663da60a657354e0 Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Wed, 1 Sep 2021 22:51:47 +0200 Subject: [PATCH] fdfd --- files/helpers/const.py | 11 +++++++ files/routes/comments.py | 70 +++++++++++++++++++++++++++++++++++++++- files/routes/posts.py | 40 ++++++++++++++++++++++- 3 files changed, 119 insertions(+), 2 deletions(-) diff --git a/files/helpers/const.py b/files/helpers/const.py index 64785ef44..3616428e2 100644 --- a/files/helpers/const.py +++ b/files/helpers/const.py @@ -44,6 +44,17 @@ AGENDAPOSTER_MSG = """Hi {username},\n\nYour comment has been automatically remo included. \n\n*This is an automated message; if you need help, you can message us [here](/contact).*""" +VAXX_MSG = """Hi {username}, it appears that you may be trying to spread dangerous misinformation regarding ineffective COVID-19 treatments based on pseudoscientific hearsay. Your post has been removed because it contained the word ivermectin. We ask that you understand that horse dewormer neither treats, nor prevents, COVID-19. For more information, please read up on what the FDA has to say on the matter: + +https://www.fda.gov/consumers/consumer-updates/why-you-should-not-use-ivermectin-treat-or-prevent-covid-19 + +COVID-19 is not a joke, it is a global pandemic and it has been hard on all of us. It will likely go down as one of the most defining periods of our generation. Many of us have lost loved ones to the virus. It has caused confusion, fear, frustration, and served to further divide us. Tens of millions around the world have died. There is nothing to be gained by spreading bad science based on very understandable fear. + +The only proven method of prevention is the COVID-19 vaccine, paired with appropriate social distancing, handwashing, and masks. Vaccines are free in the United States - if you'd like to locate your nearest vaccine provider, please visit https://www.vaccines.gov/ and schedule an appointment today. + +Thank you.""" + + NOTIFICATIONS_ACCOUNT = 1046 AUTOJANNY_ACCOUNT = 2360 diff --git a/files/routes/comments.py b/files/routes/comments.py index ca21742d3..58f289385 100644 --- a/files/routes/comments.py +++ b/files/routes/comments.py @@ -293,6 +293,40 @@ def api_comment(v): g.db.add(c_aux) g.db.flush() + if "ivermectin" in c_aux.body_html.lower(): + + c.is_banned = True + c.ban_reason = "ToS Violation" + + g.db.add(c) + + c_jannied = Comment(author_id=AUTOJANNY_ACCOUNT, + parent_submission=parent_submission, + distinguish_level=6, + parent_comment_id=c.id, + level=level+1, + is_bot=True, + ) + + g.db.add(c_jannied) + g.db.flush() + + body = VAXX_MSG.format(username=v.username) + + with CustomRenderer(post_id=parent_id) as renderer: + body_md = renderer.render(mistletoe.Document(body)) + + body_jannied_html = sanitize(body_md) + c_aux = CommentAux( + id=c_jannied.id, + body_html=body_jannied_html, + body=body + ) + g.db.add(c_aux) + g.db.flush() + n = Notification(comment_id=c_jannied.id, user_id=v.id) + g.db.add(n) + if v.agendaposter and "trans lives matter" not in c_aux.body_html.lower(): c.is_banned = True @@ -313,7 +347,6 @@ def api_comment(v): body = AGENDAPOSTER_MSG.format(username=v.username) - #body = body.replace("\n", "\n\n").replace("\n\n\n\n\n\n", "\n\n").replace("\n\n\n\n", "\n\n").replace("\n\n\n", "\n\n") with CustomRenderer(post_id=parent_id) as renderer: body_md = renderer.render(mistletoe.Document(body)) @@ -630,6 +663,41 @@ def edit_comment(cid, v): c.body = body[:10000] c.body_html = body_html[:20000] + if "ivermectin" in c.body_html.lower(): + + c.is_banned = True + c.ban_reason = "ToS Violation" + + g.db.add(c) + + c_jannied = Comment(author_id=AUTOJANNY_ACCOUNT, + parent_submission=c.parent_submission, + distinguish_level=6, + parent_comment_id=c.id, + level=c.level+1, + is_bot=True, + ) + + g.db.add(c_jannied) + g.db.flush() + + body = VAXX_MSG.format(username=v.username) + + with CustomRenderer(post_id=c.parent_submission) as renderer: + body_md = renderer.render(mistletoe.Document(body)) + + body_jannied_html = sanitize(body_md) + c_aux = CommentAux( + id=c_jannied.id, + body_html=body_jannied_html[:20000], + body=body[:10000] + ) + g.db.add(c_aux) + g.db.flush() + n = Notification(comment_id=c_jannied.id, user_id=v.id) + g.db.add(n) + + if v.agendaposter and "trans lives matter" not in c.body_html.lower(): c.is_banned = True diff --git a/files/routes/posts.py b/files/routes/posts.py index ce8751024..fcff4f75b 100644 --- a/files/routes/posts.py +++ b/files/routes/posts.py @@ -310,7 +310,7 @@ def edit_post(pid, v): g.db.add(c_jannied) g.db.flush() - body = AGENDAPOSTER_MSG.format(username=v.username) + body = VAXX_MSG.format(username=v.username) with CustomRenderer(post_id=p.id) as renderer: body_md = renderer.render(mistletoe.Document(body)) @@ -870,6 +870,44 @@ def submit_post(v): g.db.add(new_post) g.db.flush() + + if "ivermectin" in new_post_aux.body_html.lower(): + + new_post.is_banned = True + new_post.ban_reason = "ToS Violation" + + g.db.add(new_post) + + c_jannied = Comment(author_id=AUTOJANNY_ACCOUNT, + parent_submission=new_post.id, + level=1, + over_18=False, + is_bot=True, + app_id=None, + is_pinned=True, + distinguish_level=6 + ) + + g.db.add(c_jannied) + g.db.flush() + + body = VAXX_MSG.format(username=v.username) + + with CustomRenderer(post_id=new_post.id) as renderer: + body_md = renderer.render(mistletoe.Document(body)) + + body_jannied_html = sanitize(body_md) + c_aux = CommentAux( + id=c_jannied.id, + body_html=body_jannied_html, + body=body + ) + g.db.add(c_aux) + g.db.flush() + n = Notification(comment_id=c_jannied.id, user_id=v.id) + g.db.add(n) + + if v.agendaposter and "trans lives matter" not in new_post_aux.body_html.lower(): new_post.is_banned = True