示例json用于电报机器人中的show inline_keyboard
https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating
在此输入图像描述
{ "chat_id": "123456", "text": "Hi", "reply_markup": { "inline_keyboard": [[ { "text": "A", "callback_data": "A1" }, { "text": "B", "callback_data": "C1" }] ] } }
Nova.. 6
我只是很难尝试让它在我的API上工作,我发现了问题.你需要JSON.stringify()的内容reply_markup首先键盘对象和内容转换为字符串.
这是一个例子.
bot.onCommand = function (chat, from, message_id, text, command, commandData) { if (command === "test") { var keyboard = { "inline_keyboard": [ [ {"text": "Yes", "url": "http://www.google.com/"}, {"text": "No", "url": "http://www.google.com/"} ] ] }; var data = { "reply_to_message_id": message_id, "reply_markup": JSON.stringify(keyboard) }; bot.sendText(chat.id, "test", data, function (isSuccess) { console.log(isSuccess); }); return; } }
我写这篇文章是为了让它不那么混乱.
输出将是:
(test ) [Yes] [No]
圆圈括号是消息,方括号是按钮.在此示例中都打开了指向Google的链接.
我只是很难尝试让它在我的API上工作,我发现了问题.你需要JSON.stringify()的内容reply_markup首先键盘对象和内容转换为字符串.
这是一个例子.
bot.onCommand = function (chat, from, message_id, text, command, commandData) { if (command === "test") { var keyboard = { "inline_keyboard": [ [ {"text": "Yes", "url": "http://www.google.com/"}, {"text": "No", "url": "http://www.google.com/"} ] ] }; var data = { "reply_to_message_id": message_id, "reply_markup": JSON.stringify(keyboard) }; bot.sendText(chat.id, "test", data, function (isSuccess) { console.log(isSuccess); }); return; } }
我写这篇文章是为了让它不那么混乱.
输出将是:
(test ) [Yes] [No]
圆圈括号是消息,方括号是按钮.在此示例中都打开了指向Google的链接.