From d9dfa73edda127580e0961c89d8fafa56735f672 Mon Sep 17 00:00:00 2001 From: llnulldisk <48621230+llnulldisk@users.noreply.github.com> Date: Thu, 29 Sep 2022 10:27:41 +0200 Subject: Confirm updates directly after handling them (#231) --- src/net/TgLongPoll.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src') 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 updates = _api->getUpdates(_lastUpdateId, _limit, _timeout, _allowUpdates); + // get all unconfirmed updates + std::vector 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); } } -- cgit v1.2.3