From 178f9cd9051b63377fcbb3a13f564b175b1cd3e7 Mon Sep 17 00:00:00 2001 From: Yago Date: Sun, 13 Mar 2016 13:42:46 +0100 Subject: [PATCH] Update offset on polling everymessage --- src/telegramPolling.js | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/telegramPolling.js b/src/telegramPolling.js index 7cec903..d0546e6 100644 --- a/src/telegramPolling.js +++ b/src/telegramPolling.js @@ -30,16 +30,13 @@ TelegramBotPolling.prototype._polling = function () { this.lastUpdate = Date.now(); debug('polling data %j', updates); updates.forEach(function (update, index) { - // If is the latest, update the offset. - if (index === updates.length - 1) { - this.offset = update.update_id; - debug('updated offset: %s', this.offset); - } + this.offset = update.update_id; + debug('updated offset: %s', this.offset); this.callback(update); }.bind(this)); }.bind(this)) .catch(function (err) { - debug('polling error: %j', err); + debug('polling error: %s', err.message); throw err; }) .finally(function () {