Universal-Arduino-Telegram-Bot icon indicating copy to clipboard operation
Universal-Arduino-Telegram-Bot copied to clipboard

Remove keyboard feature added, here is the code i used.

Open Hoeby opened this issue 4 years ago • 1 comments

In the .ino file, this is de command to trigger the remove keyboard function bot.sendMessageWithRemoveKeyboard(chat_id, "Your text", true);

In the UniversalTelegramBot.h file i added this bool sendMessageWithRemoveKeyboard(const String& chat_id, const String& text, bool remove_keyboard = false);

In the UniversalTelegramBot.cpp file i added this

bool UniversalTelegramBot::sendMessageWithRemoveKeyboard(const String& chat_id,
                                                         const String& text,
                                                         bool remove_keyboard) {

  DynamicJsonDocument payload(maxMessageLength);
  payload["chat_id"] = chat_id;
  payload["text"] = text;


  JsonObject replyMarkup = payload.createNestedObject("reply_markup");

  if (remove_keyboard)
    replyMarkup["remove_keyboard"] = remove_keyboard;

  return sendPostMessage(payload.as<JsonObject>());
}

There is an option "selective" for the remove keyboard. It didn't add that function, it is optional. But i think it is not a problem for you to add that to the code.

Hoeby avatar Aug 18 '20 08:08 Hoeby

Anyone interested in turning this into a PR? Would either need a new example or the existing keyboard example to be updated

witnessmenow avatar Sep 30 '20 23:09 witnessmenow