From 36a112a1dd623cbc318fe06e0f4ce69f45d11eff Mon Sep 17 00:00:00 2001 From: Lasse Studion Date: Sun, 18 Dec 2022 09:01:45 +0100 Subject: [PATCH] More config... --- config.py | 6 +++++- twitterbot.py | 5 +++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/config.py b/config.py index 84b8933..72eee5b 100644 --- a/config.py +++ b/config.py @@ -58,11 +58,15 @@ def update_config(key, value): return config -def get_config(): +def get_config(check_for=False): # Returns a config file, creating one if not existing. if os.path.exists("config.json"): with open("config.json") as f: config = json.load(f) + if check_for: + for i in check_for: + if i not in config: + config = create_config() else: config = create_config() return config diff --git a/twitterbot.py b/twitterbot.py index 6393b7c..71257e2 100644 --- a/twitterbot.py +++ b/twitterbot.py @@ -32,7 +32,7 @@ def start_bot(default=True): if __name__ == "__main__": - conf = config.get_config() + conf = config.get_config(check_for=['dropbox_refresh_token', 'twitter_access_token_secret']) if len(sys.argv) > 1: if sys.argv[1].lower() == 'start': @@ -53,7 +53,8 @@ if __name__ == "__main__": else: first_tweet_id = start_bot(default=False) else: - print('Exiting...') + print('\nExiting...\n') + exit() conf = config.get_config()