From 9a9dfa9560eaf0bddb732868809be4c0e21585c4 Mon Sep 17 00:00:00 2001 From: GochoMugo Date: Thu, 9 Feb 2017 19:06:38 +0300 Subject: [PATCH] src: Minor fixes --- doc/api.md | 1 + src/telegram.js | 1 + src/telegramPolling.js | 2 +- test/telegram.js | 2 +- 4 files changed, 4 insertions(+), 2 deletions(-) diff --git a/doc/api.md b/doc/api.md index dd0d52b..e29e744 100644 --- a/doc/api.md +++ b/doc/api.md @@ -75,6 +75,7 @@ Emits `message` when a message arrives. | [options.polling.interval] | String | Number | 300 | Interval between requests in miliseconds | | [options.polling.autoStart] | Boolean | true | Start polling immediately | | [options.polling.params] | Object | | Parameters to be used in polling API requests. See https://core.telegram.org/bots/api#getupdates for more information. | +| [options.polling.params.timeout] | Number | 10 | Timeout in seconds for long polling. | | [options.webHook] | Boolean | Object | false | Set true to enable WebHook or set options | | [options.webHook.host] | String | 0.0.0.0 | Host to bind to | | [options.webHook.port] | Number | 8443 | Port to bind to | diff --git a/src/telegram.js b/src/telegram.js index 5194180..e30d4a0 100644 --- a/src/telegram.js +++ b/src/telegram.js @@ -57,6 +57,7 @@ class TelegramBot extends EventEmitter { * @param {Boolean} [options.polling.autoStart=true] Start polling immediately * @param {Object} [options.polling.params] Parameters to be used in polling API requests. * See https://core.telegram.org/bots/api#getupdates for more information. + * @param {Number} [options.polling.params.timeout=10] Timeout in seconds for long polling. * @param {Boolean|Object} [options.webHook=false] Set true to enable WebHook or set options * @param {String} [options.webHook.host=0.0.0.0] Host to bind to * @param {Number} [options.webHook.port=8443] Port to bind to diff --git a/src/telegramPolling.js b/src/telegramPolling.js index bcc8311..43ed751 100644 --- a/src/telegramPolling.js +++ b/src/telegramPolling.js @@ -133,7 +133,7 @@ class TelegramBotPolling { */ _getUpdates() { debug('polling with options: %j', this.options.params); - return this.bot._request('getUpdates', this.options.params) + return this.bot.getUpdates(this.options.params) .catch(err => { if (err.response && err.response.statusCode === ANOTHER_WEB_HOOK_USED) { return this._unsetWebHook(); diff --git a/test/telegram.js b/test/telegram.js index 345b6bf..a099c97 100644 --- a/test/telegram.js +++ b/test/telegram.js @@ -48,7 +48,7 @@ before(function beforeAll() { describe('module.exports', function moduleExportsSuite() { const nodeVersion = parseInt(process.versions.node.split('.')[0], 10); - it('is loaded from src/ on Node.js v5+', function test() { + it('is loaded from src/ on Node.js v5+ and above', function test() { if (nodeVersion <= 4) this.skip(); // skip on Node.js v4 and below assert.equal(TelegramBot, require('../src/telegram')); });