![](/img/trans.png)
[英]PHP - How to read the text of a button that was clicked on ReplyKeyboardMarkup (Telegram bot)
[英]How to hide ReplyKeyboardMarkup after user click in Telegram Bot API
我正在使用Node.js telegram-bot-api 。
理念:
這是我正在使用的代碼:
bot.sendMessage({
text: 'Please give us your phone number',
reply_markup: JSON.stringify({
keyboard: [
[{
text: 'Share my phone number',
request_contact: true
}]
],
resize_keyboard: true,
one_time_keyboard: true
})
});
問題:
request_contact
標志時, one_time_keyboard
正常工作(在使用后隱藏按鈕),但即使在這種情況下它只是隱藏按鈕,所以用戶可以點擊一個圖標將其帶回屏幕,這根本不好。 如果我在這里做錯了,請告訴我。 謝謝
找到了。
這是一個解決方案:
bot.sendMessage({
chat_id: message.chat.id,
text: 'Some text...',
reply_markup: JSON.stringify({
hide_keyboard: true
})
});
hide_keyboard
已更名為remove_keyboard
自API 2.3 。
bot.sendMessage({
chat_id: message.chat.id,
text: 'Some text...',
reply_markup: JSON.stringify({
remove_keyboard: true
})
});
您應該使用editMessageReplyMarkup
並在收到客戶端用戶的點擊后使用空字符串( ''
)更新該消息的replyMarkup
。
更新這適用於內聯鍵盤。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.