mirror of
https://github.com/yagop/node-telegram-bot-api
synced 2025-08-28 21:07:39 +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);
|
util.inherits(TelegramBot, EventEmitter);
|
||||||
|
|
||||||
TelegramBot.prototype._configureWebHook = function (port, host, key, cert) {
|
TelegramBot.prototype._configureWebHook = function (port, host, key, cert) {
|
||||||
var protocol = 'HTTP';
|
var binded = this._requestListener.bind(this);
|
||||||
var self = this;
|
|
||||||
|
|
||||||
if (key && cert) { // HTTPS Server
|
if (key && cert) { // HTTPS Server
|
||||||
protocol = 'HTTPS';
|
debug('HTTPS WebHook enabled');
|
||||||
var options = {
|
var options = {
|
||||||
key: fs.readFileSync(key),
|
key: fs.readFileSync(key),
|
||||||
cert: fs.readFileSync(cert)
|
cert: fs.readFileSync(cert)
|
||||||
};
|
};
|
||||||
this._webServer = https.createServer(options, function (req, res) {
|
this._webServer = https.createServer(options, binded);
|
||||||
self._requestListener.call(self, req, res);
|
} else {
|
||||||
});
|
debug('HTTP WebHook enabled');
|
||||||
} else { // HTTP Server
|
this._webServer = http.createServer(binded);
|
||||||
this._webServer = http.createServer(function (req, res) {
|
|
||||||
self._requestListener.call(self, req, res);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this._webServer.listen(port, host, function () {
|
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