我想请求热图中用户拥有的频道之一。
这是我的代码
from pyrogram.raw.types import KeyboardButtonRequestPeer, RequestPeerTypeBroadcast
from pyrogram import types
async def request_channel(message:types.Message)
btn = [
[
KeyboardButtonRequestPeer(
text="Select Channel",
button_id=1,
peer_type=RequestPeerTypeBroadcast(creator=True),
)
]
]
keyboard = types.InlineKeyboardMarkup(btn)
await message.reply_text("Select your channel:", reply_markup=keyboard)
这会引发毫无意义的异常,这些异常都是由键盘引起的。
根据您的代码,您完全搞砸了,完全使用
raw
和热解图函数!
以下是修复方法:
from pyrogram.types import InlineKeyboardMarkup, InlineKeyboardButton, Message
async def request_channel(message: Message)
btns = [
[
InlineKeyboardButton(
text="Select Channel",
url="#some_url",
)
]
]
keyboard = InlineKeyboardMarkup(btns)
await message.reply_text("Select your channel:", reply_markup=keyboard)
潜在错误:
raw
函数,仅与 client.invoke()
一起使用,这些函数仅适用于不在热解图中内置的 TelegramAPI 函数。参考资料: