Update offset on polling everymessage

experimental
Yago 10 years ago
parent 610a989e69
commit 178f9cd905
  1. 9
      src/telegramPolling.js

@ -30,16 +30,13 @@ TelegramBotPolling.prototype._polling = function () {
this.lastUpdate = Date.now(); this.lastUpdate = Date.now();
debug('polling data %j', updates); debug('polling data %j', updates);
updates.forEach(function (update, index) { updates.forEach(function (update, index) {
// If is the latest, update the offset. this.offset = update.update_id;
if (index === updates.length - 1) { debug('updated offset: %s', this.offset);
this.offset = update.update_id;
debug('updated offset: %s', this.offset);
}
this.callback(update); this.callback(update);
}.bind(this)); }.bind(this));
}.bind(this)) }.bind(this))
.catch(function (err) { .catch(function (err) {
debug('polling error: %j', err); debug('polling error: %s', err.message);
throw err; throw err;
}) })
.finally(function () { .finally(function () {

Loading…
Cancel
Save