typescript-telegram-bot-api
Advanced tools
Comparing version 0.1.26 to 0.1.27
import { ReadStream } from 'fs'; | ||
export type InputFile = ReadStream | Buffer | File; | ||
import { FileOptions } from '../index'; | ||
export type InputFile = ReadStream | Buffer | File | FileOptions; |
{ | ||
"type": "commonjs", | ||
"name": "typescript-telegram-bot-api", | ||
"version": "0.1.26", | ||
"version": "0.1.27", | ||
"description": "Telegram Bot API wrapper for Node.js written in TypeScript", | ||
@@ -6,0 +6,0 @@ "repository": "github:Borodin/typescript-telegram-bot-api", |
@@ -49,5 +49,7 @@ # 📦 typescript-telegram-bot-api | ||
For sending files, you can use not only ```'file_id'``` or ```'url'```, but also ```stream.Readable``` or ```Buffer```. | ||
To send files with additional parameters, such as a filename or specific contentType, use the ```FileOptions``` wrapper class. | ||
```typescript | ||
import {createReadStream} from 'fs'; | ||
import {readFile} from 'fs/promises'; | ||
import { TelegramBot, FileOptions } from 'typescript-telegram-bot-api'; | ||
import { createReadStream } from 'fs'; | ||
import { readFile } from 'fs/promises'; | ||
@@ -85,2 +87,15 @@ | ||
// or | ||
await bot.sendPhoto({ | ||
chat_id: chat_id, | ||
photo: new FileOptions( | ||
await readFile('photo.jpg'), { | ||
filename: 'custom_file_name.jpg', | ||
contentType: 'image/jpeg', | ||
} | ||
), | ||
caption: 'FileOptions', | ||
}); | ||
// or in browser | ||
@@ -90,3 +105,3 @@ | ||
chat_id: chat_id, | ||
photo: input.files[0], | ||
photo: input.files[0], // or new File(…) | ||
caption: 'file', | ||
@@ -93,0 +108,0 @@ }); |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
268886
6347
186