2
0
mirror of https://github.com/yagop/node-telegram-bot-api synced 2025-08-29 13:27:44 +00:00
This commit is contained in:
Yago 2015-09-27 11:18:25 +02:00
parent 48045b98ff
commit 6a679b5644
7 changed files with 46 additions and 14 deletions

11
.jshintrc Normal file
View File

@ -0,0 +1,11 @@
{
"curly" : true,
"eqeqeq" : true,
"indent" : 2,
"latedef" : true,
"newcap" : true,
"quotmark": "single",
"strict" : true,
"undef" : true,
"node" : true
}

View File

@ -16,7 +16,8 @@
"scripts": {
"test": "./node_modules/.bin/mocha test/index.js",
"test-cov": "./node_modules/.bin/istanbul cover ./node_modules/mocha/bin/_mocha --report lcovonly -- -R spec && cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js && rm -rf ./coverage",
"gen-doc": "./node_modules/.bin/jsdoc2md --src src/telegram.js -t README.hbs > README.md"
"gen-doc": "./node_modules/.bin/jsdoc2md --src src/telegram.js -t README.hbs > README.md",
"jshint": "./node_modules/.bin/jshint src test"
},
"author": "Yago Pérez <yagoperezs@gmail.com>",
"license": "MIT",
@ -32,6 +33,7 @@
"del": "^2.0.2",
"istanbul": "^0.3.17",
"jsdoc-to-markdown": "^1.2.0",
"jshint": "^2.8.0",
"mocha": "^2.2.5",
"mocha-lcov-reporter": "0.0.2",
"should": "^7.0.1"

View File

@ -1,9 +1,11 @@
'use strict';
var TelegramBotWebHook = require('./telegramWebHook');
var TelegramBotPolling = require('./telegramPolling');
var debug = require('debug')('node-telegram-bot-api');
var EventEmitter = require('events').EventEmitter;
var Promise = require("bluebird");
var request = require("request");
var Promise = require('bluebird');
var request = require('request');
var stream = require('stream');
var util = require('util');
var mime = require('mime');
@ -56,7 +58,7 @@ util.inherits(TelegramBot, EventEmitter);
TelegramBot.prototype.initPolling = function() {
if (this._polling) {
this._polling.abort = true;
this._polling.lastRequest.cancel("Polling restart");
this._polling.lastRequest.cancel('Polling restart');
}
this._polling = new TelegramBotPolling(this.token, this.options.polling, this.processUpdate);
};
@ -111,7 +113,7 @@ TelegramBot.prototype._buildURL = function(path) {
host: 'api.telegram.org',
pathname: '/bot' + this.token + '/' + path
});
}
};
/**
* Returns basic information about the bot in form of a `User` object.
@ -462,6 +464,6 @@ TelegramBot.prototype.downloadFile = function(fileId, downloadDir) {
});
});
}
};
module.exports = TelegramBot;

View File

@ -1,5 +1,7 @@
'use strict';
var debug = require('debug')('node-telegram-bot-api');
var Promise = require("bluebird");
var Promise = require('bluebird');
var request = require('request');
var URL = require('url');
@ -7,7 +9,7 @@ var requestPromise = Promise.promisify(request);
var TelegramBotPolling = function (token, options, callback) {
options = options || {};
if (typeof options === "function") {
if (typeof options === 'function') {
callback = options;
options = {};
}

View File

@ -1,7 +1,8 @@
'use strict';
var debug = require('debug')('node-telegram-bot-api');
var https = require('https');
var http = require('http');
var util = require('util');
var fs = require('fs');
var TelegramBotWebHook = function (token, options, callback) {
@ -26,7 +27,7 @@ var TelegramBotWebHook = function (token, options, callback) {
}
this._webServer.listen(options.port, options.host, function () {
debug("WebHook listening on port %s", options.port);
debug('WebHook listening on port %s', options.port);
});
};

12
test/.jshintrc Normal file
View File

@ -0,0 +1,12 @@
{
"mocha" : true,
"curly" : true,
"eqeqeq" : true,
"indent" : 2,
"latedef" : true,
"newcap" : true,
"quotmark": "single",
"strict" : true,
"undef" : true,
"node" : true
}

View File

@ -1,10 +1,12 @@
'use strict';
var TelegramPolling = require('../src/telegramPolling');
var Telegram = require('../index');
var request = require('request');
var should = require('should');
var fs = require('fs');
process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0";
process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';
var TOKEN = process.env.TEST_TELEGRAM_TOKEN;
if (!TOKEN) {
throw new Error('Bot token not provided');
@ -69,7 +71,7 @@ describe('Telegram', function () {
method: 'POST',
json: true,
headers: {
"content-type": "application/json",
'content-type': 'application/json',
},
body: {update_id: 0, message: {text: 'test'}}
});
@ -94,7 +96,7 @@ describe('Telegram', function () {
method: 'POST',
json: true,
headers: {
"content-type": "application/json",
'content-type': 'application/json',
},
rejectUnhauthorized: false,
body: {update_id: 0, message: {text: 'test'}}
@ -190,7 +192,7 @@ describe('Telegram', function () {
describe('#sendChatAction', function () {
it('should send a chat action', function (done) {
var bot = new Telegram(TOKEN);
var action = "typing";
var action = 'typing';
bot.sendChatAction(USERID, action).then(function (resp) {
resp.should.be.exactly(true);
done();