From 4251a9358fee769439ccca6fd4dee88bfab0e320 Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Tue, 11 Jan 2022 01:34:56 +0200 Subject: [PATCH] bbb --- Dockerfile | 12 +++++++----- files/helpers/const.py | 4 ++-- files/routes/comments.py | 8 ++++---- files/routes/posts.py | 34 ++++++++++++++++++++++++++++----- files/templates/submission.html | 1 - 5 files changed, 42 insertions(+), 17 deletions(-) diff --git a/Dockerfile b/Dockerfile index c5f2df4fc..c79d4b6b3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,13 +1,15 @@ FROM ubuntu:20.04 -RUN apt update && apt install -y python3.8 python3-pip +COPY supervisord.conf /etc/supervisord.conf -COPY requirements.txt /service/requirements.txt +RUN apt update && apt install -y python3.8 python3-pip supervisor -WORKDIR /service +RUN mkdir -p ./service -RUN pip3 install -r requirements.txt +COPY requirements.txt ./service/requirements.txt + +RUN cd ./service && pip3 install -r requirements.txt EXPOSE 80/tcp -CMD sudo -E gunicorn files.__main__:app -k gevent -w 2 --reload -b 0.0.0.0:80 --max-requests 1000 --max-requests-jitter 500 \ No newline at end of file +CMD [ "/usr/bin/supervisord", "-c", "/etc/supervisord.conf" ] \ No newline at end of file diff --git a/files/helpers/const.py b/files/helpers/const.py index 13af14f72..0f8c435a8 100644 --- a/files/helpers/const.py +++ b/files/helpers/const.py @@ -135,10 +135,10 @@ def torture_ap(body, username): LONGPOST_REPLIES = ['Wow, you must be a JP fan.', 'This is one of the worst posts I have EVER seen. Delete it.', "No, don't reply like this, please do another wall of unhinged rant please.", '# 😴😴😴', "Ma'am we've been over this before. You need to stop.", "I've known more coherent downies.", "Your pulitzer's in the mail", "That's great and all, but I asked for my burger without cheese.", 'That degree finally paying off', "That's nice sweaty. Why don't you have a seat in the time out corner with Pizzashill until you calm down, then you can have your Capri Sun.", "All them words won't bring your pa back.", "You had a chance to not be completely worthless, but it looks like you threw it away. At least you're consistent.", 'Some people are able to display their intelligence by going on at length on a subject and never actually saying anything. This ability is most common in trades such as politics, public relations, and law. You have impressed me by being able to best them all, while still coming off as an absolute idiot.', "You can type 10,000 characters and you decided that these were the one's that you wanted.", 'Have you owned the libs yet?', "I don't know what you said, because I've seen another human naked.", 'Impressive. Normally people with such severe developmental disabilities struggle to write much more than a sentence or two. He really has exceded our expectations for the writing portion. Sadly the coherency of his writing, along with his abilities in the social skills and reading portions, are far behind his peers with similar disabilities.', "This is a really long way of saying you don't fuck.", "Sorry ma'am, looks like his delusions have gotten worse. We'll have to admit him.", ':#marseywoah:', 'If only you could put that energy into your relationships', 'Posts like this is why I do Heroine.', 'still unemployed then?', 'K', 'look im gunna have 2 ask u 2 keep ur giant dumps in the toilet not in my replys 😷😷😷', "Mommy is soooo proud of you, sweaty. Let's put this sperg out up on the fridge with all your other failures.", "Good job bobby, here's a star", "That was a mistake. You're about to find out the hard way why.", 'You sat down and wrote all this shit. You could have done so many other things with your life. What happened to your life that made you decide writing novels of bullshit on rdrama.net was the best option?', "I don't have enough spoons to read this shit", "All those words won't bring daddy back.", 'OUT!'] -AGENDAPOSTER_MSG = """Hi @{username},\n\nYour comment has been automatically removed because you forgot +AGENDAPOSTER_MSG = """Hi @{username},\n\nYour {type} has been automatically removed because you forgot to include `trans lives matter`.\n\nDon't worry, we're here to help! We won't let you post or comment anything that doesn't express your love and acceptance towards - the trans community. Feel free to resubmit your comment with `trans lives matter` + the trans community. Feel free to resubmit your {type} with `trans lives matter` included. \n\n*This is an automated message; if you need help, you can message us [here](/contact).*""" diff --git a/files/routes/comments.py b/files/routes/comments.py index 4fa296af8..84032235f 100644 --- a/files/routes/comments.py +++ b/files/routes/comments.py @@ -342,7 +342,7 @@ def api_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 "trans lives matter" not in c.body_html.lower(): + if v.agendaposter and not v.marseyawarded and "trans lives matter" not in c.body.lower(): c.is_banned = True c.ban_reason = "AutoJanny" @@ -350,7 +350,7 @@ def api_comment(v): g.db.add(c) - body = AGENDAPOSTER_MSG.format(username=v.username) + body = AGENDAPOSTER_MSG.format(username=v.username, type='comment') body_md = CustomRenderer().render(mistletoe.Document(body)) @@ -683,7 +683,7 @@ def edit_comment(cid, v): c.body = body[:10000] c.body_html = body_html - if v.agendaposter and not v.marseyawarded and "trans lives matter" not in c.body_html.lower(): + if v.agendaposter and not v.marseyawarded and "trans lives matter" not in c.body.lower(): c.is_banned = True c.ban_reason = "AutoJanny" @@ -691,7 +691,7 @@ def edit_comment(cid, v): g.db.add(c) - body = AGENDAPOSTER_MSG.format(username=v.username) + body = AGENDAPOSTER_MSG.format(username=v.username, type='comment') body_md = CustomRenderer().render(mistletoe.Document(body)) diff --git a/files/routes/posts.py b/files/routes/posts.py index 6c80c68ee..e58dae045 100644 --- a/files/routes/posts.py +++ b/files/routes/posts.py @@ -19,6 +19,7 @@ from urllib.parse import ParseResult, urlunparse, urlparse, quote, unquote from os import path import requests from shutil import copyfile +from psutil import cpu_percent site = environ.get("DOMAIN").strip() site_name = environ.get("SITE_NAME").strip() @@ -493,14 +494,14 @@ def edit_post(pid, v): p.body_html = body_html - if v.agendaposter and not v.marseyawarded and "trans lives matter" not in body_html.lower(): + if v.agendaposter and not v.marseyawarded and "trans lives matter" not in f'{p.body}{p.title}'.lower(): p.is_banned = True p.ban_reason = "AutoJanny" g.db.add(p) - body = AGENDAPOSTER_MSG.format(username=v.username) + body = AGENDAPOSTER_MSG.format(username=v.username, type='post') body_md = CustomRenderer().render(mistletoe.Document(body)) @@ -549,6 +550,30 @@ def archiveorg(url): def thumbnail_thread(pid): + print(cpu_percent(), flush=True) + + time.sleep(0.1) + + cpu = cpu_percent() + + if cpu > 7: + with open('under_attack', 'r') as f: content = f.read() + + with open('under_attack', 'w') as f: + if content != "yes": + f.write("yes") + ma = ModAction( + kind="enable_under_attack", + user_id=AUTOJANNY_ID, + ) + g.db.add(ma) + g.db.commit() + data='{"value":"under_attack"}' + + response = str(requests.patch(f'https://api.cloudflare.com/client/v4/zones/{CF_ZONE}/settings/security_level', headers=CF_HEADERS, data=data)) + if response == "": return {"message": "Under attack mode enabled!"} + return {"error": "Failed to enable under attack mode."} + def expand_url(post_url, fragment_url): if fragment_url.startswith("https://"): @@ -1029,12 +1054,11 @@ def submit_post(v): if new_post.club and not user.paid_dues: continue add_notif(cid, user.id) - if v.agendaposter and not v.marseyawarded and "trans lives matter" not in new_post.body_html.lower(): - + if v.agendaposter and not v.marseyawarded and "trans lives matter" not in f'{new_post.body}{new_post.title}'.lower(): new_post.is_banned = True new_post.ban_reason = "AutoJanny" - body = AGENDAPOSTER_MSG.format(username=v.username) + body = AGENDAPOSTER_MSG.format(username=v.username, type='post') body_md = CustomRenderer().render(mistletoe.Document(body)) diff --git a/files/templates/submission.html b/files/templates/submission.html index 60c89b6b1..938dd595e 100644 --- a/files/templates/submission.html +++ b/files/templates/submission.html @@ -16,7 +16,6 @@ {% if p.award_count("wholesome") %}