from configparser import RawConfigParser from httpx import get from pyrogram import Client config = RawConfigParser() config.read("config.ini") bot_token: str = "" bot_token = config.get("basic", "bot_token", fallback=bot_token) # 自定义类型 class Bot: def __init__(self, data: dict): self.uid = data["id"] self.username = data["username"] self.name = data["first_name"] me = Bot(get(f"https://api.telegram.org/bot{bot_token}/getme").json()["result"]) # 初始化客户端 app = Client("bot", bot_token=bot_token)