Skip to content

Commit

Permalink
Now only dumping to config if we have made a change to it
Browse files Browse the repository at this point in the history
  • Loading branch information
dev-fatal committed Feb 11, 2023
1 parent ae147d4 commit c205347
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down

0 comments on commit c205347

Please sign in to comment.