From 2b94493eb54b0bcb60fef6274c118957a22a01d0 Mon Sep 17 00:00:00 2001 From: Yago Date: Fri, 1 Jan 2016 22:00:41 +0100 Subject: [PATCH 1/3] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index fea7316..cb402c0 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -[![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) 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. From 9e2a8321e9d02381973c8b3744fb44bce548a1f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADtor=20Augusto=20da=20Silva=20Vasconcellos?= Date: Sun, 3 Jan 2016 00:19:06 -0200 Subject: [PATCH 2/3] Add Buffer support to _formatSendData --- src/telegram.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/telegram.js b/src/telegram.js index cc29788..d7ed6dd 100644 --- a/src/telegram.js +++ b/src/telegram.js @@ -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 = {}; From cd2867edfdfdd03ce921d15cecd1c60d07660b3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADtor=20Augusto=20da=20Silva=20Vasconcellos?= Date: Sun, 3 Jan 2016 00:20:35 -0200 Subject: [PATCH 3/3] Add file-type as dependency --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index e914159..3563409 100644 --- a/package.json +++ b/package.json @@ -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": {