mirror of
https://github.com/yagop/node-telegram-bot-api
synced 2025-08-28 12:57:38 +00:00
bind requestListener function on createServer
This commit is contained in:
parent
573640a421
commit
01a1b67bb4
@ -53,26 +53,22 @@ var TelegramBot = function (token, options) {
|
||||
util.inherits(TelegramBot, EventEmitter);
|
||||
|
||||
TelegramBot.prototype._configureWebHook = function (port, host, key, cert) {
|
||||
var protocol = 'HTTP';
|
||||
var self = this;
|
||||
var binded = this._requestListener.bind(this);
|
||||
|
||||
if (key && cert) { // HTTPS Server
|
||||
protocol = 'HTTPS';
|
||||
debug('HTTPS WebHook enabled');
|
||||
var options = {
|
||||
key: fs.readFileSync(key),
|
||||
cert: fs.readFileSync(cert)
|
||||
};
|
||||
this._webServer = https.createServer(options, function (req, res) {
|
||||
self._requestListener.call(self, req, res);
|
||||
});
|
||||
} else { // HTTP Server
|
||||
this._webServer = http.createServer(function (req, res) {
|
||||
self._requestListener.call(self, req, res);
|
||||
});
|
||||
this._webServer = https.createServer(options, binded);
|
||||
} else {
|
||||
debug('HTTP WebHook enabled');
|
||||
this._webServer = http.createServer(binded);
|
||||
}
|
||||
|
||||
this._webServer.listen(port, host, function () {
|
||||
console.log(protocol+" WebHook listening on:", port);
|
||||
debug("WebHook listening on port %s", port);
|
||||
});
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user