Stage 01 - bootstrap v2 stable start
This commit is contained in:
1
app/src/core/__init__.py
Normal file
1
app/src/core/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
"""Package marker."""
|
||||
35
app/src/core/config.py
Normal file
35
app/src/core/config.py
Normal 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",
|
||||
)
|
||||
2
app/src/core/constants.py
Normal file
2
app/src/core/constants.py
Normal file
@@ -0,0 +1,2 @@
|
||||
APP_NAME = "Dzentra Bot"
|
||||
APP_VERSION = "2.0.0"
|
||||
2
app/src/core/exceptions.py
Normal file
2
app/src/core/exceptions.py
Normal file
@@ -0,0 +1,2 @@
|
||||
class AppError(Exception):
|
||||
"""Base application exception."""
|
||||
Reference in New Issue
Block a user