From 16125b419b0c93226cdfb302837f6051acdadff2 Mon Sep 17 00:00:00 2001 From: TLSM Date: Sat, 9 Jul 2022 06:50:53 -0400 Subject: [PATCH] LGB: Disable Snappy Marseys; Snappy empty behavior. --- files/helpers/actions.py | 17 +++++++---------- files/helpers/const.py | 8 ++++++++ 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/files/helpers/actions.py b/files/helpers/actions.py index fc33347ba..f22c513ce 100644 --- a/files/helpers/actions.py +++ b/files/helpers/actions.py @@ -7,13 +7,6 @@ from files.helpers.sanitize import * import random from urllib.parse import quote -if SITE_NAME == 'PCM': snappyquotes = [] -else: snappyquotes = [f':#{x}:' for x in marseys_const2] - -if path.exists(f'snappy_{SITE_NAME}.txt'): - with open(f'snappy_{SITE_NAME}.txt', "r", encoding="utf-8") as f: - snappyquotes += f.read().split("\n{[para]}\n") - def badge_grant(user, badge_id, description=None, url=None): assert user != None if user.has_badge(badge_id): @@ -49,8 +42,10 @@ def execute_snappy(post, v): elif v.id == LAWLZ_ID: if random.random() < 0.5: body = "wow, this lawlzpost sucks!" else: body = "wow, a good lawlzpost for once!" + elif len(SNAPPY_QUOTES) == 0: + body = "" else: - body = random.choice(snappyquotes).strip() + body = random.choice(SNAPPY_QUOTES).strip() if body.startswith('▼'): body = body[1:] vote = Vote(user_id=SNAPPY_ID, @@ -122,9 +117,11 @@ def execute_snappy(post, v): gevent.spawn(archiveorg, href) body = body.strip() - body_html = sanitize(body) + if len(body_html) == 0: + return + if len(body_html) < 40000: c = Comment(author_id=SNAPPY_ID, distinguish_level=6, @@ -156,4 +153,4 @@ def execute_snappy(post, v): c.top_comment_id = c.id post.comment_count += 1 - post.replies = [c] \ No newline at end of file + post.replies = [c] diff --git a/files/helpers/const.py b/files/helpers/const.py index c266d42c0..dde5c245c 100644 --- a/files/helpers/const.py +++ b/files/helpers/const.py @@ -859,6 +859,14 @@ marseys_const = [x[0] for x in db.query(Marsey.name).filter(Marsey.name!='chudse marseys_const2 = marseys_const + ['chudsey','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','0','1','2','3','4','5','6','7','8','9','exclamationpoint','period','questionmark'] db.close() +SNAPPY_QUOTES = [] +if not SITE_NAME in ['PCM', 'LGBDropTheT']: + SNAPPY_QUOTES = [f':#{x}:' for x in marseys_const2] + +if path.exists(f'snappy_{SITE_NAME}.txt'): + with open(f'snappy_{SITE_NAME}.txt', "r", encoding="utf-8") as f: + SNAPPY_QUOTES += f.read().split("\n{[para]}\n") + YOUTUBE_KEY = environ.get("YOUTUBE_KEY", "").strip() ADMIGGERS = (37696,37697,37749,37833,37838,39413)