From 94f2a691673cd04facab6ad9204acb38939ea2f1 Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Tue, 1 Mar 2022 01:30:44 +0200 Subject: [PATCH] N --- files/classes/comment.py | 4 +++ files/classes/user.py | 3 +- files/helpers/alerts.py | 4 +++ files/helpers/const.py | 26 +++++---------- files/helpers/sanitize.py | 25 +++++++++++--- files/routes/awards.py | 14 -------- files/routes/comments.py | 56 +------------------------------ files/routes/posts.py | 64 ++++-------------------------------- files/templates/default.html | 2 +- schema.sql | 1 - 10 files changed, 48 insertions(+), 151 deletions(-) diff --git a/files/classes/comment.py b/files/classes/comment.py index 83eed8d07..939932a68 100644 --- a/files/classes/comment.py +++ b/files/classes/comment.py @@ -341,7 +341,11 @@ class Comment(Base): if v.nitter and not '/i/' in body: body = body.replace("www.twitter.com", "nitter.net").replace("twitter.com", "nitter.net") if v and v.controversial: + captured = [] for i in controversial_regex.finditer(body): + if i.group(0) in captured: continue + captured.append(i.group(0)) + url = i.group(1) p = urlparse(url).query p = parse_qs(p) diff --git a/files/classes/user.py b/files/classes/user.py index cb5980a05..2c41295af 100644 --- a/files/classes/user.py +++ b/files/classes/user.py @@ -128,7 +128,6 @@ class User(Base): ban_evade = Column(Integer, default=0) original_username = deferred(Column(String)) referred_by = Column(Integer, ForeignKey("users.id")) - nwordpass = Column(Boolean) subs_created = Column(Integer, default=0) badges = relationship("Badge", viewonly=True) @@ -474,7 +473,7 @@ class User(Base): if self.profileurl: if self.profileurl.startswith('/'): return SITE_FULL + self.profileurl return self.profileurl - if SITE_NAME == 'Drama': return f"{SITE_FULL}/static/assets/images/defaultpictures/bhm/{random.randint(1, 25)}.webp?v=1008" + if SITE_NAME == 'Drama': return f"{SITE_FULL}/static/assets/images/defaultpictures/{random.randint(1, 150)}.webp?v=1008" return f"{SITE_FULL}/static/assets/images/default-profile-pic.webp?v=1008" @lazy diff --git a/files/helpers/alerts.py b/files/helpers/alerts.py index ffe478f4b..c3ff52007 100644 --- a/files/helpers/alerts.py +++ b/files/helpers/alerts.py @@ -67,7 +67,11 @@ def NOTIFY_USERS(text, v): if id == 0: continue if word in text.lower() and id not in notify_users and v.id != id: notify_users.add(id) + captured = [] for i in mention_regex.finditer(text): + if i.group(0) in captured: continue + captured.append(i.group(0)) + user = get_user(i.group(2), graceful=True) if user and not v.any_block_exists(user): notify_users.add(user.id) diff --git a/files/helpers/const.py b/files/helpers/const.py index dd0b284ed..2266bfa41 100644 --- a/files/helpers/const.py +++ b/files/helpers/const.py @@ -110,14 +110,9 @@ single_words = "|".join([slur.lower() for slur in SLURS.keys()]) 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.", f'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 {SITE} was the best option?', "I don't have enough spoons to read this shit", "All those words won't bring daddy back.", 'OUT!', "Damn, you're really mad over this, but thanks for the effort you put into typing that all out! Sadly I won't read it all.", "Jesse what the fuck are you talking about??", "▼you're fucking bananas if you think I'm reading all that, take my downvote and shut up idiot") -AGENDAPOSTER_PHRASE = 'black lives matter' +AGENDAPOSTER_PHRASE = 'trans lives matter' -AGENDAPOSTER_MSG = """Hi @{username},\n\nYour {type} has been automatically removed because you forgot - to include `{AGENDAPOSTER_PHRASE}`.\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 black community. Feel free to resubmit your {type} with `{AGENDAPOSTER_PHRASE}` - included. \n\n*This is an automated message; if you need help, - you can message us [here](/contact).*""" +AGENDAPOSTER_MSG = """Hi @{username},\n\nYour {type} has been automatically removed because you forgot to include `{AGENDAPOSTER_PHRASE}`.\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 {type} with `{AGENDAPOSTER_PHRASE}` included. \n\n*This is an automated message; if you need help, you can message us [here](/contact).*""" if SITE in {'rdrama.net','devrama.xyz'}: NOTIFICATIONS_ID = 1046 @@ -497,14 +492,6 @@ AWARDS = { "color": "text-lightgreen", "price": 10000 }, - "nword": { - "kind": "nword", - "title": "Nword Pass", - "description": "Gives the recipient the ability to speak that which must not be spoken", - "icon": "fas fa-edit", - "color": "text-success", - "price": 10000 - }, "fish": { "kind": "fish", "title": "Fish", @@ -601,8 +588,6 @@ NOTIFIED_USERS = { FORTUNE_REPLIES = ('Your fortune: Allah Wills It','Your fortune: Inshallah, Only Good Things Shall Come To Pass','Your fortune: Allah Smiles At You This Day','Your fortune: Your Bussy Is In For A Blasting','Your fortune: You Will Be Propositioned By A High-Tier Twink','Your fortune: Repent, You Have Displeased Allah And His Vengeance Is Nigh','Your fortune: Reply Hazy, Try Again','Your fortune: lmao you just lost 100 coins','Your fortune: Yikes 😬','Your fortune: You Will Be Blessed With Many Black Bulls','Your fortune: NEETmax, The Day Is Lost If You Venture Outside','Your fortune: A Taste Of Jannah Awaits You Today','Your fortune: Watch Your Back','Your fortune: Outlook good','Your fortune: Godly Luck','Your fortune: Good Luck','Your fortune: Bad Luck','Your fortune: Good news will come to you by mail','Your fortune: Very Bad Luck','Your fortune: キタ━━━━━━(゚∀゚)━━━━━━ !!!!','Your fortune: Better not tell you now','Your fortune: You will meet a dark handsome stranger','Your fortune: ( ´_ゝ`)フーン','Your fortune: Excellent Luck','Your fortune: Average Luck') -no_pass_phrase = """

Sorry whiteboy, we're gonna need to see some ID before you start throwin that word around like it's nothing.\n\nTake a 10 minute time-out and come back when you've learned your lesson and/or paid reparations (by purchasing a BIPOC Approved™ rDrama NWord Pass© from the shop) \n\nThis is an automated message; if you need help, you can message us here.

""" - ROLES={ "owner": "864612849199480914", "admin": "879459632656048180" if environ.get("DOMAIN") == "pcmemes.net" else "846509661288267776", @@ -690,6 +675,13 @@ sub_regex = re.compile('(^|\s|

)\/?(s\/(\w|-){3,25})', flags=re.A) youtube_regex = re.compile('" target="_blank">(https://youtube\.com/watch\?v\=(.*?))(?!)', flags=re.A) strikethrough_regex = re.compile('~~(.*?)~~', flags=re.A) +emoji_regex = re.compile("[^a]>\s*(:[!#]{0,2}\w+:\s*)+<\/", flags=re.A) +emoji_regex2 = re.compile('(?(.*?)<\/a>', flags=re.A) + slur_regex = re.compile(rf"((?<=\s|>)|^)({single_words})((?=[\s<,.$]|s[\s<,.$]))", flags=re.I|re.A) slur_regex_upper = re.compile(rf"((?<=\s|>)|^)({single_words.upper()})((?=[\s<,.$]|S[\s<,.$]))", flags=re.A) torture_regex = re.compile('(^|\s)(i|me) ', flags=re.I|re.A) diff --git a/files/helpers/sanitize.py b/files/helpers/sanitize.py index 39540fea6..6406aff1e 100644 --- a/files/helpers/sanitize.py +++ b/files/helpers/sanitize.py @@ -116,7 +116,11 @@ def sanitize(sanitized, noimages=False, alert=False, comment=False, edit=False): sanitized = sanitized.replace("\ufeff", "").replace("𒐪","").replace("","").replace('‎','') if alert: + captured = [] for i in mention_regex2.finditer(sanitized): + if i.group(0) in captured: continue + captured.append(i.group(0)) + u = get_user(i.group(1), graceful=True) if u: sanitized = sanitized.replace(i.group(0), f'''

@{u.username}''', 1) @@ -125,7 +129,11 @@ def sanitize(sanitized, noimages=False, alert=False, comment=False, edit=False): sanitized = sub_regex.sub(r'\1/\2', sanitized) + captured = [] for i in mention_regex.finditer(sanitized): + if i.group(0) in captured: continue + captured.append(i.group(0)) + u = get_user(i.group(2), graceful=True) if u and (not g.v.any_block_exists(u) or g.v.admin_level > 1): @@ -186,7 +194,7 @@ def sanitize(sanitized, noimages=False, alert=False, comment=False, edit=False): if comment: marseys_used = set() - emojis = list(re.finditer("[^a]>\s*(:[!#]{0,2}\w+:\s*)+<\/", sanitized, flags=re.A)) + emojis = list(emoji_regex.finditer(sanitized)) if len(emojis) > 20: edit = True captured = [] @@ -197,7 +205,12 @@ def sanitize(sanitized, noimages=False, alert=False, comment=False, edit=False): old = i.group(0) if 'marseylong1' in old or 'marseylong2' in old or 'marseyllama1' in old or 'marseyllama2' in old: new = old.lower().replace(">", " class='mb-0'>") else: new = old.lower() - for i in re.finditer('(? 20: edit = True captured = [] @@ -259,7 +272,11 @@ def sanitize(sanitized, noimages=False, alert=False, comment=False, edit=False): if "https://youtube.com/watch?v=" in sanitized: sanitized = sanitized.replace("?t=", "&t=") + captured = [] for i in youtube_regex.finditer(sanitized): + if i.group(0) in captured: continue + captured.append(i.group(0)) + url = i.group(1) yt_id = i.group(2).split('&')[0].split('%')[0] replacing = f'{url}' @@ -307,7 +324,7 @@ def filter_emojis_only(title, edit=False, graceful=False): title = bleach.clean(title, tags=[]) - emojis = list(re.finditer('(? 20: edit = True captured = [] diff --git a/files/routes/awards.py b/files/routes/awards.py index 2175e1f13..bda8b1e50 100644 --- a/files/routes/awards.py +++ b/files/routes/awards.py @@ -398,13 +398,6 @@ def award_post(pid, v): for c in post.comments: c.ghost = True g.db.add(c) - elif kind == "nword": - author.nwordpass = True - if not author.has_badge(108): - new_badge = Badge(badge_id=108, user_id=author.id) - g.db.add(new_badge) - g.db.flush() - send_notification(author.id, f"@AutoJanny has given you the following profile badge:\n\n![]({new_badge.path})\n\n{new_badge.name}") elif kind == "rehab": if author.rehab: author.rehab += 86400 else: author.rehab = int(time.time()) + 86400 @@ -625,13 +618,6 @@ def award_comment(cid, v): elif kind == "ghost": c.ghost = True g.db.add(c) - elif kind == "nword": - author.nwordpass = True - if not author.has_badge(108): - new_badge = Badge(badge_id=108, user_id=author.id) - g.db.add(new_badge) - g.db.flush() - send_notification(author.id, f"@AutoJanny has given you the following profile badge:\n\n![]({new_badge.path})\n\n{new_badge.name}") elif kind == "rehab": if author.rehab: author.rehab += 86400 else: author.rehab = int(time.time()) + 86400 diff --git a/files/routes/comments.py b/files/routes/comments.py index f6fe47488..1912f584f 100644 --- a/files/routes/comments.py +++ b/files/routes/comments.py @@ -243,7 +243,7 @@ def api_comment(v): copyfile(oldname, filename) process_image(filename, 400) elif parent_post.id == 37697: - filename = 'files/assets/images/Drama/banners_bhm/' + str(len(listdir('files/assets/images/Drama/banners_bhm'))+1) + '.webp' + filename = 'files/assets/images/Drama/banners/' + str(len(listdir('files/assets/images/Drama/banners'))+1) + '.webp' copyfile(oldname, filename) process_image(filename) elif parent_post.id == 37833: @@ -480,35 +480,8 @@ def api_comment(v): n = Notification(comment_id=c_jannied.id, user_id=v.id) g.db.add(n) - - elif SITE_NAME == 'Drama' and 'nigg' in c.body.lower() and not v.nwordpass: - c.is_banned = True - c.ban_reason = "AutoJanny" - g.db.add(c) - c_jannied = Comment(author_id=NOTIFICATIONS_ID, - parent_submission=parent_submission, - distinguish_level=6, - parent_comment_id=c.id, - level=level+1, - is_bot=True, - body_html=no_pass_phrase, - top_comment_id=c.top_comment_id, - ghost=parent_post.ghost - ) - - g.db.add(c_jannied) - g.db.flush() - - v.ban(reason="White people nonsense.", days=0.007) - - text = "Your account has been banned for **10 minutes** for the following reason:\n\n> Unsanctioned NWord" - send_repeatable_notification(v.id, text) - - n = Notification(comment_id=c_jannied.id, user_id=v.id) - g.db.add(n) - if SITE_NAME == 'Drama' and len(c.body) >= 1000 and "<" not in body and "" not in body_html: body = random.choice(LONGPOST_REPLIES) @@ -859,33 +832,6 @@ def edit_comment(cid, v): n = Notification(comment_id=c_jannied.id, user_id=v.id) g.db.add(n) - elif SITE_NAME == 'Drama' and 'nigg' in c.body.lower() and not v.nwordpass: - - c.is_banned = True - c.ban_reason = "AutoJanny" - g.db.add(c) - - c_jannied = Comment(author_id=NOTIFICATIONS_ID, - parent_submission=c.parent_submission, - distinguish_level=6, - parent_comment_id=c.id, - level=c.level+1, - is_bot=True, - body_html=no_pass_phrase, - top_comment_id=c.top_comment_id, - ghost=c.ghost - ) - - g.db.add(c_jannied) - g.db.flush() - - v.ban(reason="White people nonsense.", days=0.007) - - text = "Your account has been banned for **10 minutes** for the following reason:\n\n> Unsanctioned NWord" - send_repeatable_notification(v.id, text) - - n = Notification(comment_id=c_jannied.id, user_id=v.id) - g.db.add(n) if int(time.time()) - c.created_utc > 60 * 3: c.edited_utc = int(time.time()) diff --git a/files/routes/posts.py b/files/routes/posts.py index f30414569..8418ef98a 100644 --- a/files/routes/posts.py +++ b/files/routes/posts.py @@ -570,34 +570,6 @@ def edit_post(pid, v): n = Notification(comment_id=c_jannied.id, user_id=v.id) g.db.add(n) - elif SITE_NAME == 'Drama' and 'nigg' in f'{p.body}{p.title}'.lower() and not v.nwordpass: - - p.is_banned = True - p.ban_reason = "AutoJanny" - g.db.add(p) - - c_jannied = Comment(author_id=NOTIFICATIONS_ID, - parent_submission=p.id, - level=1, - over_18=False, - is_bot=True, - app_id=None, - is_pinned='AutoJanny', - distinguish_level=6, - body_html=no_pass_phrase, - ghost=p.ghost - ) - - g.db.add(c_jannied) - g.db.flush() - - v.ban(reason="White people nonsense.", days=0.007) - - text = "Your account has been banned for **10 minutes** for the following reason:\n\n> Unsanctioned NWord" - send_repeatable_notification(v.id, text) - - n = Notification(comment_id=c_jannied.id, user_id=v.id) - g.db.add(n) if not p.private and not p.ghost: @@ -1248,32 +1220,7 @@ def submit_post(v, sub=None): n = Notification(comment_id=c_jannied.id, user_id=v.id) g.db.add(n) - elif SITE_NAME == 'Drama' and 'nigg' in f'{post.body}{post.title}'.lower() and not v.nwordpass: - post.is_banned = True - post.ban_reason = "AutoJanny" - - c_jannied = Comment(author_id=NOTIFICATIONS_ID, - parent_submission=post.id, - level=1, - over_18=False, - is_bot=True, - app_id=None, - is_pinned='AutoJanny', - distinguish_level=6, - body_html=no_pass_phrase, - ) - - g.db.add(c_jannied) - g.db.flush() - - v.ban(reason="White people nonsense.", days=0.007) - - text = "Your account has been banned for **10 minutes** for the following reason:\n\n> Unsanctioned NWord" - send_repeatable_notification(v.id, text) - - n = Notification(comment_id=c_jannied.id, user_id=v.id) - g.db.add(n) if not (post.sub and g.db.query(Exile.user_id).filter_by(user_id=SNAPPY_ID, sub=post.sub).one_or_none()): if post.sub == 'dankchristianmemes': @@ -1321,12 +1268,15 @@ def submit_post(v, sub=None): body += f"Snapshots:\n\n{rev}* [archive.org](https://web.archive.org/{newposturl})\n* [archive.ph](https://archive.ph/?url={quote(newposturl)}&run=1) (click to archive)\n\n" gevent.spawn(archiveorg, newposturl) - url_regex = '(.*?)<\/a>' - for url_match in list(re.finditer(url_regex, post.body_html, flags=re.A))[:20]: - href = url_match.group(1) + captured = [] + for i in list(snappy_url_regex.finditer(post.body_html))[:20]: + if i.group(0) in captured: continue + captured.append(i.group(0)) + + href = i.group(1) if not href: continue - title = url_match.group(2) + title = i.group(2) if "Snapshots:\n\n" not in body: body += "Snapshots:\n\n" if f'**[{title}]({href})**:\n\n' not in body: diff --git a/files/templates/default.html b/files/templates/default.html index 98ac99d03..e01aee1af 100644 --- a/files/templates/default.html +++ b/files/templates/default.html @@ -231,7 +231,7 @@ {% if sub %} /s/{{sub.name}} banner {% elif SITE_NAME == 'Drama' %} - {% set path = "assets/images/" + SITE_NAME + "/banners_bhm" %} + {% set path = "assets/images/" + SITE_NAME + "/banners" %} {% set image = "/static/" + path + "/" + listdir('files/' + path)|random() + '?v=21' %} diff --git a/schema.sql b/schema.sql index d73d9a1d5..6071be498 100644 --- a/schema.sql +++ b/schema.sql @@ -618,7 +618,6 @@ CREATE TABLE public.users ( winnings integer DEFAULT 0 NOT NULL, patron_utc integer DEFAULT 0 NOT NULL, rehab integer, - nwordpass boolean, house character varying(16), subs_created integer DEFAULT 0 NOT NULL );