@@ -238,6 +238,39 @@ bool UniversalTelegramBot::sendMessage(String chat_id, String text, String reply
238
238
// if (sent==false) Serial.println("Message not delivered");
239
239
}
240
240
241
+ bool UniversalTelegramBot::sendMessageWithReplyKeyboard (String chat_id, String text, String reply_markup, String keyboard, bool resize, bool oneTime, bool selective) {
242
+
243
+
244
+ DynamicJsonBuffer jsonBuffer;
245
+ JsonObject& payload = jsonBuffer.createObject ();
246
+ payload[" chat_id" ] = chat_id;
247
+ payload[" text" ] = text;
248
+ JsonObject& replyMarkup = payload.createNestedObject (" reply_markup" );
249
+
250
+ // Reply keyboard is an array of arrays.
251
+ // Outer array represents rows
252
+ // Inner arrays represents columns
253
+ // This example "ledon" and "ledoff" are two buttons on the top row
254
+ // and "status is a single button on the next row"
255
+ DynamicJsonBuffer keyboardBuffer;
256
+ replyMarkup[" keyboard" ] = keyboardBuffer.parseArray (keyboard);
257
+
258
+ // Telegram defaults these values to false, so to decrease the size of the payload we will only send them if needed
259
+ if (resize){
260
+ replyMarkup[" resize_keyboard" ] = resize;
261
+ }
262
+
263
+ if (oneTime){
264
+ replyMarkup[" one_time_keyboard" ] = oneTime;
265
+ }
266
+
267
+ if (selective){
268
+ replyMarkup[" selective" ] = selective;
269
+ }
270
+
271
+ return sendPostMessage (payload);
272
+ }
273
+
241
274
/* **********************************************************************
242
275
* SendPostMessage - function to send message to telegram *
243
276
* (Arguments to pass: chat_id, text to transmit and markup(optional)) *
0 commit comments