Merge pull request #44 from laurynas-karvelis/master

Don't add 'getUpdates' request to the queue
This commit is contained in:
Mahdi Dibaiee 2018-04-20 16:02:47 +04:30 committed by GitHub
commit 66a4b09288
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -65,6 +65,11 @@ const methods = ['getMe', 'sendMessage', 'forwardMessage', 'sendPhoto',
methods.forEach(method => { methods.forEach(method => {
API.prototype[method] = function (data) { //eslint-disable-line API.prototype[method] = function (data) { //eslint-disable-line
if (method === 'getUpdates') {
// don't add 'getUpdates' request to the queue as it's going to hinder 'send*' calls performance
return this.request(method, data);
}
// implementation taken from https://github.com/yagop/node-telegram-bot-api/issues/192#issuecomment-249488807 // implementation taken from https://github.com/yagop/node-telegram-bot-api/issues/192#issuecomment-249488807
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
this._queue.push({ method, data, resolve, reject }); this._queue.push({ method, data, resolve, reject });