【问题标题】:Telegram bot inline keyboard via Node.JS通过 Node.JS 的 Telegram bot 内联键盘
【发布时间】:2017-06-18 01:51:13
【问题描述】:

我正在使用 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);
});

【问题讨论】:

  • 你会看到什么结果?

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


【解决方案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"]]

【讨论】:

    【解决方案2】:

    在您的情况下,解决方案是:

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

    【讨论】:

    • 不起作用。错误:Unhandled rejection Error: ETELEGRAM: 400 Bad Request: can't parse inline keyboard button: Text buttons are unallowed in the inline keyboard
    【解决方案3】:

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

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

    【讨论】:

      猜你喜欢
      • 2017-06-02
      • 2016-10-20
      • 2018-08-09
      • 2018-03-31
      • 1970-01-01
      • 2020-01-05
      • 2017-06-06
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多