[英]Is there a bot menu in Telethon?
我正在用Telethon構建一個應用程序,並且幾乎完成了它。 現在還有一些美麗要做,我發現互聯網(以及文檔)中沒有很好的解釋如何制作機器人的菜單。
一兩年前,我用types.ReplyKeyboardMarkup
構建了另一個機器人,它使用types.ReplyKeyboardMarkup為它提供了一個很好的解決方案。 我可以看到 Telethon 文檔如何提到ReplyKeyboardMarkup
,但我仍然無法完成我的機器人菜單。
為了清楚起見,我想要做的看起來像這樣:
哦,我發現我使用了錯誤的 Button 類型( inline
而不是text
)。 工作代碼:
from telethon import events, Button
bot = ...
@bot.on(events.NewMessage(pattern='/start'))
async def handle_start_command(event):
markup = event.client.build_reply_markup([
[Button.text('First button')],
[Button.text('Second button')]
])
await event.respond("Hello!", buttons=markup)
結果如下所示:
文檔說:
您可以一起使用
inline
、switch_inline
、url
和auth
來創建內聯按鈕(在消息下方)。您可以一起使用
text
、request_location
、request_phone
和request_poll
來創建回復標記(替換用戶鍵盤)。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.