Spaces:
Runtime error
Runtime error
File size: 732 Bytes
a405e76 cc8851e a405e76 cc8851e a405e76 cc8851e a405e76 cc8851e |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# 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) |