From a98590ac0d3a37ef38129bc90b94154ab60d05f0 Mon Sep 17 00:00:00 2001 From: Chuck Sneed Date: Wed, 21 Jun 2023 21:23:07 -0500 Subject: [PATCH] Fix weird post bug, also reduce chance of phrases --- files/helpers/config/const.py | 1 + files/helpers/sanitize.py | 9 ++++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/files/helpers/config/const.py b/files/helpers/config/const.py index cccb320f9..e02f70983 100644 --- a/files/helpers/config/const.py +++ b/files/helpers/config/const.py @@ -101,6 +101,7 @@ AJ_REPLACEMENTS = { 'EVERYBODY': 'EVERYPONY', } +PHRASE_CHANCE = 0.5 GIRL_PHRASES = [ "ok so $", "um $", diff --git a/files/helpers/sanitize.py b/files/helpers/sanitize.py index 68d509754..84c590d7e 100644 --- a/files/helpers/sanitize.py +++ b/files/helpers/sanitize.py @@ -703,8 +703,11 @@ def torture_queen(string, key): string = more_than_one_comma_regex.sub(",", string) if string[-5:] == ', and': string = string[:-5] - girl_phrase = GIRL_PHRASES[key%len(GIRL_PHRASES)] - string = girl_phrase.replace("$", string) + + random.seed(key) + if random.random() < PHRASE_CHANCE: + girl_phrase = random.choice(GIRL_PHRASES) + string = girl_phrase.replace("$", string) string = initial + string return string @@ -716,7 +719,7 @@ def torture_object(obj, torture_method): i = 0 for tag in tags: i+=1 - key = obj.id*i + key = obj.id+i tag.string.replace_with(torture_method(tag.string, key)) obj.body_html = str(soup).replace('','').replace('','')