mirror of
https://github.com/yagop/node-telegram-bot-api
synced 2025-08-29 21:37:58 +00:00
Closes #204: Fix handling fs.readStream.path if it's a buffer
This commit is contained in:
commit
bf5ca1340b
@ -301,7 +301,7 @@ class TelegramBot extends EventEmitter {
|
|||||||
let fileName;
|
let fileName;
|
||||||
let fileId;
|
let fileId;
|
||||||
if (data instanceof stream.Stream) {
|
if (data instanceof stream.Stream) {
|
||||||
fileName = URL.parse(path.basename(data.path)).pathname;
|
fileName = URL.parse(path.basename(data.path.toString())).pathname;
|
||||||
formData = {};
|
formData = {};
|
||||||
formData[type] = {
|
formData[type] = {
|
||||||
value: data,
|
value: data,
|
||||||
|
@ -200,6 +200,16 @@ describe('Telegram', function telegramSuite() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('#_formatSendData', function _formatSendData() {
|
||||||
|
it('should handle buffer path from fs.readStream', function test() {
|
||||||
|
const bot = new Telegram(TOKEN);
|
||||||
|
const photo = fs.createReadStream(Buffer.from(`${__dirname}/bot.gif`));
|
||||||
|
return bot.sendPhoto(USERID, photo).then(resp => {
|
||||||
|
assert.ok(is.object(resp));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe('#sendPhoto', function sendPhotoSuite() {
|
describe('#sendPhoto', function sendPhotoSuite() {
|
||||||
let photoId;
|
let photoId;
|
||||||
it('should send a photo from file', function test() {
|
it('should send a photo from file', function test() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user