forked from dev-fatal/queue-notify
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
36 lines (26 loc) · 1.02 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
from message import get_chat_id
from monitor import monitor
import toml
import sys
def load_config():
config_location = "config.toml"
with open(config_location) as file:
config = toml.load(file) # Make a dict of the config values
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"])
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
def main():
config = load_config()
monitor(config)
if __name__ == "__main__":
main()