import os from functools import cached_property from pydantic_settings import BaseSettings from pydantic import computed_field class Settings(BaseSettings): """ Settings class that defines configuration variables for the application. Attributes: ---------- app_env : str Specifies the environment in which the application is running. Default is 'DEV'. Possible values could include 'DEV', 'PROD' workers : int Defines the number of workers to be used in the application. Default is 1. api_id : int Represents the API ID from my.telegram.org api_hash : str The hash key corresponding to your API Hash from my.telegram.org bot_token : str The token from BotFather. storage : os.path Specifies the path where the application stores persistent data. allowed_ids : str A list or comma-separated string of IDs that are allowed access to the bot or application. log_level : str The log level used for logging module. Config: ------- env_file : str Specifies the environment file to load the environment variables from. Default is ".env". """ app_env: str = "DEV" workers: int = 1 api_id: int api_hash: str bot_token: str storage: str allowed_ids: str log_level: str @computed_field @property def tt_hash_file(self) -> str: return os.path.join(settings.storage, "tt_hashes.pickle") @computed_field @cached_property def allowed_ids_list(self) -> list: allowed_ids = settings.allowed_ids.split(",") allowed_ids = [int(x) for x in allowed_ids] return allowed_ids class Config: env_file = ".env" settings = Settings()