node-telegram-bot-api
Advanced tools
Comparing version 0.17.1 to 0.18.0
{ | ||
"name": "node-telegram-bot-api", | ||
"version": "0.17.1", | ||
"version": "0.18.0", | ||
"description": "Telegram Bot API", | ||
@@ -28,2 +28,3 @@ "main": "index.js", | ||
"mime": "^1.3.4", | ||
"file-type": "^3.3.1", | ||
"request": "^2.64.0" | ||
@@ -51,17 +52,26 @@ }, | ||
{ | ||
"name": "Guido García", | ||
"email": "palmerabollo@gmail.com", | ||
"url": "https://github.com/palmerabollo", | ||
"contributions": 1, | ||
"additions": 1, | ||
"deletions": 1, | ||
"name": "Ivan Skorokhodov", | ||
"email": "iskorokhodov@gmail.com", | ||
"url": "https://github.com/universome", | ||
"contributions": 3, | ||
"additions": 219, | ||
"deletions": 5, | ||
"hireable": null | ||
}, | ||
{ | ||
"name": "Riddler", | ||
"email": null, | ||
"url": "https://github.com/Waterloo", | ||
"contributions": 3, | ||
"additions": 64, | ||
"deletions": 2, | ||
"hireable": true | ||
}, | ||
{ | ||
"name": "Yago", | ||
"email": "yago@yago.me", | ||
"url": "https://github.com/yagop", | ||
"contributions": 99, | ||
"additions": 1685, | ||
"deletions": 504, | ||
"name": "Patricio López Juri", | ||
"email": "patricio@lopezjuri.com", | ||
"url": "https://github.com/mrpatiwi", | ||
"contributions": 1, | ||
"additions": 49, | ||
"deletions": 2, | ||
"hireable": true | ||
@@ -79,38 +89,56 @@ }, | ||
{ | ||
"name": "Sebastian Troć", | ||
"email": "sebastian.troc@gucman.pl", | ||
"url": "https://github.com/SebastianTroc", | ||
"name": "Guido García", | ||
"email": "palmerabollo@gmail.com", | ||
"url": "https://github.com/palmerabollo", | ||
"contributions": 1, | ||
"additions": 1, | ||
"deletions": 1, | ||
"hireable": null | ||
"hireable": true | ||
}, | ||
{ | ||
"name": "Patricio López Juri", | ||
"email": "lopezjuripatricio@gmail.com", | ||
"url": "https://github.com/mrpatiwi", | ||
"name": "Matthew Brandly", | ||
"email": "matt@brandly.me", | ||
"url": "https://github.com/brandly", | ||
"contributions": 1, | ||
"additions": 49, | ||
"deletions": 2, | ||
"hireable": true | ||
"additions": 1, | ||
"deletions": 1, | ||
"hireable": null | ||
}, | ||
{ | ||
"name": "Riddler", | ||
"name": "Rey", | ||
"email": null, | ||
"url": "https://github.com/Waterloo", | ||
"contributions": 3, | ||
"additions": 64, | ||
"deletions": 2, | ||
"hireable": true | ||
"url": "https://github.com/reyy", | ||
"contributions": 2, | ||
"additions": 34, | ||
"deletions": 25, | ||
"hireable": null | ||
}, | ||
{ | ||
"name": "Ivan Skorokhodov", | ||
"email": "iskorokhodov@gmail.com", | ||
"url": "https://github.com/universome", | ||
"contributions": 3, | ||
"additions": 219, | ||
"deletions": 5, | ||
"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", | ||
@@ -117,0 +145,0 @@ "email": "hello@illyism.com", |
@@ -1,2 +0,2 @@ | ||
[![Build Status](https://travis-ci.org/yagop/node-telegram-bot-api.svg?branch=master)](https://travis-ci.org/yagop/node-telegram-bot-api) [![Build status](https://ci.appveyor.com/api/projects/status/ujko6bsum3g5msjh/branch/master?svg=true)](https://ci.appveyor.com/project/yagop/node-telegram-bot-api/branch/master) [![Coverage Status](https://coveralls.io/repos/yagop/node-telegram-bot-api/badge.svg?branch=master)](https://coveralls.io/r/yagop/node-telegram-bot-api?branch=master) [![bitHound Score](https://www.bithound.io/github/yagop/node-telegram-bot-api/badges/score.svg)](https://www.bithound.io/github/yagop/node-telegram-bot-api) [![https://telegram.me/node_telegram_bot_api](https://img.shields.io/badge/Telegram-node__telegram__bot__api-blue.svg)](https://telegram.me/node_telegram_bot_api) [![https://telegram.me/Yago_Perez](https://img.shields.io/badge/Telegram-Yago__Perez-blue.svg)](https://telegram.me/Yago_Perez) | ||
[![Build Status](https://travis-ci.org/yagop/node-telegram-bot-api.svg?branch=master)](https://travis-ci.org/yagop/node-telegram-bot-api) [![Build status](https://ci.appveyor.com/api/projects/status/ujko6bsum3g5msjh/branch/master?svg=true)](https://ci.appveyor.com/project/yagop/node-telegram-bot-api/branch/master) [![Coverage Status](https://coveralls.io/repos/yagop/node-telegram-bot-api/badge.svg?branch=master)](https://coveralls.io/r/yagop/node-telegram-bot-api?branch=master) [![bitHound Score](https://www.bithound.io/github/yagop/node-telegram-bot-api/badges/score.svg)](https://www.bithound.io/github/yagop/node-telegram-bot-api) [![https://telegram.me/node_telegram_bot_api](https://img.shields.io/badge/💬 Telegram-node__telegram__bot__api-blue.svg)](https://telegram.me/node_telegram_bot_api) [![https://telegram.me/Yago_Perez](https://img.shields.io/badge/💬 Telegram-Yago__Perez-blue.svg)](https://telegram.me/Yago_Perez) | ||
@@ -16,2 +16,3 @@ Node.js module to interact with official [Telegram Bot API](https://core.telegram.org/bots/api). A bot token is needed, to obtain one, talk to [@botfather](https://telegram.me/BotFather) and create a new bot. | ||
// Matches /echo [whatever] | ||
bot.onText(/\/echo (.+)/, function (msg, match) { | ||
@@ -66,5 +67,5 @@ var fromId = msg.from.id; | ||
* [.sendAudio(chatId, audio, [options])](#TelegramBot+sendAudio) ⇒ <code>Promise</code> | ||
* [.sendDocument(chatId, A, [options])](#TelegramBot+sendDocument) ⇒ <code>Promise</code> | ||
* [.sendSticker(chatId, A, [options])](#TelegramBot+sendSticker) ⇒ <code>Promise</code> | ||
* [.sendVideo(chatId, A, [options])](#TelegramBot+sendVideo) ⇒ <code>Promise</code> | ||
* [.sendDocument(chatId, doc, [options])](#TelegramBot+sendDocument) ⇒ <code>Promise</code> | ||
* [.sendSticker(chatId, sticker, [options])](#TelegramBot+sendSticker) ⇒ <code>Promise</code> | ||
* [.sendVideo(chatId, video, [options])](#TelegramBot+sendVideo) ⇒ <code>Promise</code> | ||
* [.sendVoice(chatId, voice, [options])](#TelegramBot+sendVoice) ⇒ <code>Promise</code> | ||
@@ -164,3 +165,3 @@ * [.sendChatAction(chatId, action)](#TelegramBot+sendChatAction) ⇒ <code>Promise</code> | ||
| chatId | <code>Number</code> | <code>String</code> | Unique identifier for the message recipient | | ||
| photo | <code>String</code> | <code>stream.Stream</code> | A file path or a Stream. Can also be a `file_id` previously uploaded | | ||
| photo | <code>String</code> | <code>stream.Stream</code> | <code>Buffer</code> | A file path or a Stream. Can also be a `file_id` previously uploaded | | ||
| [options] | <code>Object</code> | Additional Telegram query options | | ||
@@ -178,7 +179,7 @@ | ||
| chatId | <code>Number</code> | <code>String</code> | Unique identifier for the message recipient | | ||
| audio | <code>String</code> | <code>stream.Stream</code> | A file path or a Stream. Can also be a `file_id` previously uploaded. | | ||
| audio | <code>String</code> | <code>stream.Stream</code> | <code>Buffer</code> | A file path, Stream or Buffer. Can also be a `file_id` previously uploaded. | | ||
| [options] | <code>Object</code> | Additional Telegram query options | | ||
<a name="TelegramBot+sendDocument"></a> | ||
### telegramBot.sendDocument(chatId, A, [options]) ⇒ <code>Promise</code> | ||
### telegramBot.sendDocument(chatId, doc, [options]) ⇒ <code>Promise</code> | ||
Send Document | ||
@@ -192,7 +193,7 @@ | ||
| chatId | <code>Number</code> | <code>String</code> | Unique identifier for the message recipient | | ||
| A | <code>String</code> | <code>stream.Stream</code> | file path or a Stream. Can also be a `file_id` previously uploaded. | | ||
| doc | <code>String</code> | <code>stream.Stream</code> | <code>Buffer</code> | A file path, Stream or Buffer. Can also be a `file_id` previously uploaded. | | ||
| [options] | <code>Object</code> | Additional Telegram query options | | ||
<a name="TelegramBot+sendSticker"></a> | ||
### telegramBot.sendSticker(chatId, A, [options]) ⇒ <code>Promise</code> | ||
### telegramBot.sendSticker(chatId, sticker, [options]) ⇒ <code>Promise</code> | ||
Send .webp stickers. | ||
@@ -206,7 +207,7 @@ | ||
| chatId | <code>Number</code> | <code>String</code> | Unique identifier for the message recipient | | ||
| A | <code>String</code> | <code>stream.Stream</code> | file path or a Stream. Can also be a `file_id` previously uploaded. | | ||
| sticker | <code>String</code> | <code>stream.Stream</code> | <code>Buffer</code> | A file path, Stream or Buffer. Can also be a `file_id` previously uploaded. Stickers are WebP format files. | | ||
| [options] | <code>Object</code> | Additional Telegram query options | | ||
<a name="TelegramBot+sendVideo"></a> | ||
### telegramBot.sendVideo(chatId, A, [options]) ⇒ <code>Promise</code> | ||
### telegramBot.sendVideo(chatId, video, [options]) ⇒ <code>Promise</code> | ||
Use this method to send video files, Telegram clients support mp4 videos (other formats may be sent as Document). | ||
@@ -220,3 +221,3 @@ | ||
| chatId | <code>Number</code> | <code>String</code> | Unique identifier for the message recipient | | ||
| A | <code>String</code> | <code>stream.Stream</code> | file path or a Stream. Can also be a `file_id` previously uploaded. | | ||
| video | <code>String</code> | <code>stream.Stream</code> | A file path or Stream. Can also be a `file_id` previously uploaded. | | ||
| [options] | <code>Object</code> | Additional Telegram query options | | ||
@@ -234,3 +235,3 @@ | ||
| chatId | <code>Number</code> | <code>String</code> | Unique identifier for the message recipient | | ||
| voice | <code>String</code> | <code>stream.Stream</code> | A file path or a Stream. Can also be a `file_id` previously uploaded. | | ||
| voice | <code>String</code> | <code>stream.Stream</code> | <code>Buffer</code> | A file path, Stream or Buffer. Can also be a `file_id` previously uploaded. | | ||
| [options] | <code>Object</code> | Additional Telegram query options | | ||
@@ -237,0 +238,0 @@ |
@@ -7,2 +7,3 @@ 'use strict'; | ||
var EventEmitter = require('events').EventEmitter; | ||
var fileType = require('file-type'); | ||
var Promise = require('bluebird'); | ||
@@ -240,2 +241,15 @@ var request = require('request'); | ||
}; | ||
} else if (Buffer.isBuffer(data)) { | ||
var filetype = fileType(data); | ||
if (!filetype) { | ||
throw new Error('Unsupported Buffer file type'); | ||
} | ||
formData = {}; | ||
formData[type] = { | ||
value: data, | ||
options: { | ||
filename: 'data.' + filetype.ext, | ||
contentType: filetype.mime | ||
} | ||
}; | ||
} else if (fs.existsSync(data)) { | ||
@@ -260,3 +274,3 @@ fileName = path.basename(data); | ||
* @param {Number|String} chatId Unique identifier for the message recipient | ||
* @param {String|stream.Stream} photo A file path or a Stream. Can | ||
* @param {String|stream.Stream|Buffer} photo A file path or a Stream. Can | ||
* also be a `file_id` previously uploaded | ||
@@ -281,4 +295,4 @@ * @param {Object} [options] Additional Telegram query options | ||
* @param {Number|String} chatId Unique identifier for the message recipient | ||
* @param {String|stream.Stream} audio A file path or a Stream. Can | ||
* also be a `file_id` previously uploaded. | ||
* @param {String|stream.Stream|Buffer} audio A file path, Stream or Buffer. | ||
* Can also be a `file_id` previously uploaded. | ||
* @param {Object} [options] Additional Telegram query options | ||
@@ -302,4 +316,4 @@ * @return {Promise} | ||
* @param {Number|String} chatId Unique identifier for the message recipient | ||
* @param {String|stream.Stream} A file path or a Stream. Can | ||
* also be a `file_id` previously uploaded. | ||
* @param {String|stream.Stream|Buffer} doc A file path, Stream or Buffer. | ||
* Can also be a `file_id` previously uploaded. | ||
* @param {Object} [options] Additional Telegram query options | ||
@@ -323,4 +337,4 @@ * @return {Promise} | ||
* @param {Number|String} chatId Unique identifier for the message recipient | ||
* @param {String|stream.Stream} A file path or a Stream. Can | ||
* also be a `file_id` previously uploaded. | ||
* @param {String|stream.Stream|Buffer} sticker A file path, Stream or Buffer. | ||
* Can also be a `file_id` previously uploaded. Stickers are WebP format files. | ||
* @param {Object} [options] Additional Telegram query options | ||
@@ -344,4 +358,4 @@ * @return {Promise} | ||
* @param {Number|String} chatId Unique identifier for the message recipient | ||
* @param {String|stream.Stream} A file path or a Stream. Can | ||
* also be a `file_id` previously uploaded. | ||
* @param {String|stream.Stream} video A file path or Stream. | ||
* Can also be a `file_id` previously uploaded. | ||
* @param {Object} [options] Additional Telegram query options | ||
@@ -365,4 +379,4 @@ * @return {Promise} | ||
* @param {Number|String} chatId Unique identifier for the message recipient | ||
* @param {String|stream.Stream} voice A file path or a Stream. Can | ||
* also be a `file_id` previously uploaded. | ||
* @param {String|stream.Stream|Buffer} voice A file path, Stream or Buffer. | ||
* Can also be a `file_id` previously uploaded. | ||
* @param {Object} [options] Additional Telegram query options | ||
@@ -369,0 +383,0 @@ * @return {Promise} |
@@ -200,2 +200,11 @@ 'use strict'; | ||
}); | ||
it('should send a photo from a Buffer', function (done) { | ||
var bot = new Telegram(TOKEN); | ||
var photo = fs.readFileSync(__dirname+'/bot.gif'); | ||
bot.sendPhoto(USERID, photo).then(function (resp) { | ||
resp.should.be.an.instanceOf(Object); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
@@ -264,2 +273,11 @@ | ||
}); | ||
it('should send a document from a Buffer', function (done) { | ||
var bot = new Telegram(TOKEN); | ||
var document = fs.readFileSync(__dirname+'/bot.gif'); | ||
bot.sendDocument(USERID, document).then(function (resp) { | ||
resp.should.be.an.instanceOf(Object); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
@@ -305,2 +323,11 @@ | ||
}); | ||
it('should send a sticker from a Buffer', function (done) { | ||
var bot = new Telegram(TOKEN); | ||
var sticker = fs.readFileSync(__dirname+'/sticker.webp'); | ||
bot.sendDocument(USERID, sticker).then(function (resp) { | ||
resp.should.be.an.instanceOf(Object); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
@@ -346,2 +373,13 @@ | ||
}); | ||
/* Currently unsupported (https://github.com/sindresorhus/file-type/pull/44) | ||
it('should send a video from a Buffer', function (done) { | ||
var bot = new Telegram(TOKEN); | ||
var video = fs.readFileSync(__dirname+'/video.mp4'); | ||
bot.sendVideo(USERID, video).then(function (resp) { | ||
resp.should.be.an.instanceOf(Object); | ||
done(); | ||
}); | ||
}); | ||
*/ | ||
}); | ||
@@ -348,0 +386,0 @@ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
565969
1183
330
5
+ Addedfile-type@^3.3.1
+ Addedfile-type@3.9.0(transitive)