Add storage, syncing db, rename module

This commit is contained in:
BarsTiger
2023-10-08 21:21:15 +03:00
parent 42d7f7d235
commit 0135294fcb
25 changed files with 281 additions and 2 deletions

0
bot/utils/__init__.py Normal file
View File

View File

@@ -0,0 +1,4 @@
from ._config import Config
config = Config()

View File

@@ -0,0 +1,22 @@
import tomllib
class Config(dict):
def __init__(self, _config: dict = None):
try:
if _config is None:
config = tomllib.load(open('config.toml', 'rb'))
super().__init__(**config)
else:
super().__init__(**_config)
except FileNotFoundError:
super().__init__()
def __getattr__(self, item):
return (
self.get(item)
if type(self.get(item)) is not dict
else Config(self.get(item))
)