From 8947d1f6349f5bf4697c297b7976773d59a4957c Mon Sep 17 00:00:00 2001 From: Justin Date: Wed, 12 Jul 2023 17:08:20 +0800 Subject: [PATCH] save jokes added --- server.py | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/server.py b/server.py index d2ceebf..3fe1e11 100755 --- a/server.py +++ b/server.py @@ -661,6 +661,8 @@ def save(): save_ipo_settings(input_settings) elif feature == 'Economic Calendar': save_economic_settings(input_settings) + elif feature == 'Jokes': + save_jokes_settings(input_settings) elif 'Sports' in feature: save_sports_settings(input_settings) @@ -1335,6 +1337,43 @@ def save_economic_settings(input_settings): f.close() +def save_jokes_settings(input_settings): + filename = 'jokes_settings.json' + try: + f = open('csv/' + filename, 'r') + current_settings = json.load(f) + f.close() + except: + current_settings = {"feature": "Jokes", "speed": "medium", "speed2": "medium", "animation": "up", "title": True, "categories": ["Any"], "blacklist": [], "amount": "5", "jokes": []} + + current_settings['speed'] = input_settings['speed'].lower() + current_settings['speed2'] = input_settings['speed2'].lower() + current_settings['animation'] = input_settings['animation'].lower() + current_settings['title'] = input_settings['title'] + if input_settings['categories'] == '': + current_settings['categories'] = 'Any' + else: + current_settings['categories'] = input_settings['categories'] + current_settings['blacklist'] = input_settings['blacklist'] + current_settings['amount'] = input_settings['amount'] + + try: + f = open('csv/' + filename, 'w') + json.dump(current_settings, f) + f.close() + except: + with open('csv/jokes_settings.json', 'w') as f: + json.dump(current_settings, f) + + f = open('csv/last_updates.json', 'r') + last_updates = json.load(f) + f.close() + last_updates['jokes']['force'] = True + f = open('csv/last_updates.json', 'w') + json.dump(last_updates, f) + f.close() + + def save_sports_settings(input_settings): feature = input_settings['feature']