summaryrefslogtreecommitdiff
path: root/src/net
diff options
context:
space:
mode:
authorllnulldisk <48621230+llnulldisk@users.noreply.github.com>2022-09-29 10:27:41 +0200
committerllnulldisk <48621230+llnulldisk@users.noreply.github.com>2022-09-29 10:27:41 +0200
commitd9dfa73edda127580e0961c89d8fafa56735f672 (patch)
tree0273a42e2b716821bbc0642adc8ecc863d7ec7fb /src/net
parentf7e27c9acdfd96c6a5d7f3e056643a722945cd96 (diff)
Confirm updates directly after handling them (#231)
Diffstat (limited to 'src/net')
-rw-r--r--src/net/TgLongPoll.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/net/TgLongPoll.cpp b/src/net/TgLongPoll.cpp
index a7b4fcb..6a224cb 100644
--- a/src/net/TgLongPoll.cpp
+++ b/src/net/TgLongPoll.cpp
@@ -21,13 +21,19 @@ TgLongPoll::TgLongPoll(const Bot& bot, std::int32_t limit, std::int32_t timeout,
}
void TgLongPoll::start() {
- std::vector<Update::Ptr> updates = _api->getUpdates(_lastUpdateId, _limit, _timeout, _allowUpdates);
+ // get all unconfirmed updates
+ std::vector<Update::Ptr> updates = _api->getUpdates(0, _limit, _timeout, _allowUpdates);
+
+ // handle updates
for (Update::Ptr& item : updates) {
if (item->updateId >= _lastUpdateId) {
_lastUpdateId = item->updateId + 1;
}
_eventHandler->handleUpdate(item);
}
+
+ // confirm handled updates
+ _api->getUpdates(_lastUpdateId, _limit, _timeout, _allowUpdates);
}
}