diff options
Diffstat (limited to 'shared')
| -rw-r--r-- | shared/config.py | 21 | ||||
| -rw-r--r-- | shared/instances.py | 1 |
2 files changed, 21 insertions, 1 deletions
diff --git a/shared/config.py b/shared/config.py index 6b973d3..d04a510 100644 --- a/shared/config.py +++ b/shared/config.py | |||
| @@ -1,3 +1,24 @@ | |||
| 1 | from copy import deepcopy | ||
| 2 | from json import dump, load | ||
| 1 | from os import environ as env | 3 | from os import environ as env |
| 4 | from os import path | ||
| 5 | from typing import Any | ||
| 2 | 6 | ||
| 7 | if path.exists("data/settings.json"): | ||
| 8 | open("data/settings.json", "w").close() | ||
| 9 | fields: dict[str, Any] = { | ||
| 10 | "chances": {}, | ||
| 11 | } | ||
| 12 | |||
| 13 | settings: dict[str, Any] = load(open("data/settings.json", "r")) | ||
| 14 | for key, default in fields.items(): | ||
| 15 | settings[key] = settings.get(key, deepcopy(default)) | ||
| 16 | |||
| 17 | |||
| 18 | def save(): | ||
| 19 | dump(settings, open("data/settings.json", "w")) | ||
| 20 | |||
| 21 | |||
| 22 | # Configs | ||
| 3 | token = env["TOKEN"] | 23 | token = env["TOKEN"] |
| 24 | chances = settings["chances"] | ||
diff --git a/shared/instances.py b/shared/instances.py index 3ffec5e..9ca0b2c 100644 --- a/shared/instances.py +++ b/shared/instances.py | |||
| @@ -4,4 +4,3 @@ from shared.config import token | |||
| 4 | 4 | ||
| 5 | bot = Bot(token=token) | 5 | bot = Bot(token=token) |
| 6 | dp = Dispatcher(bot) | 6 | dp = Dispatcher(bot) |
| 7 | gen_chance: dict[int, int] = {} | ||
