mirror of
https://github.com/yagop/node-telegram-bot-api
synced 2025-08-28 21:07:39 +00:00
Merge branch 'HeavenVolkoff-master'
This commit is contained in:
commit
7ebb1d120d
@ -1,4 +1,4 @@
|
||||
[](https://travis-ci.org/yagop/node-telegram-bot-api) [](https://ci.appveyor.com/project/yagop/node-telegram-bot-api/branch/master) [](https://coveralls.io/r/yagop/node-telegram-bot-api?branch=master) [](https://www.bithound.io/github/yagop/node-telegram-bot-api) [](https://telegram.me/node_telegram_bot_api) [](https://telegram.me/Yago_Perez)
|
||||
[](https://travis-ci.org/yagop/node-telegram-bot-api) [](https://ci.appveyor.com/project/yagop/node-telegram-bot-api/branch/master) [](https://coveralls.io/r/yagop/node-telegram-bot-api?branch=master) [](https://www.bithound.io/github/yagop/node-telegram-bot-api) [](https://telegram.me/node_telegram_bot_api) [](https://telegram.me/Yago_Perez)
|
||||
|
||||
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.
|
||||
|
||||
|
@ -25,6 +25,7 @@
|
||||
"bluebird": "^2.10.1",
|
||||
"debug": "^2.2.0",
|
||||
"mime": "^1.3.4",
|
||||
"file-type": "^3.3.1",
|
||||
"request": "^2.64.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
@ -9,6 +9,7 @@ var request = require('request');
|
||||
var stream = require('stream');
|
||||
var util = require('util');
|
||||
var mime = require('mime');
|
||||
var fileType = require('file-type');
|
||||
var path = require('path');
|
||||
var URL = require('url');
|
||||
var fs = require('fs');
|
||||
@ -236,6 +237,16 @@ TelegramBot.prototype._formatSendData = function (type, data) {
|
||||
contentType: mime.lookup(fileName)
|
||||
}
|
||||
};
|
||||
} else if(util.isBuffer(data)){
|
||||
var filetype = fileType(data);
|
||||
formData = {};
|
||||
formData[type] = {
|
||||
value: data,
|
||||
options: {
|
||||
filename: 'data.' + filetype.ext,
|
||||
contentType: filetype.mime
|
||||
}
|
||||
};
|
||||
} else if (fs.existsSync(data)) {
|
||||
fileName = path.basename(data);
|
||||
formData = {};
|
||||
|
Loading…
x
Reference in New Issue
Block a user