ир
Some checks failed
CI / Lint (ruff + mypy) (push) Failing after 33s
CI / Run tests (push) Has been skipped
CI / Docker build test (push) Successful in 12s
Security / Dependency security scan (push) Failing after 48s

This commit is contained in:
2026-04-03 01:03:52 +07:00
parent 94afa86920
commit a13f4e378c
7 changed files with 308 additions and 78 deletions

View File

@@ -18,6 +18,14 @@ class BotSettings:
admin_ids: set[int]
hidden_link_url: str
hidden_link_char: str
telethon_api_id: int | None
telethon_api_hash: str
telethon_session_string: str
telethon_channel: str
@property
def telethon_enabled(self) -> bool:
return bool(self.telethon_api_id and self.telethon_api_hash and self.telethon_session_string)
def _parse_admin_ids(value: str) -> set[int]:
@@ -32,6 +40,8 @@ def _parse_admin_ids(value: str) -> set[int]:
def load_settings() -> BotSettings:
load_dotenv()
telethon_api_id = os.environ.get("TELETHON_API_ID", "").strip()
return BotSettings(
bot_token=os.environ["BOT_TOKEN"],
channel_id=int(os.environ["CHANNEL_ID"]),
@@ -41,6 +51,10 @@ def load_settings() -> BotSettings:
admin_ids=_parse_admin_ids(os.environ.get("ADMIN_IDS", "")),
hidden_link_url=os.environ.get("HIDDEN_LINK_URL", ""),
hidden_link_char=os.environ.get("HIDDEN_LINK_CHAR", "​"),
telethon_api_id=int(telethon_api_id) if telethon_api_id else None,
telethon_api_hash=os.environ.get("TELETHON_API_HASH", "").strip(),
telethon_session_string=os.environ.get("TELETHON_SESSION_STRING", "").strip(),
telethon_channel=os.environ.get("TELETHON_CHANNEL", "").strip(),
)