mirror of
https://github.com/yagop/node-telegram-bot-api
synced 2025-09-02 15:25:28 +00:00
_processUpdate
This commit is contained in:
@@ -92,8 +92,7 @@ TelegramBot.prototype._requestListener = function (req, res) {
|
|||||||
try {
|
try {
|
||||||
debug('WebHook request fullBody', fullBody);
|
debug('WebHook request fullBody', fullBody);
|
||||||
var data = JSON.parse(fullBody);
|
var data = JSON.parse(fullBody);
|
||||||
self.offset = data.update_id;
|
self._processUpdate(data);
|
||||||
self.emit('message', data.message);
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
debug(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) {
|
TelegramBot.prototype._processUpdates = function (updates) {
|
||||||
for (var i = 0; i < updates.length; i++) {
|
for (var i = 0; i < updates.length; i++) {
|
||||||
if (updates[i].message) {
|
this._processUpdate(updates[i]);
|
||||||
this.emit('message', updates[i].message);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user