通过Node.JS电报机器人内联键盘

时间:2017-02-01 10:43:14

标签: javascript node.js telegram telegram-bot node-telegram-bot-api

我正在使用 node-telegram-bot-api 模块, 如何将键盘设为内联键盘? 这是我的代码:

bot.onText(/^\/start$/, function (msg) {
    const opts = {
        reply_to_message_id: msg.message_id,
        reply_markup: {
            resize_keyboard: true,
            one_time_keyboard: true,
            keyboard: [ ['Level 1'] ]
        }
    };

    bot.sendMessage(msg.chat.id, "I'm a test robot", opts);
});

3 个答案:

答案 0 :(得分:1)

我回答了类似这个链接的问题:How can create menu for telegram bot in bot father?

在您的情况下,您可以使用:

keyboard: [["uno :+1:"],["uno \ud83d\udc4d", "due"],["uno", "due","tre"],["uno", "due","tre","quattro"]]

答案 1 :(得分:0)

您的解决方案是:

const opts = {
        reply_to_message_id: msg.message_id,
        reply_markup: JSON.stringify({
        inline_keyboard: 
        [
            [{text: 'Level 1'}],
        ]
    })
  };

答案 2 :(得分:0)

您可以使用: https://github.com/RealPeha/telegram-keyboard

该库专注于Telegraf,但是如果没有它,您可以使用。

相关问题