From e5adaf85269a3b1e7701580036f2b9ec3dfd1598 Mon Sep 17 00:00:00 2001 From: whymequestion Date: Thu, 12 Mar 2026 00:12:07 +0500 Subject: [PATCH] =?UTF-8?q?refactor:=20=D1=83=D0=B1=D1=80=D0=B0=D0=BB=20?= =?UTF-8?q?=D0=BB=D0=B8=D1=88=D0=BD=D0=B8=D0=B5=20=D0=B8=D0=BC=D0=BF=D0=BE?= =?UTF-8?q?=D1=80=D1=82=D1=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- requirements.txt | 2 -- src/common/config.py | 20 ++++++++++++++++++-- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/requirements.txt b/requirements.txt index 8b73f40..be21ad7 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,9 +1,7 @@ pyTelegramBotAPI aiomysql -python-dotenv msgpack lz4 websockets pydantic -aiohttp aiosqlite \ No newline at end of file diff --git a/src/common/config.py b/src/common/config.py index dc4c7ed..f05bab4 100644 --- a/src/common/config.py +++ b/src/common/config.py @@ -1,6 +1,22 @@ import os -from dotenv import load_dotenv -load_dotenv() +from pathlib import Path + +def _load_dotenv(): + env_path = Path(".env") + if not env_path.is_file(): + return + with open(env_path, encoding="utf-8") as f: + for line in f: + line = line.strip() + if not line or line.startswith("#") or "=" not in line: + continue + key, _, value = line.partition("=") + key = key.strip() + value = value.strip().strip("\"'") + if key and key not in os.environ: + os.environ[key] = value + +_load_dotenv() class ServerConfig: def __init__(self):