热解图请求PerrButton

问题描述 投票:0回答:1

我想请求热图中用户拥有的频道之一。

这是我的代码

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)
    

这会引发毫无意义的异常,这些异常都是由键盘引起的。

python telegram pyrogram
1个回答
0
投票

根据您的代码,您完全搞砸了,完全使用

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)

潜在错误:

  1. 使用
    raw
    函数,仅与
    client.invoke()
    一起使用,这些函数仅适用于不在热解图中内置的 TelegramAPI 函数。

参考资料:

© www.soinside.com 2019 - 2024. All rights reserved.