deno.land / x / grammy@v1.22.4 / convenience / input_media.ts

input_media.ts
نووسراو ببینە
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
import { type InputFile, type InputMediaAnimation, type InputMediaAudio, type InputMediaDocument, type InputMediaPhoto, type InputMediaVideo,} from "../types.ts";
type InputMediaOptions<T> = Omit<T, "type" | "media">;
/** * Holds a number of helper methods for building `InputMedia*` objects. They are * useful when sending media groups and when editing media messages. * * For example, media groups can be sent like this. * * ```ts * const paths = [ * '/tmp/pic0.jpg', * '/tmp/pic1.jpg', * '/tmp/pic2.jpg', * ] * const files = paths.map((path) => new InputFile(path)) * const media = files.map((file) => InputMediaBuilder.photo(file)) * await bot.api.sendMediaGroup(chatId, media) * ``` * * Media can be edited like this. * * ```ts * const file = new InputFile('/tmp/pic0.jpg') * const media = InputMediaBuilder.photo(file, { * caption: 'new caption' * }) * await bot.api.editMessageMedia(chatId, messageId, media) * ``` */export const InputMediaBuilder = { /** * Creates a new `InputMediaPhoto` object as specified by * https://core.telegram.org/bots/api#inputmediaphoto. * * @param media An `InputFile` instance or a file identifier * @param options Remaining optional options */ photo( media: string | InputFile, options: InputMediaOptions<InputMediaPhoto> = {}, ): InputMediaPhoto { return { type: "photo", media, ...options }; }, /** * Creates a new `InputMediaVideo` object as specified by * https://core.telegram.org/bots/api#inputmediavideo. * * @param media An `InputFile` instance or a file identifier * @param options Remaining optional options */ video( media: string | InputFile, options: InputMediaOptions<InputMediaVideo> = {}, ): InputMediaVideo { return { type: "video", media, ...options }; }, /** * Creates a new `InputMediaAnimation` object as specified by * https://core.telegram.org/bots/api#inputmediaanimation. * * @param media An `InputFile` instance or a file identifier * @param options Remaining optional options */ animation( media: string | InputFile, options: InputMediaOptions<InputMediaAnimation> = {}, ): InputMediaAnimation { return { type: "animation", media, ...options }; }, /** * Creates a new `InputMediaAudio` object as specified by * https://core.telegram.org/bots/api#inputmediaaudio. * * @param media An `InputFile` instance or a file identifier * @param options Remaining optional options */ audio( media: string | InputFile, options: InputMediaOptions<InputMediaAudio> = {}, ): InputMediaAudio { return { type: "audio", media, ...options }; }, /** * Creates a new `InputMediaDocument` object as specified by * https://core.telegram.org/bots/api#inputmediadocument. * * @param media An `InputFile` instance or a file identifier * @param options Remaining optional options */ document( media: string | InputFile, options: InputMediaOptions<InputMediaDocument> = {}, ): InputMediaDocument { return { type: "document", media, ...options }; },};
grammy

Version Info

Tagged at
a month ago