Skip to content

Commit 3190674

Browse files
committed
Issue #4: No need to re-serialized the keyboard, just pass it along
1 parent d8e047b commit 3190674

File tree

1 file changed

+2
-11
lines changed

1 file changed

+2
-11
lines changed

src/UniversalTelegramBot.cpp

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -611,14 +611,7 @@ bool UniversalTelegramBot::sendMessageWithReplyKeyboard(
611611

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

614-
// Reply keyboard is an array of arrays.
615-
// Outer array represents rows
616-
// Inner arrays represents columns
617-
// This example "ledon" and "ledoff" are two buttons on the top row
618-
// and "status is a single button on the next row"
619-
DynamicJsonDocument keyboardBuffer(maxMessageLength); // creating a buffer enough to keep keyboard string
620-
deserializeJson(keyboardBuffer, keyboard);
621-
replyMarkup["keyboard"] = keyboardBuffer.as<JsonArray>();
614+
replyMarkup["keyboard"] = serialized(keyboard);
622615

623616
// Telegram defaults these values to false, so to decrease the size of the
624617
// payload we will only send them if needed
@@ -647,9 +640,7 @@ bool UniversalTelegramBot::sendMessageWithInlineKeyboard(String chat_id,
647640
payload["parse_mode"] = parse_mode;
648641

649642
JsonObject replyMarkup = payload.createNestedObject("reply_markup");
650-
DynamicJsonDocument keyboardBuffer(maxMessageLength); // assuming keyboard buffer will alwas be limited to 1024 bytes
651-
deserializeJson(keyboardBuffer, keyboard);
652-
replyMarkup["inline_keyboard"] = keyboardBuffer.as<JsonArray>();
643+
replyMarkup["inline_keyboard"] = serialized(keyboard);
653644
return sendPostMessage(payload.as<JsonObject>());
654645
}
655646

0 commit comments

Comments
 (0)