2
0
mirror of https://github.com/yagop/node-telegram-bot-api synced 2025-08-29 05:17:41 +00:00

_processUpdate

This commit is contained in:
yago 2015-07-12 17:29:43 +02:00
parent 29c748d6f5
commit 3573d0949d

View File

@ -92,8 +92,7 @@ TelegramBot.prototype._requestListener = function (req, res) {
try {
debug('WebHook request fullBody', fullBody);
var data = JSON.parse(fullBody);
self.offset = data.update_id;
self.emit('message', data.message);
self._processUpdate(data);
} catch (error) {
debug(error);
}
@ -106,11 +105,15 @@ TelegramBot.prototype._requestListener = function (req, res) {
}
};
TelegramBot.prototype._processUpdate = function (update) {
if (update.message) {
this.emit('message', update.message);
}
};
TelegramBot.prototype._processUpdates = function (updates) {
for (var i = 0; i < updates.length; i++) {
if (updates[i].message) {
this.emit('message', updates[i].message);
}
this._processUpdate(updates[i]);
}
};