Node-telegram-bot-api: BUG: remove_keyboard flag is not working

Created on 18 Feb 2018  路  1Comment  路  Source: yagop/node-telegram-bot-api

Bug Report

Expected Behavior

Should hide keyboard reply buttons withremove_keyboard: true parameter.

Actual Behavior

Reply keyboard buttons are not hiding/removing with remove_keyboard: true

Steps to reproduce the Behavior

Set parameter for reply_markup --> remove_keyboard: true, answer to question with tapping on button, see that it is not disappearing.

My example which is not working:

 reply_markup: {
      remove_keyboard: true,
      keyboard: [
        [
          {
            text: "text"
          }
        ],
        [
          {
            text: "text"
          }
        ]
      ]
    }
  };

It won't work with JSON.stringify object as well.

Most helpful comment

I don't think it's a bug, you should send a message with an empty keyboard with remove_keyboard: true once you get the result.

example

const optKeyboard = {
  reply_markup: {
      keyboard: [
        [ {
            text: "help",
          }],
        [{
            text: "about"
          }]
      ]}
  }
};

const optRemove = {
  reply_markup: {
     remove_keyboard: true
  }
};

bot.onText(/\/start/, (msg) => {
  bot.sendMessage(msg.chat.id, "Please select one", optKeyboard)
});

bot.on('message', (msg) => {
  if (msg.text.toString().toLowerCase() === 'help') {
    bot.sendMessage(msg.chat.id,"This is a message that shows help and removes keyboard", optRemove);
  } else if (msg.text.toString().toLowerCase() === 'about') {
    bot.sendMessage(msg.chat.id, "The creator of the bot is ME, and remove keyboard", optRemove);
  } 
}

This is how you use remove_keyboard

>All comments

I don't think it's a bug, you should send a message with an empty keyboard with remove_keyboard: true once you get the result.

example

const optKeyboard = {
  reply_markup: {
      keyboard: [
        [ {
            text: "help",
          }],
        [{
            text: "about"
          }]
      ]}
  }
};

const optRemove = {
  reply_markup: {
     remove_keyboard: true
  }
};

bot.onText(/\/start/, (msg) => {
  bot.sendMessage(msg.chat.id, "Please select one", optKeyboard)
});

bot.on('message', (msg) => {
  if (msg.text.toString().toLowerCase() === 'help') {
    bot.sendMessage(msg.chat.id,"This is a message that shows help and removes keyboard", optRemove);
  } else if (msg.text.toString().toLowerCase() === 'about') {
    bot.sendMessage(msg.chat.id, "The creator of the bot is ME, and remove keyboard", optRemove);
  } 
}

This is how you use remove_keyboard

Was this page helpful?
0 / 5 - 0 ratings