Skip to content

Commit 8c7bdba

Browse files
committed
also added message_id to sendMessage() function
1 parent 762d6e8 commit 8c7bdba

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

src/UniversalTelegramBot.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -562,16 +562,19 @@ bool UniversalTelegramBot::sendSimpleMessage(const String& chat_id, const String
562562
}
563563

564564
bool UniversalTelegramBot::sendMessage(const String& chat_id, const String& text,
565-
const String& parse_mode) {
565+
const String& parse_mode, int message_id) { // added message_id
566566

567567
DynamicJsonDocument payload(maxMessageLength);
568568
payload["chat_id"] = chat_id;
569569
payload["text"] = text;
570570

571+
if (message_id != 0)
572+
payload["message_id"] = message_id; // added message_id
573+
571574
if (parse_mode != "")
572575
payload["parse_mode"] = parse_mode;
573576

574-
return sendPostMessage(payload.as<JsonObject>());
577+
return sendPostMessage(payload.as<JsonObject>(), message_id); // if message id == 0 then edit is false, else edit is true
575578
}
576579

577580
bool UniversalTelegramBot::sendMessageWithReplyKeyboard(

src/UniversalTelegramBot.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ class UniversalTelegramBot {
8484
bool getMe();
8585

8686
bool sendSimpleMessage(const String& chat_id, const String& text, const String& parse_mode);
87-
bool sendMessage(const String& chat_id, const String& text, const String& parse_mode = "");
87+
bool sendMessage(const String& chat_id, const String& text, const String& parse_mode = "", int message_id = 0); // added message id
8888
bool sendMessageWithReplyKeyboard(const String& chat_id, const String& text,
8989
const String& parse_mode, const String& keyboard,
9090
bool resize = false, bool oneTime = false,

0 commit comments

Comments
 (0)