mirror of
https://github.com/yagop/node-telegram-bot-api
synced 2025-08-29 13:27:44 +00:00
Code climate
This commit is contained in:
parent
bc3927713a
commit
2598b1dce9
@ -16,7 +16,7 @@ var requestPromise = Promise.promisify(request);
|
|||||||
* Both request method to obtain messages are implemented. To use standard polling, set `polling: true`
|
* Both request method to obtain messages are implemented. To use standard polling, set `polling: true`
|
||||||
* on `options`. Notice that [webHook](https://core.telegram.org/bots/api#setwebhook) will need a valid (not self signed) SSL certificate.
|
* on `options`. Notice that [webHook](https://core.telegram.org/bots/api#setwebhook) will need a valid (not self signed) SSL certificate.
|
||||||
* Emmits `message` when a message arrives.
|
* Emmits `message` when a message arrives.
|
||||||
*
|
*
|
||||||
* @class TelegramBot
|
* @class TelegramBot
|
||||||
* @constructor
|
* @constructor
|
||||||
* @param {String} token Bot Token
|
* @param {String} token Bot Token
|
||||||
@ -76,7 +76,7 @@ TelegramBot.prototype._configureWebHook = function (port, key, cert) {
|
|||||||
|
|
||||||
TelegramBot.prototype._requestListener = function (req, res) {
|
TelegramBot.prototype._requestListener = function (req, res) {
|
||||||
var self = this;
|
var self = this;
|
||||||
if (req.url == '/bot' && req.method == 'POST') {
|
if (req.url === '/bot' && req.method === 'POST') {
|
||||||
var fullBody = '';
|
var fullBody = '';
|
||||||
req.on('data', function (chunk) {
|
req.on('data', function (chunk) {
|
||||||
fullBody += chunk.toString();
|
fullBody += chunk.toString();
|
||||||
@ -124,7 +124,7 @@ TelegramBot.prototype._request = function (path, options) {
|
|||||||
|
|
||||||
return requestPromise(options)
|
return requestPromise(options)
|
||||||
.then(function (resp) {
|
.then(function (resp) {
|
||||||
if (resp[0].statusCode != 200) {
|
if (resp[0].statusCode !== 200) {
|
||||||
throw new Error(resp[0].statusCode+' '+resp[0].body);
|
throw new Error(resp[0].statusCode+' '+resp[0].body);
|
||||||
}
|
}
|
||||||
var data = JSON.parse(resp[0].body);
|
var data = JSON.parse(resp[0].body);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user