diff --git a/src/Bot.cpp b/src/Bot.cpp index 64f83337d..b7dd848b2 100644 --- a/src/Bot.cpp +++ b/src/Bot.cpp @@ -27,13 +27,6 @@ void Bot::start() { try { // Get updates from Telegram (any new events such as messages, commands, files, ...) m_updates = m_api->getUpdates(/*offset=*/m_lastUpdateId); - // Dispatch updates to callbacks (onCommand, onAnyMessage, onPoll, ...) - for (const Ptr& update: m_updates) { - if (update->updateId >= m_lastUpdateId) { - m_lastUpdateId = update->updateId + 1; - this->dispatch(update); - } - } } catch (const std::exception& err) { /// Callback -> onLongPollError this->onLongPollError(err.what()); @@ -43,6 +36,13 @@ void Bot::start() { this->onLongPollError("unknown error"); continue; } + // Dispatch updates to callbacks (onCommand, onAnyMessage, onPoll, ...) + for (const Ptr& update: m_updates) { + if (update->updateId >= m_lastUpdateId) { + m_lastUpdateId = update->updateId + 1; + this->dispatch(update); + } + } } }