diff --git a/README.md b/README.md index b3e62f2..5f515ec 100644 --- a/README.md +++ b/README.md @@ -125,6 +125,7 @@ Emits `message` when a message arrives. | [options.polling] | Boolean | Object | false | Set true to enable polling or set options | | [options.polling.timeout] | String | Number | 10 | Timeout in seconds for long polling | | [options.polling.interval] | String | Number | 300 | Interval between requests in miliseconds | +| [options.polling.autoStart] | Boolean | true | Start polling immediately | | [options.webHook] | Boolean | Object | false | Set true to enable WebHook or set options | | [options.webHook.port] | Number | 8443 | Port to bind to | | [options.webHook.key] | String | | Path to file with PEM private key for webHook server. (Read synchronously!) | diff --git a/src/telegram.js b/src/telegram.js index 419b3d1..760ff21 100644 --- a/src/telegram.js +++ b/src/telegram.js @@ -43,6 +43,7 @@ class TelegramBot extends EventEmitter { * @param {Boolean|Object} [options.polling=false] Set true to enable polling or set options * @param {String|Number} [options.polling.timeout=10] Timeout in seconds for long polling * @param {String|Number} [options.polling.interval=300] Interval between requests in miliseconds + * @param {Boolean} [options.polling.autoStart=true] Start polling immediately * @param {Boolean|Object} [options.webHook=false] Set true to enable WebHook or set options * @param {Number} [options.webHook.port=8443] Port to bind to * @param {String} [options.webHook.key] Path to file with PEM private key for webHook server. (Read synchronously!) @@ -59,7 +60,10 @@ class TelegramBot extends EventEmitter { this._onReplyToMessages = []; if (options.polling) { - this.initPolling(); + const autoStart = options.polling.autoStart; + if (typeof autoStart === 'undefined' || autoStart === true) { + this.initPolling(); + } } if (options.webHook) {