from __future__ import annotations import os from dataclasses import dataclass from pathlib import Path @dataclass(frozen=True, slots=True) class Settings: telegram_token: str base_app_url: str data_dir: Path @property def database_path(self) -> Path: return self.data_dir / "pozhitki.sqlite3" @property def avatars_dir(self) -> Path: return self.data_dir / "avatars" @property def webapp_url(self) -> str: return f"{self.base_app_url.rstrip('/')}/app/" def load_settings() -> Settings: return Settings( telegram_token=os.getenv("TELEGRAM_TOKEN", "").strip(), base_app_url=os.getenv("BASE_APP_URL", "http://localhost").strip(), data_dir=Path(os.getenv("DATA_DIR", "/data")), )