diff options
| author | Igor Tolmachov <me@igorek.dev> | 2022-12-03 02:03:05 +0900 |
|---|---|---|
| committer | Igor Tolmachov <me@igorek.dev> | 2022-12-03 02:03:05 +0900 |
| commit | 70becfc32ec98084067686bd456971a4cb76082c (patch) | |
| tree | 87e426a5e5bfa789a750665707046e3ddc1a8c73 /shared/config.py | |
| parent | 7f9e3d0055b3f659f3b5337b1a69418cc1fae72f (diff) | |
| download | karpov_ai_bot-70becfc32ec98084067686bd456971a4cb76082c.tar.gz karpov_ai_bot-70becfc32ec98084067686bd456971a4cb76082c.zip | |
Beta 2.0
Diffstat (limited to 'shared/config.py')
| -rw-r--r-- | shared/config.py | 28 |
1 files changed, 0 insertions, 28 deletions
diff --git a/shared/config.py b/shared/config.py deleted file mode 100644 index 09ced45..0000000 --- a/shared/config.py +++ /dev/null | |||
| @@ -1,28 +0,0 @@ | |||
| 1 | import logging | ||
| 2 | from copy import deepcopy | ||
| 3 | from json import dump, load | ||
| 4 | from os import environ as env | ||
| 5 | from os import path | ||
| 6 | from typing import Any | ||
| 7 | |||
| 8 | logging.info("Load configs") | ||
| 9 | |||
| 10 | if not path.exists("data/settings.json"): | ||
| 11 | with open("data/settings.json", "w") as f: | ||
| 12 | f.write("{}") | ||
| 13 | fields: dict[str, Any] = { | ||
| 14 | "chances": {}, | ||
| 15 | } | ||
| 16 | |||
| 17 | settings: dict[str, Any] = load(open("data/settings.json", "r")) | ||
| 18 | for key, default in fields.items(): | ||
| 19 | settings[key] = settings.get(key, deepcopy(default)) | ||
| 20 | |||
| 21 | |||
| 22 | def save(): | ||
| 23 | dump(settings, open("data/settings.json", "w")) | ||
| 24 | |||
| 25 | |||
| 26 | # Configs | ||
| 27 | token = env["TOKEN"] | ||
| 28 | chances: dict[str, int] = settings["chances"] | ||
