From 973ce26b7ad6d24b90d773b26b508157d60f56d5 Mon Sep 17 00:00:00 2001 From: Aevann Date: Tue, 2 May 2023 16:49:28 +0300 Subject: [PATCH] better DKD snappy system --- files/helpers/actions.py | 15 +++++++++------ files/helpers/const_stateful.py | 16 +++++++--------- 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/files/helpers/actions.py b/files/helpers/actions.py index 5954742a6..4bbb9a8e5 100644 --- a/files/helpers/actions.py +++ b/files/helpers/actions.py @@ -75,15 +75,18 @@ def execute_snappy(post:Submission, v:User): else: body = "wow, a good lawlzpost for once!" else: if IS_DKD(): - SNAPPY_CHOICES = SNAPPY_EMOJIS - elif SNAPPY_EMOJIS and SNAPPY_QUOTES: + SNAPPY_CHOICES = SNAPPY_KONGS + elif SNAPPY_MARSEYS and SNAPPY_QUOTES: if IS_FISTMAS() or random.random() > 0.5: SNAPPY_CHOICES = SNAPPY_QUOTES else: - SNAPPY_CHOICES = SNAPPY_EMOJIS - elif SNAPPY_EMOJIS: SNAPPY_CHOICES = SNAPPY_EMOJIS - elif SNAPPY_QUOTES: SNAPPY_CHOICES = SNAPPY_QUOTES - else: SNAPPY_CHOICES = [""] + SNAPPY_CHOICES = SNAPPY_MARSEYS + elif SNAPPY_MARSEYS: + SNAPPY_CHOICES = SNAPPY_MARSEYS + elif SNAPPY_QUOTES: + SNAPPY_CHOICES = SNAPPY_QUOTES + else: + SNAPPY_CHOICES = [""] body = random.choice(SNAPPY_CHOICES).strip() if body.startswith('▼') or body.startswith(':#marseydownvote'): diff --git a/files/helpers/const_stateful.py b/files/helpers/const_stateful.py index d5aa47bb4..5f5dae5cc 100644 --- a/files/helpers/const_stateful.py +++ b/files/helpers/const_stateful.py @@ -5,11 +5,11 @@ from sqlalchemy.orm import scoped_session from files.classes import Emoji from files.helpers.config.const import * -dk_const = [] +SNAPPY_KONGS = [] marseys_const = [] marseys_const2 = [] marsey_mappings = {} -SNAPPY_EMOJIS = [] +SNAPPY_MARSEYS = [] SNAPPY_QUOTES = [] def const_initialize(db:scoped_session): @@ -17,7 +17,7 @@ def const_initialize(db:scoped_session): _initialize_snappy_marseys_and_quotes() def _initialize_marseys(db:scoped_session): - global marseys_const, marseys_const2, marsey_mappings, dk_const + global marseys_const, marseys_const2, marsey_mappings, SNAPPY_KONGS marseys_const = [x[0] for x in db.query(Emoji.name).filter(Emoji.kind=="Marsey", Emoji.submitter_id==None, Emoji.name!='chudsey').all()] 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'] marseys = db.query(Emoji).filter(Emoji.kind=="Marsey", Emoji.submitter_id==None).all() @@ -29,16 +29,14 @@ def _initialize_marseys(db:scoped_session): marsey_mappings[tag] = [marsey.name] if IS_DKD(): - dk_const = [x[0] for x in db.query(Emoji.name).filter(Emoji.kind=="Donkey Kong", Emoji.submitter_id==None).all()] + SNAPPY_KONGS = db.query(Emoji.name).filter(Emoji.kind=="Donkey Kong", Emoji.submitter_id==None).all() + SNAPPY_KONGS = [f':#{x[0]}:' for x in SNAPPY_KONGS] def _initialize_snappy_marseys_and_quotes(): - global SNAPPY_EMOJIS, SNAPPY_QUOTES + global SNAPPY_MARSEYS, SNAPPY_QUOTES - if IS_DKD(): - SNAPPY_EMOJIS = [f':#{x}:' for x in dk_const] - else: - SNAPPY_EMOJIS = [f':#{x}:' for x in marseys_const2] + SNAPPY_MARSEYS = [f':#{x}:' for x in marseys_const2] if IS_FISTMAS(): filename = f"snappy_fistmas_{SITE_NAME}.txt"