2
0
mirror of https://github.com/yagop/node-telegram-bot-api synced 2025-08-29 13:27:44 +00:00

Fix ES6 syntax

Fix:

  This enables the library to be used without transpiling on
  Node 6 (current LTS).

Author: @GingerPlusPlus
This commit is contained in:
GochoMugo 2017-01-06 22:26:25 +03:00
parent 215e0dc23b
commit 487b5f4b8b
No known key found for this signature in database
GPG Key ID: 7B6A01CB57AA39E4

View File

@ -27,6 +27,8 @@ class TelegramBotWebHook {
this.callback = callback; this.callback = callback;
this._regex = new RegExp(this.token); this._regex = new RegExp(this.token);
this._webServer = null; this._webServer = null;
this._requestListener = this._requestListener.bind(this);
this._parseBody = this._parseBody.bind(this);
if (options.key && options.cert) { // HTTPS Server if (options.key && options.cert) { // HTTPS Server
debug('HTTPS WebHook enabled'); debug('HTTPS WebHook enabled');
@ -59,7 +61,7 @@ class TelegramBotWebHook {
* Handle request body by passing it to 'callback' * Handle request body by passing it to 'callback'
* @private * @private
*/ */
_parseBody = (err, body) => { _parseBody(err, body) {
if (err) { if (err) {
return debug(err); return debug(err);
} }
@ -78,7 +80,7 @@ class TelegramBotWebHook {
* @see https://nodejs.org/docs/latest/api/http.html#http_http_createserver_requestlistener * @see https://nodejs.org/docs/latest/api/http.html#http_http_createserver_requestlistener
* @see https://nodejs.org/docs/latest/api/https.html#https_https_createserver_options_requestlistener * @see https://nodejs.org/docs/latest/api/https.html#https_https_createserver_options_requestlistener
*/ */
_requestListener = (req, res) => { _requestListener(req, res) {
debug('WebHook request URL: %s', req.url); debug('WebHook request URL: %s', req.url);
debug('WebHook request headers: %j', req.headers); debug('WebHook request headers: %j', req.headers);