Stage 01 - bootstrap v2 stable start

This commit is contained in:
2026-04-13 20:47:04 +03:00
commit 551b4bd690
51 changed files with 1190 additions and 0 deletions

35
app/src/core/config.py Normal file
View File

@@ -0,0 +1,35 @@
from __future__ import annotations
import os
from dataclasses import dataclass
from pathlib import Path
from dotenv import load_dotenv
BASE_DIR = Path(__file__).resolve().parents[2]
ENV_FILE = BASE_DIR / ".env"
load_dotenv(ENV_FILE)
@dataclass(slots=True)
class Settings:
bot_token: str
bot_parse_mode: str
app_env: str
log_level: str
tz: str
def load_settings() -> Settings:
bot_token = os.getenv("BOT_TOKEN", "").strip()
if not bot_token:
raise RuntimeError("BOT_TOKEN is not set in app/.env")
return Settings(
bot_token=bot_token,
bot_parse_mode=os.getenv("BOT_PARSE_MODE", "HTML").strip() or "HTML",
app_env=os.getenv("APP_ENV", "dev").strip() or "dev",
log_level=os.getenv("LOG_LEVEL", "INFO").strip().upper() or "INFO",
tz=os.getenv("TZ", "Europe/Madrid").strip() or "Europe/Madrid",
)