""" Configuration module for VNDB Telegram Bot Handles environment variables and settings """ import os from typing import Optional from dotenv import load_dotenv # Load environment variables from .env file load_dotenv() class Config: """Bot configuration class""" # Telegram configuration TELEGRAM_BOT_TOKEN: str = os.getenv("TELEGRAM_BOT_TOKEN", "") # VNDB API configuration VNDB_TOKEN: Optional[str] = os.getenv("VNDB_TOKEN") USE_SANDBOX: bool = os.getenv("USE_SANDBOX", "false").lower() == "true" # Logging configuration LOG_LEVEL: str = os.getenv("LOG_LEVEL", "INFO") # API limits MAX_RESULTS_PER_PAGE: int = 100 DEFAULT_RESULTS_PER_PAGE: int = 10 MAX_QUOTES_AT_ONCE: int = 5 # Timeouts (in seconds) API_TIMEOUT: int = 10 BOT_TIMEOUT: int = 30 @classmethod def validate(cls) -> bool: """Validate that required configuration is present""" if not cls.TELEGRAM_BOT_TOKEN: raise ValueError("TELEGRAM_BOT_TOKEN environment variable is required") return True @classmethod def to_dict(cls) -> dict: """Convert config to dictionary""" return { "TELEGRAM_BOT_TOKEN": "***" if cls.TELEGRAM_BOT_TOKEN else "NOT SET", "VNDB_TOKEN": "SET" if cls.VNDB_TOKEN else "NOT SET", "USE_SANDBOX": cls.USE_SANDBOX, "LOG_LEVEL": cls.LOG_LEVEL, "MAX_RESULTS_PER_PAGE": cls.MAX_RESULTS_PER_PAGE, "DEFAULT_RESULTS_PER_PAGE": cls.DEFAULT_RESULTS_PER_PAGE, "API_TIMEOUT": cls.API_TIMEOUT, }