grammy-tools 1.36.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +339 -0
  3. package/out/bot.d.ts +314 -0
  4. package/out/bot.js +669 -0
  5. package/out/composer.d.ts +764 -0
  6. package/out/composer.js +704 -0
  7. package/out/context.d.ts +1618 -0
  8. package/out/context.js +1976 -0
  9. package/out/convenience/constants.d.ts +98 -0
  10. package/out/convenience/constants.js +37 -0
  11. package/out/convenience/frameworks.d.ts +216 -0
  12. package/out/convenience/frameworks.js +370 -0
  13. package/out/convenience/inline_query.d.ts +401 -0
  14. package/out/convenience/inline_query.js +461 -0
  15. package/out/convenience/input_media.d.ts +72 -0
  16. package/out/convenience/input_media.js +82 -0
  17. package/out/convenience/keyboard.d.ts +763 -0
  18. package/out/convenience/keyboard.js +935 -0
  19. package/out/convenience/session.d.ts +345 -0
  20. package/out/convenience/session.js +455 -0
  21. package/out/convenience/webhook.d.ts +59 -0
  22. package/out/convenience/webhook.js +80 -0
  23. package/out/core/api.d.ts +1628 -0
  24. package/out/core/api.js +1907 -0
  25. package/out/core/client.d.ts +180 -0
  26. package/out/core/client.js +226 -0
  27. package/out/core/error.d.ts +53 -0
  28. package/out/core/error.js +87 -0
  29. package/out/core/payload.d.ts +39 -0
  30. package/out/core/payload.js +199 -0
  31. package/out/filter.d.ts +959 -0
  32. package/out/filter.js +378 -0
  33. package/out/mod.d.ts +14 -0
  34. package/out/mod.js +43 -0
  35. package/out/platform.node.d.ts +16 -0
  36. package/out/platform.node.js +43 -0
  37. package/out/shim.node.d.ts +2 -0
  38. package/out/shim.node.js +7 -0
  39. package/out/types.d.ts +1 -0
  40. package/out/types.js +17 -0
  41. package/out/types.node.d.ts +78 -0
  42. package/out/types.node.js +107 -0
  43. package/out/web.d.ts +1 -0
  44. package/out/web.mjs +5172 -0
  45. package/package.json +71 -0
@@ -0,0 +1,461 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.InlineQueryResultBuilder = void 0;
4
+ function inputMessage(queryTemplate) {
5
+ return {
6
+ ...queryTemplate,
7
+ ...inputMessageMethods(queryTemplate),
8
+ };
9
+ }
10
+ function inputMessageMethods(queryTemplate) {
11
+ return {
12
+ text(message_text, options = {}) {
13
+ const content = {
14
+ message_text,
15
+ ...options,
16
+ };
17
+ return { ...queryTemplate, input_message_content: content };
18
+ },
19
+ location(latitude, longitude, options = {}) {
20
+ const content = {
21
+ latitude,
22
+ longitude,
23
+ ...options,
24
+ };
25
+ return { ...queryTemplate, input_message_content: content };
26
+ },
27
+ venue(title, latitude, longitude, address, options) {
28
+ const content = {
29
+ title,
30
+ latitude,
31
+ longitude,
32
+ address,
33
+ ...options,
34
+ };
35
+ return { ...queryTemplate, input_message_content: content };
36
+ },
37
+ contact(first_name, phone_number, options = {}) {
38
+ const content = {
39
+ first_name,
40
+ phone_number,
41
+ ...options,
42
+ };
43
+ return { ...queryTemplate, input_message_content: content };
44
+ },
45
+ invoice(title, description, payload, provider_token, currency, prices, options = {}) {
46
+ const content = {
47
+ title,
48
+ description,
49
+ payload,
50
+ provider_token,
51
+ currency,
52
+ prices,
53
+ ...options,
54
+ };
55
+ return { ...queryTemplate, input_message_content: content };
56
+ },
57
+ };
58
+ }
59
+ /**
60
+ * Holds a number of helper methods for building `InlineQueryResult*` objects.
61
+ *
62
+ * For example, letting the user pick one out of three photos can be done like
63
+ * this.
64
+ *
65
+ * ```ts
66
+ * const results = [
67
+ * InlineQueryResultBuilder.photo('id0', 'https://grammy.dev/images/Y.png'),
68
+ * InlineQueryResultBuilder.photo('id1', 'https://grammy.dev/images/Y.png'),
69
+ * InlineQueryResultBuilder.photo('id2', 'https://grammy.dev/images/Y.png'),
70
+ * ];
71
+ * await ctx.answerInlineQuery(results)
72
+ * ```
73
+ *
74
+ * If you want the message content to be different from the content in the
75
+ * inline query result, you can perform another method call on the resulting
76
+ * objects.
77
+ *
78
+ * ```ts
79
+ * const results = [
80
+ * InlineQueryResultBuilder.photo("id0", "https://grammy.dev/images/Y.png")
81
+ * .text("Picked photo 0!"),
82
+ * InlineQueryResultBuilder.photo("id1", "https://grammy.dev/images/Y.png")
83
+ * .text("Picked photo 1!"),
84
+ * InlineQueryResultBuilder.photo("id2", "https://grammy.dev/images/Y.png")
85
+ * .text("Picked photo 2!"),
86
+ * ];
87
+ * await ctx.answerInlineQuery(results)
88
+ * ```
89
+ *
90
+ * Be sure to check the
91
+ * [documentation](https://core.telegram.org/bots/api#inline-mode) on inline
92
+ * mode.
93
+ */
94
+ exports.InlineQueryResultBuilder = {
95
+ /**
96
+ * Builds an InlineQueryResultArticle object as specified by
97
+ * https://core.telegram.org/bots/api#inlinequeryresultarticle. Requires you
98
+ * to specify the actual message content by calling another function on the
99
+ * object returned from this method.
100
+ *
101
+ * @param id Unique identifier for this result, 1-64 Bytes
102
+ * @param title Title of the result
103
+ * @param options Remaining options
104
+ */
105
+ article(id, title, options = {}) {
106
+ return inputMessageMethods({ type: "article", id, title, ...options });
107
+ },
108
+ /**
109
+ * Builds an InlineQueryResultAudio object as specified by
110
+ * https://core.telegram.org/bots/api#inlinequeryresultaudio.
111
+ *
112
+ * @param id Unique identifier for this result, 1-64 bytes
113
+ * @param title Title
114
+ * @param audio_url A valid URL for the audio file
115
+ * @param options Remaining options
116
+ */
117
+ audio(id, title, audio_url, options = {}) {
118
+ return inputMessage({
119
+ type: "audio",
120
+ id,
121
+ title,
122
+ audio_url: typeof audio_url === "string"
123
+ ? audio_url
124
+ : audio_url.href,
125
+ ...options,
126
+ });
127
+ },
128
+ /**
129
+ * Builds an InlineQueryResultCachedAudio object as specified by
130
+ * https://core.telegram.org/bots/api#inlinequeryresultcachedaudio.
131
+ *
132
+ * @param id Unique identifier for this result, 1-64 bytes
133
+ * @param audio_file_id A valid file identifier for the audio file
134
+ * @param options Remaining options
135
+ */
136
+ audioCached(id, audio_file_id, options = {}) {
137
+ return inputMessage({ type: "audio", id, audio_file_id, ...options });
138
+ },
139
+ /**
140
+ * Builds an InlineQueryResultContact object as specified by
141
+ * https://core.telegram.org/bots/api#inlinequeryresultcontact.
142
+ *
143
+ * @param id Unique identifier for this result, 1-64 Bytes
144
+ * @param phone_number Contact's phone number
145
+ * @param first_name Contact's first name
146
+ * @param options Remaining options
147
+ */
148
+ contact(id, phone_number, first_name, options = {}) {
149
+ return inputMessage({ type: "contact", id, phone_number, first_name, ...options });
150
+ },
151
+ /**
152
+ * Builds an InlineQueryResultDocument object as specified by
153
+ * https://core.telegram.org/bots/api#inlinequeryresultdocument with
154
+ * mime_type set to "application/pdf".
155
+ *
156
+ * @param id Unique identifier for this result, 1-64 bytes
157
+ * @param title Title for the result
158
+ * @param document_url A valid URL for the file
159
+ * @param options Remaining options
160
+ */
161
+ documentPdf(id, title, document_url, options = {}) {
162
+ return inputMessage({
163
+ type: "document",
164
+ mime_type: "application/pdf",
165
+ id,
166
+ title,
167
+ document_url: typeof document_url === "string"
168
+ ? document_url
169
+ : document_url.href,
170
+ ...options,
171
+ });
172
+ },
173
+ /**
174
+ * Builds an InlineQueryResultDocument object as specified by
175
+ * https://core.telegram.org/bots/api#inlinequeryresultdocument with
176
+ * mime_type set to "application/zip".
177
+ *
178
+ * @param id Unique identifier for this result, 1-64 bytes
179
+ * @param title Title for the result
180
+ * @param document_url A valid URL for the file
181
+ * @param options Remaining options
182
+ */
183
+ documentZip(id, title, document_url, options = {}) {
184
+ return inputMessage({
185
+ type: "document",
186
+ mime_type: "application/zip",
187
+ id,
188
+ title,
189
+ document_url: typeof document_url === "string"
190
+ ? document_url
191
+ : document_url.href,
192
+ ...options,
193
+ });
194
+ },
195
+ /**
196
+ * Builds an InlineQueryResultCachedDocument object as specified by
197
+ * https://core.telegram.org/bots/api#inlinequeryresultcacheddocument.
198
+ *
199
+ * @param id Unique identifier for this result, 1-64 bytes
200
+ * @param title Title for the result
201
+ * @param document_file_id A valid file identifier for the file
202
+ * @param options Remaining options
203
+ */
204
+ documentCached(id, title, document_file_id, options = {}) {
205
+ return inputMessage({ type: "document", id, title, document_file_id, ...options });
206
+ },
207
+ /**
208
+ * Builds an InlineQueryResultGame object as specified by
209
+ * https://core.telegram.org/bots/api#inlinequeryresultgame.
210
+ *
211
+ * @param id Unique identifier for this result, 1-64 bytes
212
+ * @param game_short_name Short name of the game
213
+ * @param options Remaining options
214
+ */
215
+ game(id, game_short_name, options = {}) {
216
+ return { type: "game", id, game_short_name, ...options };
217
+ },
218
+ /**
219
+ * Builds an InlineQueryResultGif object as specified by
220
+ * https://core.telegram.org/bots/api#inlinequeryresultgif.
221
+ *
222
+ * @param id Unique identifier for this result, 1-64 bytes
223
+ * @param gif_url A valid URL for the GIF file. File size must not exceed 1MB
224
+ * @param thumbnail_url URL of the static (JPEG or GIF) or animated (MPEG4) thumbnail for the result
225
+ * @param options Remaining options
226
+ */
227
+ gif(id, gif_url, thumbnail_url, options = {}) {
228
+ return inputMessage({
229
+ type: "gif",
230
+ id,
231
+ gif_url: typeof gif_url === "string" ? gif_url : gif_url.href,
232
+ thumbnail_url: typeof thumbnail_url === "string"
233
+ ? thumbnail_url
234
+ : thumbnail_url.href,
235
+ ...options,
236
+ });
237
+ },
238
+ /**
239
+ * Builds an InlineQueryResultCachedGif object as specified by
240
+ * https://core.telegram.org/bots/api#inlinequeryresultcachedgif.
241
+ *
242
+ * @param id Unique identifier for this result, 1-64 bytes
243
+ * @param gif_file_id A valid file identifier for the GIF file
244
+ * @param options Remaining options
245
+ */
246
+ gifCached(id, gif_file_id, options = {}) {
247
+ return inputMessage({ type: "gif", id, gif_file_id, ...options });
248
+ },
249
+ /**
250
+ * Builds an InlineQueryResultLocation object as specified by
251
+ * https://core.telegram.org/bots/api#inlinequeryresultlocation.
252
+ *
253
+ * @param id Unique identifier for this result, 1-64 Bytes
254
+ * @param title Location title
255
+ * @param latitude Location latitude in degrees
256
+ * @param longitude Location longitude in degrees
257
+ * @param options Remaining options
258
+ */
259
+ location(id, title, latitude, longitude, options = {}) {
260
+ return inputMessage({ type: "location", id, title, latitude, longitude, ...options });
261
+ },
262
+ /**
263
+ * Builds an InlineQueryResultMpeg4Gif object as specified by
264
+ * https://core.telegram.org/bots/api#inlinequeryresultmpeg4gif.
265
+ *
266
+ * @param id Unique identifier for this result, 1-64 bytes
267
+ * @param mpeg4_url A valid URL for the MPEG4 file. File size must not exceed 1MB
268
+ * @param thumbnail_url URL of the static (JPEG or GIF) or animated (MPEG4) thumbnail for the result
269
+ * @param options Remaining options
270
+ */
271
+ mpeg4gif(id, mpeg4_url, thumbnail_url, options = {}) {
272
+ return inputMessage({
273
+ type: "mpeg4_gif",
274
+ id,
275
+ mpeg4_url: typeof mpeg4_url === "string"
276
+ ? mpeg4_url
277
+ : mpeg4_url.href,
278
+ thumbnail_url: typeof thumbnail_url === "string"
279
+ ? thumbnail_url
280
+ : thumbnail_url.href,
281
+ ...options,
282
+ });
283
+ },
284
+ /**
285
+ * Builds an InlineQueryResultCachedMpeg4Gif object as specified by
286
+ * https://core.telegram.org/bots/api#inlinequeryresultcachedmpeg4gif.
287
+ *
288
+ * @param id Unique identifier for this result, 1-64 bytes
289
+ * @param mpeg4_file_id A valid file identifier for the MPEG4 file
290
+ * @param options Remaining options
291
+ */
292
+ mpeg4gifCached(id, mpeg4_file_id, options = {}) {
293
+ return inputMessage({ type: "mpeg4_gif", id, mpeg4_file_id, ...options });
294
+ },
295
+ /**
296
+ * Builds an InlineQueryResultPhoto object as specified by
297
+ * https://core.telegram.org/bots/api#inlinequeryresultphoto with the
298
+ * thumbnail defaulting to the photo itself.
299
+ *
300
+ * @param id Unique identifier for this result, 1-64 bytes
301
+ * @param photo_url A valid URL of the photo. Photo must be in JPEG format. Photo size must not exceed 5MB
302
+ * @param options Remaining options
303
+ */
304
+ photo(id, photo_url, options = {
305
+ thumbnail_url: typeof photo_url === "string"
306
+ ? photo_url
307
+ : photo_url.href,
308
+ }) {
309
+ return inputMessage({
310
+ type: "photo",
311
+ id,
312
+ photo_url: typeof photo_url === "string"
313
+ ? photo_url
314
+ : photo_url.href,
315
+ ...options,
316
+ });
317
+ },
318
+ /**
319
+ * Builds an InlineQueryResultCachedPhoto object as specified by
320
+ * https://core.telegram.org/bots/api#inlinequeryresultcachedphoto.
321
+ *
322
+ * @param id Unique identifier for this result, 1-64 bytes
323
+ * @param photo_file_id A valid file identifier of the photo
324
+ * @param options Remaining options
325
+ */
326
+ photoCached(id, photo_file_id, options = {}) {
327
+ return inputMessage({ type: "photo", id, photo_file_id, ...options });
328
+ },
329
+ /**
330
+ * Builds an InlineQueryResultCachedSticker object as specified by
331
+ * https://core.telegram.org/bots/api#inlinequeryresultcachedsticker.
332
+ *
333
+ * @param id Unique identifier for this result, 1-64 bytes
334
+ * @param sticker_file_id A valid file identifier of the sticker
335
+ * @param options Remaining options
336
+ */
337
+ stickerCached(id, sticker_file_id, options = {}) {
338
+ return inputMessage({ type: "sticker", id, sticker_file_id, ...options });
339
+ },
340
+ /**
341
+ * Builds an InlineQueryResultVenue object as specified by
342
+ * https://core.telegram.org/bots/api#inlinequeryresultvenue.
343
+ *
344
+ * @param id Unique identifier for this result, 1-64 Bytes
345
+ * @param title Title of the venue
346
+ * @param latitude Latitude of the venue location in degrees
347
+ * @param longitude Longitude of the venue location in degrees
348
+ * @param address Address of the venue
349
+ * @param options Remaining options
350
+ */
351
+ venue(id, title, latitude, longitude, address, options = {}) {
352
+ return inputMessage({
353
+ type: "venue",
354
+ id,
355
+ title,
356
+ latitude,
357
+ longitude,
358
+ address,
359
+ ...options,
360
+ });
361
+ },
362
+ /**
363
+ * Builds an InlineQueryResultVideo object as specified by
364
+ * https://core.telegram.org/bots/api#inlinequeryresultvideo with mime_type
365
+ * set to "text/html". This will send an embedded video player. Requires you
366
+ * to specify the actual message content by calling another function on the
367
+ * object returned from this method.
368
+ *
369
+ * @param id Unique identifier for this result, 1-64 bytes
370
+ * @param title Title for the result
371
+ * @param video_url A valid URL for the embedded video player
372
+ * @param thumbnail_url URL of the thumbnail (JPEG only) for the video
373
+ * @param options Remaining options
374
+ */
375
+ videoHtml(id, title, video_url, thumbnail_url, options = {}) {
376
+ // require input message content by only returning methods
377
+ return inputMessageMethods({
378
+ type: "video",
379
+ mime_type: "text/html",
380
+ id,
381
+ title,
382
+ video_url: typeof video_url === "string"
383
+ ? video_url
384
+ : video_url.href,
385
+ thumbnail_url: typeof thumbnail_url === "string"
386
+ ? thumbnail_url
387
+ : thumbnail_url.href,
388
+ ...options,
389
+ });
390
+ },
391
+ /**
392
+ * Builds an InlineQueryResultVideo object as specified by
393
+ * https://core.telegram.org/bots/api#inlinequeryresultvideo with mime_type
394
+ * set to "video/mp4".
395
+ *
396
+ * @param id Unique identifier for this result, 1-64 bytes
397
+ * @param title Title for the result
398
+ * @param video_url A valid URL for the video file
399
+ * @param thumbnail_url URL of the thumbnail (JPEG only) for the video
400
+ * @param options Remaining options
401
+ */
402
+ videoMp4(id, title, video_url, thumbnail_url, options = {}) {
403
+ return inputMessage({
404
+ type: "video",
405
+ mime_type: "video/mp4",
406
+ id,
407
+ title,
408
+ video_url: typeof video_url === "string"
409
+ ? video_url
410
+ : video_url.href,
411
+ thumbnail_url: typeof thumbnail_url === "string"
412
+ ? thumbnail_url
413
+ : thumbnail_url.href,
414
+ ...options,
415
+ });
416
+ },
417
+ /**
418
+ * Builds an InlineQueryResultCachedVideo object as specified by
419
+ * https://core.telegram.org/bots/api#inlinequeryresultcachedvideo.
420
+ *
421
+ * @param id Unique identifier for this result, 1-64 bytes
422
+ * @param title Title for the result
423
+ * @param video_file_id A valid file identifier for the video file
424
+ * @param options Remaining options
425
+ */
426
+ videoCached(id, title, video_file_id, options = {}) {
427
+ return inputMessage({ type: "video", id, title, video_file_id, ...options });
428
+ },
429
+ /**
430
+ * Builds an InlineQueryResultVoice object as specified by
431
+ * https://core.telegram.org/bots/api#inlinequeryresultvoice.
432
+ *
433
+ * @param id Unique identifier for this result, 1-64 bytes
434
+ * @param title Voice message title
435
+ * @param voice_url A valid URL for the voice recording
436
+ * @param options Remaining options
437
+ */
438
+ voice(id, title, voice_url, options = {}) {
439
+ return inputMessage({
440
+ type: "voice",
441
+ id,
442
+ title,
443
+ voice_url: typeof voice_url === "string"
444
+ ? voice_url
445
+ : voice_url.href,
446
+ ...options,
447
+ });
448
+ },
449
+ /**
450
+ * Builds an InlineQueryResultCachedVoice object as specified by
451
+ * https://core.telegram.org/bots/api#inlinequeryresultcachedvoice.
452
+ *
453
+ * @param id Unique identifier for this result, 1-64 bytes
454
+ * @param title Voice message title
455
+ * @param voice_file_id A valid file identifier for the voice message
456
+ * @param options Remaining options
457
+ */
458
+ voiceCached(id, title, voice_file_id, options = {}) {
459
+ return inputMessage({ type: "voice", id, title, voice_file_id, ...options });
460
+ },
461
+ };
@@ -0,0 +1,72 @@
1
+ import { type InputFile, type InputMediaAnimation, type InputMediaAudio, type InputMediaDocument, type InputMediaPhoto, type InputMediaVideo } from "../types.js";
2
+ type InputMediaOptions<T> = Omit<T, "type" | "media">;
3
+ /**
4
+ * Holds a number of helper methods for building `InputMedia*` objects. They are
5
+ * useful when sending media groups and when editing media messages.
6
+ *
7
+ * For example, media groups can be sent like this.
8
+ *
9
+ * ```ts
10
+ * const paths = [
11
+ * '/tmp/pic0.jpg',
12
+ * '/tmp/pic1.jpg',
13
+ * '/tmp/pic2.jpg',
14
+ * ]
15
+ * const files = paths.map((path) => new InputFile(path))
16
+ * const media = files.map((file) => InputMediaBuilder.photo(file))
17
+ * await bot.api.sendMediaGroup(chatId, media)
18
+ * ```
19
+ *
20
+ * Media can be edited like this.
21
+ *
22
+ * ```ts
23
+ * const file = new InputFile('/tmp/pic0.jpg')
24
+ * const media = InputMediaBuilder.photo(file, {
25
+ * caption: 'new caption'
26
+ * })
27
+ * await bot.api.editMessageMedia(chatId, messageId, media)
28
+ * ```
29
+ */
30
+ export declare const InputMediaBuilder: {
31
+ /**
32
+ * Creates a new `InputMediaPhoto` object as specified by
33
+ * https://core.telegram.org/bots/api#inputmediaphoto.
34
+ *
35
+ * @param media An `InputFile` instance or a file identifier
36
+ * @param options Remaining optional options
37
+ */
38
+ photo(media: string | InputFile, options?: InputMediaOptions<InputMediaPhoto>): InputMediaPhoto;
39
+ /**
40
+ * Creates a new `InputMediaVideo` object as specified by
41
+ * https://core.telegram.org/bots/api#inputmediavideo.
42
+ *
43
+ * @param media An `InputFile` instance or a file identifier
44
+ * @param options Remaining optional options
45
+ */
46
+ video(media: string | InputFile, options?: InputMediaOptions<InputMediaVideo>): InputMediaVideo;
47
+ /**
48
+ * Creates a new `InputMediaAnimation` object as specified by
49
+ * https://core.telegram.org/bots/api#inputmediaanimation.
50
+ *
51
+ * @param media An `InputFile` instance or a file identifier
52
+ * @param options Remaining optional options
53
+ */
54
+ animation(media: string | InputFile, options?: InputMediaOptions<InputMediaAnimation>): InputMediaAnimation;
55
+ /**
56
+ * Creates a new `InputMediaAudio` object as specified by
57
+ * https://core.telegram.org/bots/api#inputmediaaudio.
58
+ *
59
+ * @param media An `InputFile` instance or a file identifier
60
+ * @param options Remaining optional options
61
+ */
62
+ audio(media: string | InputFile, options?: InputMediaOptions<InputMediaAudio>): InputMediaAudio;
63
+ /**
64
+ * Creates a new `InputMediaDocument` object as specified by
65
+ * https://core.telegram.org/bots/api#inputmediadocument.
66
+ *
67
+ * @param media An `InputFile` instance or a file identifier
68
+ * @param options Remaining optional options
69
+ */
70
+ document(media: string | InputFile, options?: InputMediaOptions<InputMediaDocument>): InputMediaDocument;
71
+ };
72
+ export {};
@@ -0,0 +1,82 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.InputMediaBuilder = void 0;
4
+ /**
5
+ * Holds a number of helper methods for building `InputMedia*` objects. They are
6
+ * useful when sending media groups and when editing media messages.
7
+ *
8
+ * For example, media groups can be sent like this.
9
+ *
10
+ * ```ts
11
+ * const paths = [
12
+ * '/tmp/pic0.jpg',
13
+ * '/tmp/pic1.jpg',
14
+ * '/tmp/pic2.jpg',
15
+ * ]
16
+ * const files = paths.map((path) => new InputFile(path))
17
+ * const media = files.map((file) => InputMediaBuilder.photo(file))
18
+ * await bot.api.sendMediaGroup(chatId, media)
19
+ * ```
20
+ *
21
+ * Media can be edited like this.
22
+ *
23
+ * ```ts
24
+ * const file = new InputFile('/tmp/pic0.jpg')
25
+ * const media = InputMediaBuilder.photo(file, {
26
+ * caption: 'new caption'
27
+ * })
28
+ * await bot.api.editMessageMedia(chatId, messageId, media)
29
+ * ```
30
+ */
31
+ exports.InputMediaBuilder = {
32
+ /**
33
+ * Creates a new `InputMediaPhoto` object as specified by
34
+ * https://core.telegram.org/bots/api#inputmediaphoto.
35
+ *
36
+ * @param media An `InputFile` instance or a file identifier
37
+ * @param options Remaining optional options
38
+ */
39
+ photo(media, options = {}) {
40
+ return { type: "photo", media, ...options };
41
+ },
42
+ /**
43
+ * Creates a new `InputMediaVideo` object as specified by
44
+ * https://core.telegram.org/bots/api#inputmediavideo.
45
+ *
46
+ * @param media An `InputFile` instance or a file identifier
47
+ * @param options Remaining optional options
48
+ */
49
+ video(media, options = {}) {
50
+ return { type: "video", media, ...options };
51
+ },
52
+ /**
53
+ * Creates a new `InputMediaAnimation` object as specified by
54
+ * https://core.telegram.org/bots/api#inputmediaanimation.
55
+ *
56
+ * @param media An `InputFile` instance or a file identifier
57
+ * @param options Remaining optional options
58
+ */
59
+ animation(media, options = {}) {
60
+ return { type: "animation", media, ...options };
61
+ },
62
+ /**
63
+ * Creates a new `InputMediaAudio` object as specified by
64
+ * https://core.telegram.org/bots/api#inputmediaaudio.
65
+ *
66
+ * @param media An `InputFile` instance or a file identifier
67
+ * @param options Remaining optional options
68
+ */
69
+ audio(media, options = {}) {
70
+ return { type: "audio", media, ...options };
71
+ },
72
+ /**
73
+ * Creates a new `InputMediaDocument` object as specified by
74
+ * https://core.telegram.org/bots/api#inputmediadocument.
75
+ *
76
+ * @param media An `InputFile` instance or a file identifier
77
+ * @param options Remaining optional options
78
+ */
79
+ document(media, options = {}) {
80
+ return { type: "document", media, ...options };
81
+ },
82
+ };