Telethon Bot创建WebView按钮触发ButtonTypeInvalidError问题求助
你遇到的ButtonTypeInvalidError是因为直接使用types.KeyboardButtonWebView不符合Telethon发送消息时的按钮格式规范,Telethon要求用其自定义的按钮构造器来创建WebView按钮。
改用Telethon内置的Button.webview()方法即可解决问题,示例代码如下:
from telethon.tl.custom.button import Button await client.send_message( event.chat_id, "Test", buttons=[ Button.webview("press me", "https://google.com") ] )
额外注意事项:
- 确保你的Telethon版本为最新版,旧版本可能存在WebView按钮的兼容性问题
- WebApp按钮仅在私聊场景下能正常展示,部分群组环境会受Telegram限制无法显示
- 传入的WebApp链接必须是合法的HTTPS地址,Telegram不支持HTTP链接的WebApp
内容的提问来源于stack exchange,提问作者Dariosky
相关产品推荐
相关产品推荐

