# PATH: bot/client.py from logging import getLogger from hydrogram import Client from bot.config import Telegram logger = getLogger("bot") def create_client() -> Client: base = dict( name="app", api_id=Telegram.API_ID, api_hash=Telegram.API_HASH, in_memory=True, sleep_threshold=-1, max_concurrent_transmissions=10, ) if Telegram.SESSION_STRING: logger.info("Using SESSION_STRING auth") return Client(session_string=Telegram.SESSION_STRING, **base) if not Telegram.BOT_TOKEN: raise RuntimeError("Missing BOT_TOKEN and SESSION_STRING is empty.") logger.info("Using BOT_TOKEN auth") return Client(bot_token=Telegram.BOT_TOKEN, **base)