UNPKG

2.44 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3exports.fromFileId = exports.fromURL = exports.fromURLStream = exports.fromReadableStream = exports.fromBuffer = exports.fromLocalFile = void 0;
4/**
5 * The local file specified by path will be uploaded to Telegram using multipart/form-data.
6 *
7 * 10 MB max size for photos, 50 MB for other files.
8 */
9// prettier-ignore
10const fromLocalFile = (path, filename) => ({ source: path, filename });
11exports.fromLocalFile = fromLocalFile;
12/**
13 * The buffer will be uploaded as file to Telegram using multipart/form-data.
14 *
15 * 10 MB max size for photos, 50 MB for other files.
16 */
17// prettier-ignore
18const fromBuffer = (buffer, filename) => ({ source: buffer, filename });
19exports.fromBuffer = fromBuffer;
20/**
21 * Contents of the stream will be uploaded as file to Telegram using multipart/form-data.
22 *
23 * 10 MB max size for photos, 50 MB for other files.
24 */
25// prettier-ignore
26const fromReadableStream = (stream, filename) => ({ source: stream, filename });
27exports.fromReadableStream = fromReadableStream;
28/**
29 * Contents of the URL will be streamed to Telegram.
30 *
31 * 10 MB max size for photos, 50 MB for other files.
32 */
33// prettier-ignore
34const fromURLStream = (url, filename) => ({ url: url.toString(), filename });
35exports.fromURLStream = fromURLStream;
36/**
37 * Provide Telegram with an HTTP URL for the file to be sent.
38 * Telegram will download and send the file.
39 *
40 * * The target file must have the correct MIME type (e.g., audio/mpeg for `sendAudio`, etc.).
41 * * `sendDocument` with URL will currently only work for GIF, PDF and ZIP files.
42 * * To use `sendVoice`, the file must have the type audio/ogg and be no more than 1MB in size.
43 * 1-20MB voice notes will be sent as files.
44 *
45 * 5 MB max size for photos and 20 MB max for other types of content.
46 */
47const fromURL = (url) => url.toString();
48exports.fromURL = fromURL;
49/**
50 * If the file is already stored somewhere on the Telegram servers, you don't need to reupload it:
51 * each file object has a file_id field, simply pass this file_id as a parameter instead of uploading.
52 *
53 * It is not possible to change the file type when resending by file_id.
54 *
55 * It is not possible to resend thumbnails using file_id.
56 * They have to be uploaded using one of the other Input methods.
57 *
58 * There are no limits for files sent this way.
59 */
60const fromFileId = (fileId) => fileId;
61exports.fromFileId = fromFileId;