Skip to content

Commit

Permalink
Fix issue onLongPollError reports other callbacks exceptions instead …
Browse files Browse the repository at this point in the history
…of getUpdates() long polling method only.
  • Loading branch information
baderouaich committed Dec 27, 2023
1 parent e965d8e commit 1c382dd
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/Bot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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>& 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());
Expand All @@ -43,6 +36,13 @@ void Bot::start() {
this->onLongPollError("unknown error");
continue;
}
// Dispatch updates to callbacks (onCommand, onAnyMessage, onPoll, ...)
for (const Ptr<Update>& update: m_updates) {
if (update->updateId >= m_lastUpdateId) {
m_lastUpdateId = update->updateId + 1;
this->dispatch(update);
}
}
}
}

Expand Down

0 comments on commit 1c382dd

Please sign in to comment.