Skip to content

Commit dc0146e

Browse files
committed
saving the
1 parent 6be1e70 commit dc0146e

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

src/UniversalTelegramBot.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -763,9 +763,14 @@ String UniversalTelegramBot::sendPhoto(String chat_id, String photo,
763763
}
764764

765765
bool UniversalTelegramBot::checkForOkResponse(String response) {
766+
int last_id;
766767
DynamicJsonDocument doc(response.length());
767768
deserializeJson(doc, response);
768769

770+
// Save last sent message_id
771+
last_id = doc["result"]["message_id"];
772+
if (last_id > 0) last_sent_message_id = last_id;
773+
769774
return doc["ok"] | false; // default is false, but this is more explicit and clear
770775
}
771776

src/UniversalTelegramBot.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ class UniversalTelegramBot {
109109
int longPoll = 0;
110110
int waitForResponse = 1500;
111111
int _lastError;
112+
int last_sent_message_id = 0;
112113

113114
private:
114115
// JsonObject * parseUpdates(String response);

0 commit comments

Comments
 (0)