From c20534786e502d9723e3b4b91e9897dd9ce83ce8 Mon Sep 17 00:00:00 2001 From: dev-fatal Date: Sat, 11 Feb 2023 17:04:31 +0000 Subject: [PATCH] Now only dumping to config if we have made a change to it --- main.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/main.py b/main.py index 00136dd..9cb687c 100644 --- a/main.py +++ b/main.py @@ -11,14 +11,19 @@ def load_config(): if not config["token"]: # No token supplied sys.exit("Please enter a token in the config file") + + updated_config = False while not config["chat_id"]: # Keep trying to find chat id until we get a valid one + updated_config = True input("Please send a message to the Telegram bot you created. Once done, wait 1 \ minute then press Enter. If it doesn't work, send another message then try \ again.") config["chat_id"] = get_chat_id(config["token"]) - with open(config_location, "w") as file: - toml.dump(config, file) # Output new config (to file) with updated chat id + if updated_config: + with open(config_location, "w") as file: + toml.dump(config, file) # Output new config (to file) with updated chat id + return config