ир
This commit is contained in:
@@ -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(),
|
||||
)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user