您更好地使用inlinekeyboard您要显示后两者是/否和前面的键盘按是或否。这样,您可以编辑是/否内嵌键盘消息并显示新键盘。
您可以发送inlineKeyboard,并通过检查它的callBackQuery.Data参数来重新编辑发送的消息并改为显示新消息。
下面
是一个示例更新消息JSON:
{"update_id":14603298,
"callback_query":
{
"id": "479899181065761766",
"from": {
"id": 111735238,
"first_name": "eric",
"username": "...."
},
"message": {
"message_id": 22,
"from": {
"id": 3576731383,
"first_name": "the_bot_name",
"username": "mybot_bot"
},
"chat": {
"id": 111745258,
"first_name": "eric",
"username": "....",
"type": "private"
},
"date": 1492113810,
"text": "sent message"
},
"chat_instance": "5419183837652256438",
"data": "yes"
}}
所以,当用户点击yes或no,你会得到一个更新消息。基于以上的更新消息,chatid和邮件ID是已知的,因此使用C#Telegram.Bot库中编辑代码如下:
var chatid= 111745258;
var messageid=22;
TelegramBotClient api = new TelegramBotClient("YOUR_TOKEN");
var new_keyboard = new InlineKeyboardMarkup(
new[]
{
new[]
{
new InlineKeyboardButton("step_1","step1") ,
},
new[]
{
new InlineKeyboardButton("step_2","step2"),
new InlineKeyboardButton("step_3","step3"),
},
new[]
{
new InlineKeyboardButton("step_4","step4"),
}
});
api.EditMessageReplyMarkupAsync(chatid, messageid, replyMarkup: new_keyboard);