summaryrefslogtreecommitdiff
path: root/src/net/TgLongPoll.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/net/TgLongPoll.cpp')
-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);
}
}