From 9176a7746a0a8728c20837d069317e77888b2fa4 Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Mon, 15 Aug 2022 07:10:15 +0200 Subject: [PATCH] make the chance of snappy marseys and snappy quotes even instead of being dependant on the number of each --- files/helpers/actions.py | 10 ++++++++-- files/helpers/const.py | 13 +++++-------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/files/helpers/actions.py b/files/helpers/actions.py index 25a06b50c..46a837c77 100644 --- a/files/helpers/actions.py +++ b/files/helpers/actions.py @@ -43,10 +43,16 @@ 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: + elif not SNAPPY_MARSEYS and not SNAPPY_QUOTES: body = "" else: - body = random.choice(SNAPPY_QUOTES).strip() + if SNAPPY_MARSEYS and SNAPPY_QUOTES: + if random.random() < 0.5: SNAPPY_CHOICES = SNAPPY_MARSEYS + else: SNAPPY_CHOICES = SNAPPY_QUOTES + elif SNAPPY_MARSEYS: SNAPPY_CHOICES = SNAPPY_MARSEYS + elif SNAPPY_QUOTES: SNAPPY_CHOICES = SNAPPY_QUOTES + + body = random.choice(SNAPPY_CHOICES).strip() if body.startswith('▼'): body = body[1:] vote = Vote(user_id=SNAPPY_ID, diff --git a/files/helpers/const.py b/files/helpers/const.py index 96896a396..71fc49548 100644 --- a/files/helpers/const.py +++ b/files/helpers/const.py @@ -917,15 +917,12 @@ 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 SITE_NAME not in ('PCM', 'LGBDropTheT'): + SNAPPY_MARSEYS = [f':#{x}:' for x in marseys_const2] -snappy_name = SITE_NAME - -if path.isfile(f'snappy_{snappy_name}.txt'): - with open(f'snappy_{snappy_name}.txt', "r", encoding="utf-8") as f: - SNAPPY_QUOTES += f.read().split("\n{[para]}\n") +if path.isfile(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()