Socket
Socket
Sign inDemoInstall

node-telegram-bot-api

Package Overview
Dependencies
Maintainers
1
Versions
64
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-telegram-bot-api - npm Package Compare versions

Comparing version 0.20.1 to 0.21.1

124

package.json
{
"name": "node-telegram-bot-api",
"version": "0.20.1",
"version": "0.21.1",
"description": "Telegram Bot API",

@@ -27,15 +27,15 @@ "main": "index.js",

"debug": "^2.2.0",
"file-type": "^3.4.0",
"file-type": "^3.8.0",
"mime": "^1.3.4",
"request": "^2.67.0"
"request": "^2.69.0"
},
"devDependencies": {
"contributor": "^0.1.25",
"coveralls": "^2.11.6",
"istanbul": "^0.4.1",
"coveralls": "^2.11.8",
"istanbul": "^0.4.2",
"jsdoc-to-markdown": "^1.3.3",
"jshint": "^2.9.1-rc2",
"mocha": "^2.3.4",
"mocha-lcov-reporter": "^1.0.0",
"should": "^8.0.2"
"jshint": "^2.9.1",
"mocha": "^2.4.5",
"mocha-lcov-reporter": "^1.2.0",
"should": "^8.2.2"
},

@@ -52,2 +52,11 @@ "repository": {

{
"name": "Sebastian Troć",
"email": "sebastian.troc@gucman.pl",
"url": "https://github.com/SebastianTroc",
"contributions": 1,
"additions": 1,
"deletions": 1,
"hireable": null
},
{
"name": "Ivan Skorokhodov",

@@ -62,11 +71,29 @@ "email": "iskorokhodov@gmail.com",

{
"name": "Riddler",
"email": null,
"url": "https://github.com/Waterloo",
"contributions": 3,
"additions": 64,
"deletions": 2,
"name": "Yago",
"email": "yago@yago.me",
"url": "https://github.com/yagop",
"contributions": 161,
"additions": 2543,
"deletions": 1004,
"hireable": true
},
{
"name": "Matthew Brandly",
"email": "matt@brandly.me",
"url": "https://github.com/brandly",
"contributions": 1,
"additions": 1,
"deletions": 1,
"hireable": null
},
{
"name": "Guido García",
"email": "palmerabollo@gmail.com",
"url": "https://github.com/palmerabollo",
"contributions": 1,
"additions": 1,
"deletions": 1,
"hireable": true
},
{
"name": "Patricio López Juri",

@@ -90,7 +117,7 @@ "email": "patricio@lopezjuri.com",

{
"name": "Guido García",
"email": "palmerabollo@gmail.com",
"url": "https://github.com/palmerabollo",
"contributions": 1,
"additions": 1,
"name": "Cristian Baldi",
"email": "bld.cris.96@gmail.com",
"url": "https://github.com/crisbal",
"contributions": 2,
"additions": 26,
"deletions": 1,

@@ -100,8 +127,8 @@ "hireable": true

{
"name": "Matthew Brandly",
"email": "matt@brandly.me",
"url": "https://github.com/brandly",
"contributions": 1,
"additions": 1,
"deletions": 1,
"name": "Vítor Augusto da Silva Vasconcellos",
"email": "vasvas10@gmail.com",
"url": "https://github.com/HeavenVolkoff",
"contributions": 2,
"additions": 12,
"deletions": 0,
"hireable": null

@@ -119,29 +146,2 @@ },

{
"name": "Vítor Augusto da Silva Vasconcellos",
"email": "vasvas10@gmail.com",
"url": "https://github.com/HeavenVolkoff",
"contributions": 2,
"additions": 12,
"deletions": 0,
"hireable": null
},
{
"name": "Sebastian Troć",
"email": "sebastian.troc@gucman.pl",
"url": "https://github.com/SebastianTroc",
"contributions": 1,
"additions": 1,
"deletions": 1,
"hireable": null
},
{
"name": "Yago",
"email": "yago@yago.me",
"url": "https://github.com/yagop",
"contributions": 130,
"additions": 2252,
"deletions": 812,
"hireable": true
},
{
"name": "Ilias Ismanalijev",

@@ -154,4 +154,22 @@ "email": "hello@illyism.com",

"hireable": true
},
{
"name": "Rafael Kr",
"email": null,
"url": "https://github.com/RafaelKr",
"contributions": 3,
"additions": 3,
"deletions": 2,
"hireable": null
},
{
"name": "Riddler",
"email": null,
"url": "https://github.com/Waterloo",
"contributions": 3,
"additions": 64,
"deletions": 2,
"hireable": true
}
]
}

@@ -10,2 +10,3 @@ 'use strict';

var request = require('request');
var qs = require('querystring');
var stream = require('stream');

@@ -281,3 +282,3 @@ var util = require('util');

options: {
filename: fileName,
filename: qs.unescape(fileName),
contentType: mime.lookup(fileName)

@@ -520,12 +521,10 @@ }

TelegramBot.prototype.getFileLink = function(fileId) {
var self = this;
return self.getFile(fileId).then(function (resp) {
return URL.format({
protocol: 'https',
host: 'api.telegram.org',
pathname: '/file/bot' + self.token + '/' + resp.file_path
});
});
return this.getFile(fileId)
.then(function (resp) {
return URL.format({
protocol: 'https',
host: 'api.telegram.org',
pathname: '/file/bot' + this.token + '/' + resp.file_path
});
}.bind(this));
};

@@ -532,0 +531,0 @@

@@ -6,2 +6,3 @@ 'use strict';

var request = require('request');
var util = require('util');
var URL = require('url');

@@ -34,7 +35,4 @@

updates.forEach(function (update, index) {
// If is the latest, update the offset.
if (index === updates.length - 1) {
this.offset = update.update_id;
debug('updated offset: %s', this.offset);
}
this.offset = update.update_id;
debug('updated offset: %s', this.offset);
this.callback(update);

@@ -44,3 +42,3 @@ }.bind(this));

.catch(function (err) {
debug('polling error: %j', err);
debug('polling error: %s', err.message);
throw err;

@@ -83,3 +81,5 @@ })

} catch (err) {
throw new Error('Error parsing Telegram response: %s', resp[0].body);
var text = util.format('Error parsing Telegram response: %s',
resp[0].body);
throw new Error(text);
}

@@ -86,0 +86,0 @@ if (data.ok) {

@@ -5,2 +5,3 @@ 'use strict';

var Telegram = require('../index');
var Promise = require('bluebird');
var request = require('request');

@@ -474,29 +475,24 @@ var should = require('should');

var fileId;
var downloadPath = __dirname;
var downloadPath = __dirname;
// To get a file we have to send some file first
it('should send a photo from file', function (done) {
it('should download a file', function (done) {
var bot = new Telegram(TOKEN);
var photo = __dirname + '/bot.gif';
// Send a file to get the ID
bot.sendPhoto(USERID, photo).then(function (resp) {
resp.should.be.an.instanceOf(Object);
fileId = resp.photo[0].file_id;
done();
var fileId = resp.photo[0].file_id;
bot.downloadFile(fileId, downloadPath)
.then(function (filePath) {
filePath.should.be.an.instanceOf(String);
fs.existsSync(filePath).should.be.true();
fs.unlinkSync(filePath); // Delete file after test
done();
});
});
});
it('should download a file', function (done) {
var bot = new Telegram(TOKEN);
bot.downloadFile(fileId, downloadPath).then(function (filePath) {
filePath.should.be.an.instanceOf(String);
fs.existsSync(filePath).should.be.true();
fs.unlinkSync(filePath); // Delete file after test
done();
});
});
});

@@ -527,21 +523,14 @@

it('should call the callback on polling', function (done) {
function onUpdate (update) {
update.should.be.an.instanceOf(Object);
done();
}
var polling = new TelegramPolling(null, {interval: 500}, onUpdate);
// Not the best way to mock, but it works
polling._getUpdates = function() {
return {
then: function (cb) {
cb([{update_id: 10, message: {}}]);
return this;
},
catch: function () {
return this;
},
finally: function () {}
};
var opts = {interval: 100, timeout: 1};
var polling = new TelegramPolling(TOKEN, opts, function (msg) {
if (msg.update_id === 10) {
done();
}
});
// The second time _getUpdates is called it will return a message
// Really dirty but it works
polling._getUpdates = function () {
return new Promise.resolve([{update_id: 10, message: {}}]);
};
});
});
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc