From dad8697411d655f851f85b02b71e66f3226a131c Mon Sep 17 00:00:00 2001 From: GochoMugo Date: Mon, 30 Jan 2017 13:44:07 +0300 Subject: [PATCH] doc: Document options.webHook.host --- doc/api.md | 1 + src/telegram.js | 1 + src/telegramWebHook.js | 5 ++++- 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/doc/api.md b/doc/api.md index 4da53b8..5a08492 100644 --- a/doc/api.md +++ b/doc/api.md @@ -74,6 +74,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.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 | | [options.webHook.key] | String | | Path to file with PEM private key for webHook server. The file is read **synchronously**! | | [options.webHook.cert] | String | | Path to file with PEM certificate (public) for webHook server. The file is read **synchronously**! | diff --git a/src/telegram.js b/src/telegram.js index 1c4be1c..ffbb419 100644 --- a/src/telegram.js +++ b/src/telegram.js @@ -47,6 +47,7 @@ class TelegramBot extends EventEmitter { * @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 {String} [options.webHook.host=0.0.0.0] Host to bind to * @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. * The file is read **synchronously**! diff --git a/src/telegramWebHook.js b/src/telegramWebHook.js index d35c649..d4db943 100644 --- a/src/telegramWebHook.js +++ b/src/telegramWebHook.js @@ -12,6 +12,7 @@ class TelegramBotWebHook { * * @param {String} token Telegram API token * @param {Boolean|Object} options WebHook options + * @param {String} [options.host=0.0.0.0] Host to bind to * @param {Number} [options.port=8443] Port to bind to * @param {String} [options.healthEndpoint=/healthz] An endpoint for health checks that always responds with 200 OK * @param {Function} callback Function for process a new update @@ -24,11 +25,13 @@ class TelegramBotWebHook { this.token = token; this.options = options; + this.options.host = options.host || '0.0.0.0'; this.options.port = options.port || 8443; this.options.https = options.https || {}; + this.options.healthEndpoint = options.healthEndpoint || '/healthz'; this.callback = callback; this._regex = new RegExp(this.token); - this._healthRegex = new RegExp(options.healthEndpoint || '/healthz'); + this._healthRegex = new RegExp(this.options.healthEndpoint); this._webServer = null; this._open = false; this._requestListener = this._requestListener.bind(this);