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
package/out/context.js ADDED
@@ -0,0 +1,1976 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Context = void 0;
4
+ const filter_js_1 = require("./filter.js");
5
+ const checker = {
6
+ filterQuery(filter) {
7
+ const pred = (0, filter_js_1.matchFilter)(filter);
8
+ return (ctx) => pred(ctx);
9
+ },
10
+ text(trigger) {
11
+ const hasText = checker.filterQuery([":text", ":caption"]);
12
+ const trg = triggerFn(trigger);
13
+ return (ctx) => {
14
+ var _a, _b;
15
+ if (!hasText(ctx))
16
+ return false;
17
+ const msg = (_a = ctx.message) !== null && _a !== void 0 ? _a : ctx.channelPost;
18
+ const txt = (_b = msg.text) !== null && _b !== void 0 ? _b : msg.caption;
19
+ return match(ctx, txt, trg);
20
+ };
21
+ },
22
+ command(command) {
23
+ const hasEntities = checker.filterQuery(":entities:bot_command");
24
+ const atCommands = new Set();
25
+ const noAtCommands = new Set();
26
+ toArray(command).forEach((cmd) => {
27
+ if (cmd.startsWith("/")) {
28
+ throw new Error(`Do not include '/' when registering command handlers (use '${cmd.substring(1)}' not '${cmd}')`);
29
+ }
30
+ const set = cmd.includes("@") ? atCommands : noAtCommands;
31
+ set.add(cmd);
32
+ });
33
+ return (ctx) => {
34
+ var _a, _b;
35
+ if (!hasEntities(ctx))
36
+ return false;
37
+ const msg = (_a = ctx.message) !== null && _a !== void 0 ? _a : ctx.channelPost;
38
+ const txt = (_b = msg.text) !== null && _b !== void 0 ? _b : msg.caption;
39
+ return msg.entities.some((e) => {
40
+ if (e.type !== "bot_command")
41
+ return false;
42
+ if (e.offset !== 0)
43
+ return false;
44
+ const cmd = txt.substring(1, e.length);
45
+ if (noAtCommands.has(cmd) || atCommands.has(cmd)) {
46
+ ctx.match = txt.substring(cmd.length + 1).trimStart();
47
+ return true;
48
+ }
49
+ const index = cmd.indexOf("@");
50
+ if (index === -1)
51
+ return false;
52
+ const atTarget = cmd.substring(index + 1).toLowerCase();
53
+ const username = ctx.me.username.toLowerCase();
54
+ if (atTarget !== username)
55
+ return false;
56
+ const atCommand = cmd.substring(0, index);
57
+ if (noAtCommands.has(atCommand)) {
58
+ ctx.match = txt.substring(cmd.length + 1).trimStart();
59
+ return true;
60
+ }
61
+ return false;
62
+ });
63
+ };
64
+ },
65
+ reaction(reaction) {
66
+ const hasMessageReaction = checker.filterQuery("message_reaction");
67
+ const normalized = typeof reaction === "string"
68
+ ? [{ type: "emoji", emoji: reaction }]
69
+ : (Array.isArray(reaction) ? reaction : [reaction]).map((emoji) => typeof emoji === "string" ? { type: "emoji", emoji } : emoji);
70
+ const emoji = new Set(normalized.filter((r) => r.type === "emoji")
71
+ .map((r) => r.emoji));
72
+ const customEmoji = new Set(normalized.filter((r) => r.type === "custom_emoji")
73
+ .map((r) => r.custom_emoji_id));
74
+ const paid = normalized.some((r) => r.type === "paid");
75
+ return (ctx) => {
76
+ if (!hasMessageReaction(ctx))
77
+ return false;
78
+ const { old_reaction, new_reaction } = ctx.messageReaction;
79
+ // try to find a wanted reaction that is new and not old
80
+ for (const reaction of new_reaction) {
81
+ // first check if the reaction existed previously
82
+ let isOld = false;
83
+ if (reaction.type === "emoji") {
84
+ for (const old of old_reaction) {
85
+ if (old.type !== "emoji")
86
+ continue;
87
+ if (old.emoji === reaction.emoji) {
88
+ isOld = true;
89
+ break;
90
+ }
91
+ }
92
+ }
93
+ else if (reaction.type === "custom_emoji") {
94
+ for (const old of old_reaction) {
95
+ if (old.type !== "custom_emoji")
96
+ continue;
97
+ if (old.custom_emoji_id === reaction.custom_emoji_id) {
98
+ isOld = true;
99
+ break;
100
+ }
101
+ }
102
+ }
103
+ else if (reaction.type === "paid") {
104
+ for (const old of old_reaction) {
105
+ if (old.type !== "paid")
106
+ continue;
107
+ isOld = true;
108
+ break;
109
+ }
110
+ }
111
+ else {
112
+ // always regard unsupported emoji types as new
113
+ }
114
+ // disregard reaction if it is not new
115
+ if (isOld)
116
+ continue;
117
+ // check if the new reaction is wanted and short-circuit
118
+ if (reaction.type === "emoji") {
119
+ if (emoji.has(reaction.emoji))
120
+ return true;
121
+ }
122
+ else if (reaction.type === "custom_emoji") {
123
+ if (customEmoji.has(reaction.custom_emoji_id))
124
+ return true;
125
+ }
126
+ else if (reaction.type === "paid") {
127
+ if (paid)
128
+ return true;
129
+ }
130
+ else {
131
+ // always regard unsupported emoji types as new
132
+ return true;
133
+ }
134
+ // new reaction not wanted, check next one
135
+ }
136
+ return false;
137
+ };
138
+ },
139
+ chatType(chatType) {
140
+ const set = new Set(toArray(chatType));
141
+ return (ctx) => { var _a; return ((_a = ctx.chat) === null || _a === void 0 ? void 0 : _a.type) !== undefined && set.has(ctx.chat.type); };
142
+ },
143
+ callbackQuery(trigger) {
144
+ const hasCallbackQuery = checker.filterQuery("callback_query:data");
145
+ const trg = triggerFn(trigger);
146
+ return (ctx) => hasCallbackQuery(ctx) && match(ctx, ctx.callbackQuery.data, trg);
147
+ },
148
+ gameQuery(trigger) {
149
+ const hasGameQuery = checker.filterQuery("callback_query:game_short_name");
150
+ const trg = triggerFn(trigger);
151
+ return (ctx) => hasGameQuery(ctx) &&
152
+ match(ctx, ctx.callbackQuery.game_short_name, trg);
153
+ },
154
+ inlineQuery(trigger) {
155
+ const hasInlineQuery = checker.filterQuery("inline_query");
156
+ const trg = triggerFn(trigger);
157
+ return (ctx) => hasInlineQuery(ctx) && match(ctx, ctx.inlineQuery.query, trg);
158
+ },
159
+ chosenInlineResult(trigger) {
160
+ const hasChosenInlineResult = checker.filterQuery("chosen_inline_result");
161
+ const trg = triggerFn(trigger);
162
+ return (ctx) => hasChosenInlineResult(ctx) &&
163
+ match(ctx, ctx.chosenInlineResult.result_id, trg);
164
+ },
165
+ preCheckoutQuery(trigger) {
166
+ const hasPreCheckoutQuery = checker.filterQuery("pre_checkout_query");
167
+ const trg = triggerFn(trigger);
168
+ return (ctx) => hasPreCheckoutQuery(ctx) &&
169
+ match(ctx, ctx.preCheckoutQuery.invoice_payload, trg);
170
+ },
171
+ shippingQuery(trigger) {
172
+ const hasShippingQuery = checker.filterQuery("shipping_query");
173
+ const trg = triggerFn(trigger);
174
+ return (ctx) => hasShippingQuery(ctx) &&
175
+ match(ctx, ctx.shippingQuery.invoice_payload, trg);
176
+ },
177
+ };
178
+ // === Context class
179
+ /**
180
+ * When your bot receives a message, Telegram sends an update object to your
181
+ * bot. The update contains information about the chat, the user, and of course
182
+ * the message itself. There are numerous other updates, too:
183
+ * https://core.telegram.org/bots/api#update
184
+ *
185
+ * When grammY receives an update, it wraps this update into a context object
186
+ * for you. Context objects are commonly named `ctx`. A context object does two
187
+ * things:
188
+ * 1. **`ctx.update`** holds the update object that you can use to process the
189
+ * message. This includes providing useful shortcuts for the update, for
190
+ * instance, `ctx.msg` is a shortcut that gives you the message object from
191
+ * the update—no matter whether it is contained in `ctx.update.message`, or
192
+ * `ctx.update.edited_message`, or `ctx.update.channel_post`, or
193
+ * `ctx.update.edited_channel_post`.
194
+ * 2. **`ctx.api`** gives you access to the full Telegram Bot API so that you
195
+ * can directly call any method, such as responding via
196
+ * `ctx.api.sendMessage`. Also here, the context objects has some useful
197
+ * shortcuts for you. For instance, if you want to send a message to the same
198
+ * chat that a message comes from (i.e. just respond to a user) you can call
199
+ * `ctx.reply`. This is nothing but a wrapper for `ctx.api.sendMessage` with
200
+ * the right `chat_id` pre-filled for you. Almost all methods of the Telegram
201
+ * Bot API have their own shortcut directly on the context object, so you
202
+ * probably never really have to use `ctx.api` at all.
203
+ *
204
+ * This context object is then passed to all of the listeners (called
205
+ * middleware) that you register on your bot. Because this is so useful, the
206
+ * context object is often used to hold more information. One example are
207
+ * sessions (a chat-specific data storage that is stored in a database), and
208
+ * another example is `ctx.match` that is used by `bot.command` and other
209
+ * methods to keep information about how a regular expression was matched.
210
+ *
211
+ * Read up about middleware on the
212
+ * [website](https://grammy.dev/guide/context) if you want to know more
213
+ * about the powerful opportunities that lie in context objects, and about how
214
+ * grammY implements them.
215
+ */
216
+ class Context {
217
+ constructor(
218
+ /**
219
+ * The update object that is contained in the context.
220
+ */
221
+ update,
222
+ /**
223
+ * An API instance that allows you to call any method of the Telegram
224
+ * Bot API.
225
+ */
226
+ api,
227
+ /**
228
+ * Information about the bot itself.
229
+ */
230
+ me) {
231
+ this.update = update;
232
+ this.api = api;
233
+ this.me = me;
234
+ }
235
+ // UPDATE SHORTCUTS
236
+ // Keep in sync with types in `filter.ts`.
237
+ /** Alias for `ctx.update.message` */
238
+ get message() {
239
+ return this.update.message;
240
+ }
241
+ /** Alias for `ctx.update.edited_message` */
242
+ get editedMessage() {
243
+ return this.update.edited_message;
244
+ }
245
+ /** Alias for `ctx.update.channel_post` */
246
+ get channelPost() {
247
+ return this.update.channel_post;
248
+ }
249
+ /** Alias for `ctx.update.edited_channel_post` */
250
+ get editedChannelPost() {
251
+ return this.update.edited_channel_post;
252
+ }
253
+ /** Alias for `ctx.update.business_connection` */
254
+ get businessConnection() {
255
+ return this.update.business_connection;
256
+ }
257
+ /** Alias for `ctx.update.business_message` */
258
+ get businessMessage() {
259
+ return this.update.business_message;
260
+ }
261
+ /** Alias for `ctx.update.edited_business_message` */
262
+ get editedBusinessMessage() {
263
+ return this.update.edited_business_message;
264
+ }
265
+ /** Alias for `ctx.update.deleted_business_messages` */
266
+ get deletedBusinessMessages() {
267
+ return this.update.deleted_business_messages;
268
+ }
269
+ /** Alias for `ctx.update.message_reaction` */
270
+ get messageReaction() {
271
+ return this.update.message_reaction;
272
+ }
273
+ /** Alias for `ctx.update.message_reaction_count` */
274
+ get messageReactionCount() {
275
+ return this.update.message_reaction_count;
276
+ }
277
+ /** Alias for `ctx.update.inline_query` */
278
+ get inlineQuery() {
279
+ return this.update.inline_query;
280
+ }
281
+ /** Alias for `ctx.update.chosen_inline_result` */
282
+ get chosenInlineResult() {
283
+ return this.update.chosen_inline_result;
284
+ }
285
+ /** Alias for `ctx.update.callback_query` */
286
+ get callbackQuery() {
287
+ return this.update.callback_query;
288
+ }
289
+ /** Alias for `ctx.update.shipping_query` */
290
+ get shippingQuery() {
291
+ return this.update.shipping_query;
292
+ }
293
+ /** Alias for `ctx.update.pre_checkout_query` */
294
+ get preCheckoutQuery() {
295
+ return this.update.pre_checkout_query;
296
+ }
297
+ /** Alias for `ctx.update.poll` */
298
+ get poll() {
299
+ return this.update.poll;
300
+ }
301
+ /** Alias for `ctx.update.poll_answer` */
302
+ get pollAnswer() {
303
+ return this.update.poll_answer;
304
+ }
305
+ /** Alias for `ctx.update.my_chat_member` */
306
+ get myChatMember() {
307
+ return this.update.my_chat_member;
308
+ }
309
+ /** Alias for `ctx.update.chat_member` */
310
+ get chatMember() {
311
+ return this.update.chat_member;
312
+ }
313
+ /** Alias for `ctx.update.chat_join_request` */
314
+ get chatJoinRequest() {
315
+ return this.update.chat_join_request;
316
+ }
317
+ /** Alias for `ctx.update.chat_boost` */
318
+ get chatBoost() {
319
+ return this.update.chat_boost;
320
+ }
321
+ /** Alias for `ctx.update.removed_chat_boost` */
322
+ get removedChatBoost() {
323
+ return this.update.removed_chat_boost;
324
+ }
325
+ /** Alias for `ctx.update.purchased_paid_media` */
326
+ get purchasedPaidMedia() {
327
+ return this.update.purchased_paid_media;
328
+ }
329
+ // AGGREGATION SHORTCUTS
330
+ /**
331
+ * Get the message object from wherever possible. Alias for `this.message ??
332
+ * this.editedMessage ?? this.channelPost ?? this.editedChannelPost ??
333
+ * this.businessMessage ?? this.editedBusinessMessage ??
334
+ * this.callbackQuery?.message`.
335
+ */
336
+ get msg() {
337
+ var _a, _b, _c, _d, _e, _f, _g;
338
+ // Keep in sync with types in `filter.ts`.
339
+ return ((_f = (_e = (_d = (_c = (_b = (_a = this.message) !== null && _a !== void 0 ? _a : this.editedMessage) !== null && _b !== void 0 ? _b : this.channelPost) !== null && _c !== void 0 ? _c : this.editedChannelPost) !== null && _d !== void 0 ? _d : this.businessMessage) !== null && _e !== void 0 ? _e : this.editedBusinessMessage) !== null && _f !== void 0 ? _f : (_g = this.callbackQuery) === null || _g === void 0 ? void 0 : _g.message);
340
+ }
341
+ /**
342
+ * Get the chat object from wherever possible. Alias for `(this.msg ??
343
+ * this.deletedBusinessMessages ?? this.messageReaction ??
344
+ * this.messageReactionCount ?? this.myChatMember ?? this.chatMember ??
345
+ * this.chatJoinRequest ?? this.chatBoost ?? this.removedChatBoost)?.chat`.
346
+ */
347
+ get chat() {
348
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
349
+ // Keep in sync with types in `filter.ts`.
350
+ return (_j = ((_h = (_g = (_f = (_e = (_d = (_c = (_b = (_a = this.msg) !== null && _a !== void 0 ? _a : this.deletedBusinessMessages) !== null && _b !== void 0 ? _b : this.messageReaction) !== null && _c !== void 0 ? _c : this.messageReactionCount) !== null && _d !== void 0 ? _d : this.myChatMember) !== null && _e !== void 0 ? _e : this.chatMember) !== null && _f !== void 0 ? _f : this.chatJoinRequest) !== null && _g !== void 0 ? _g : this.chatBoost) !== null && _h !== void 0 ? _h : this.removedChatBoost)) === null || _j === void 0 ? void 0 : _j.chat;
351
+ }
352
+ /**
353
+ * Get the sender chat object from wherever possible. Alias for
354
+ * `ctx.msg?.sender_chat`.
355
+ */
356
+ get senderChat() {
357
+ var _a;
358
+ // Keep in sync with types in `filter.ts`.
359
+ return (_a = this.msg) === null || _a === void 0 ? void 0 : _a.sender_chat;
360
+ }
361
+ /**
362
+ * Get the user object from wherever possible. Alias for
363
+ * `(this.businessConnection ?? this.messageReaction ??
364
+ * (this.chatBoost?.boost ?? this.removedChatBoost)?.source)?.user ??
365
+ * (this.callbackQuery ?? this.msg ?? this.inlineQuery ??
366
+ * this.chosenInlineResult ?? this.shippingQuery ?? this.preCheckoutQuery ??
367
+ * this.myChatMember ?? this.chatMember ?? this.chatJoinRequest ??
368
+ * this.purchasedPaidMedia)?.from`.
369
+ */
370
+ get from() {
371
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
372
+ // Keep in sync with types in `filter.ts`.
373
+ return (_g = (_f = ((_b = (_a = this.businessConnection) !== null && _a !== void 0 ? _a : this.messageReaction) !== null && _b !== void 0 ? _b : (_e = ((_d = (_c = this.chatBoost) === null || _c === void 0 ? void 0 : _c.boost) !== null && _d !== void 0 ? _d : this.removedChatBoost)) === null || _e === void 0 ? void 0 : _e.source)) === null || _f === void 0 ? void 0 : _f.user) !== null && _g !== void 0 ? _g : (_s = ((_r = (_q = (_p = (_o = (_m = (_l = (_k = (_j = (_h = this.callbackQuery) !== null && _h !== void 0 ? _h : this.msg) !== null && _j !== void 0 ? _j : this.inlineQuery) !== null && _k !== void 0 ? _k : this.chosenInlineResult) !== null && _l !== void 0 ? _l : this.shippingQuery) !== null && _m !== void 0 ? _m : this.preCheckoutQuery) !== null && _o !== void 0 ? _o : this.myChatMember) !== null && _p !== void 0 ? _p : this.chatMember) !== null && _q !== void 0 ? _q : this.chatJoinRequest) !== null && _r !== void 0 ? _r : this.purchasedPaidMedia)) === null || _s === void 0 ? void 0 : _s.from;
374
+ }
375
+ /**
376
+ * Get the message identifier from wherever possible. Alias for
377
+ * `this.msg?.message_id ?? this.messageReaction?.message_id ??
378
+ * this.messageReactionCount?.message_id`.
379
+ */
380
+ get msgId() {
381
+ var _a, _b, _c, _d, _e;
382
+ // Keep in sync with types in `filter.ts`.
383
+ return (_d = (_b = (_a = this.msg) === null || _a === void 0 ? void 0 : _a.message_id) !== null && _b !== void 0 ? _b : (_c = this.messageReaction) === null || _c === void 0 ? void 0 : _c.message_id) !== null && _d !== void 0 ? _d : (_e = this.messageReactionCount) === null || _e === void 0 ? void 0 : _e.message_id;
384
+ }
385
+ /**
386
+ * Gets the chat identifier from wherever possible. Alias for `this.chat?.id
387
+ * ?? this.businessConnection?.user_chat_id`.
388
+ */
389
+ get chatId() {
390
+ var _a, _b, _c;
391
+ // Keep in sync with types in `filter.ts`.
392
+ return (_b = (_a = this.chat) === null || _a === void 0 ? void 0 : _a.id) !== null && _b !== void 0 ? _b : (_c = this.businessConnection) === null || _c === void 0 ? void 0 : _c.user_chat_id;
393
+ }
394
+ /**
395
+ * Get the inline message identifier from wherever possible. Alias for
396
+ * `(ctx.callbackQuery ?? ctx.chosenInlineResult)?.inline_message_id`.
397
+ */
398
+ get inlineMessageId() {
399
+ var _a, _b, _c;
400
+ return ((_b = (_a = this.callbackQuery) === null || _a === void 0 ? void 0 : _a.inline_message_id) !== null && _b !== void 0 ? _b : (_c = this.chosenInlineResult) === null || _c === void 0 ? void 0 : _c.inline_message_id);
401
+ }
402
+ /**
403
+ * Get the business connection identifier from wherever possible. Alias for
404
+ * `this.msg?.business_connection_id ?? this.businessConnection?.id ??
405
+ * this.deletedBusinessMessages?.business_connection_id`.
406
+ */
407
+ get businessConnectionId() {
408
+ var _a, _b, _c, _d, _e;
409
+ return (_d = (_b = (_a = this.msg) === null || _a === void 0 ? void 0 : _a.business_connection_id) !== null && _b !== void 0 ? _b : (_c = this.businessConnection) === null || _c === void 0 ? void 0 : _c.id) !== null && _d !== void 0 ? _d : (_e = this.deletedBusinessMessages) === null || _e === void 0 ? void 0 : _e.business_connection_id;
410
+ }
411
+ entities(types) {
412
+ var _a, _b;
413
+ const message = this.msg;
414
+ if (message === undefined)
415
+ return [];
416
+ const text = (_a = message.text) !== null && _a !== void 0 ? _a : message.caption;
417
+ if (text === undefined)
418
+ return [];
419
+ let entities = (_b = message.entities) !== null && _b !== void 0 ? _b : message.caption_entities;
420
+ if (entities === undefined)
421
+ return [];
422
+ if (types !== undefined) {
423
+ const filters = new Set(toArray(types));
424
+ entities = entities.filter((entity) => filters.has(entity.type));
425
+ }
426
+ return entities.map((entity) => ({
427
+ ...entity,
428
+ text: text.substring(entity.offset, entity.offset + entity.length),
429
+ }));
430
+ }
431
+ /**
432
+ * Find out which reactions were added and removed in a `message_reaction`
433
+ * update. This method looks at `ctx.messageReaction` and computes the
434
+ * difference between the old reaction and the new reaction. It also groups
435
+ * the reactions by emoji reactions and custom emoji reactions. For example,
436
+ * the resulting object could look like this:
437
+ * ```ts
438
+ * {
439
+ * emoji: ['👍', '🎉']
440
+ * emojiAdded: ['🎉'],
441
+ * emojiKept: ['👍'],
442
+ * emojiRemoved: [],
443
+ * customEmoji: [],
444
+ * customEmojiAdded: [],
445
+ * customEmojiKept: [],
446
+ * customEmojiRemoved: ['id0123'],
447
+ * paid: true,
448
+ * paidAdded: false,
449
+ * paidRemoved: false,
450
+ * }
451
+ * ```
452
+ * In the above example, a tada reaction was added by the user, and a custom
453
+ * emoji reaction with the custom emoji 'id0123' was removed in the same
454
+ * update. The user had already reacted with a thumbs up reaction and a paid
455
+ * star reaction, which they left both unchanged. As a result, the current
456
+ * reaction by the user is thumbs up, tada, and a paid reaction. Note that
457
+ * the current reaction (all emoji reactions regardless of type in one list)
458
+ * can also be obtained from `ctx.messageReaction.new_reaction`.
459
+ *
460
+ * Remember that reaction updates only include information about the
461
+ * reaction of a specific user. The respective message may have many more
462
+ * reactions by other people which will not be included in this update.
463
+ *
464
+ * @returns An object containing information about the reaction update
465
+ */
466
+ reactions() {
467
+ const emoji = [];
468
+ const emojiAdded = [];
469
+ const emojiKept = [];
470
+ const emojiRemoved = [];
471
+ const customEmoji = [];
472
+ const customEmojiAdded = [];
473
+ const customEmojiKept = [];
474
+ const customEmojiRemoved = [];
475
+ let paid = false;
476
+ let paidAdded = false;
477
+ const r = this.messageReaction;
478
+ if (r !== undefined) {
479
+ const { old_reaction, new_reaction } = r;
480
+ // group all current emoji in `emoji` and `customEmoji`
481
+ for (const reaction of new_reaction) {
482
+ if (reaction.type === "emoji") {
483
+ emoji.push(reaction.emoji);
484
+ }
485
+ else if (reaction.type === "custom_emoji") {
486
+ customEmoji.push(reaction.custom_emoji_id);
487
+ }
488
+ else if (reaction.type === "paid") {
489
+ paid = paidAdded = true;
490
+ }
491
+ }
492
+ // temporarily move all old emoji to the *Removed arrays
493
+ for (const reaction of old_reaction) {
494
+ if (reaction.type === "emoji") {
495
+ emojiRemoved.push(reaction.emoji);
496
+ }
497
+ else if (reaction.type === "custom_emoji") {
498
+ customEmojiRemoved.push(reaction.custom_emoji_id);
499
+ }
500
+ else if (reaction.type === "paid") {
501
+ paidAdded = false;
502
+ }
503
+ }
504
+ // temporarily move all new emoji to the *Added arrays
505
+ emojiAdded.push(...emoji);
506
+ customEmojiAdded.push(...customEmoji);
507
+ // drop common emoji from both lists and add them to `emojiKept`
508
+ for (let i = 0; i < emojiRemoved.length; i++) {
509
+ const len = emojiAdded.length;
510
+ if (len === 0)
511
+ break;
512
+ const rem = emojiRemoved[i];
513
+ for (let j = 0; j < len; j++) {
514
+ if (rem === emojiAdded[j]) {
515
+ emojiKept.push(rem);
516
+ emojiRemoved.splice(i, 1);
517
+ emojiAdded.splice(j, 1);
518
+ i--;
519
+ break;
520
+ }
521
+ }
522
+ }
523
+ // drop common custom emoji from both lists and add them to `customEmojiKept`
524
+ for (let i = 0; i < customEmojiRemoved.length; i++) {
525
+ const len = customEmojiAdded.length;
526
+ if (len === 0)
527
+ break;
528
+ const rem = customEmojiRemoved[i];
529
+ for (let j = 0; j < len; j++) {
530
+ if (rem === customEmojiAdded[j]) {
531
+ customEmojiKept.push(rem);
532
+ customEmojiRemoved.splice(i, 1);
533
+ customEmojiAdded.splice(j, 1);
534
+ i--;
535
+ break;
536
+ }
537
+ }
538
+ }
539
+ }
540
+ return {
541
+ emoji,
542
+ emojiAdded,
543
+ emojiKept,
544
+ emojiRemoved,
545
+ customEmoji,
546
+ customEmojiAdded,
547
+ customEmojiKept,
548
+ customEmojiRemoved,
549
+ paid,
550
+ paidAdded,
551
+ };
552
+ }
553
+ /**
554
+ * Returns `true` if this context object matches the given filter query, and
555
+ * `false` otherwise. This uses the same logic as `bot.on`.
556
+ *
557
+ * @param filter The filter query to check
558
+ */
559
+ has(filter) {
560
+ return Context.has.filterQuery(filter)(this);
561
+ }
562
+ /**
563
+ * Returns `true` if this context object contains the given text, or if it
564
+ * contains text that matches the given regular expression. It returns
565
+ * `false` otherwise. This uses the same logic as `bot.hears`.
566
+ *
567
+ * @param trigger The string or regex to match
568
+ */
569
+ hasText(trigger) {
570
+ return Context.has.text(trigger)(this);
571
+ }
572
+ /**
573
+ * Returns `true` if this context object contains the given command, and
574
+ * `false` otherwise. This uses the same logic as `bot.command`.
575
+ *
576
+ * @param command The command to match
577
+ */
578
+ hasCommand(command) {
579
+ return Context.has.command(command)(this);
580
+ }
581
+ hasReaction(reaction) {
582
+ return Context.has.reaction(reaction)(this);
583
+ }
584
+ /**
585
+ * Returns `true` if this context object belongs to a chat with the given
586
+ * chat type, and `false` otherwise. This uses the same logic as
587
+ * `bot.chatType`.
588
+ *
589
+ * @param chatType The chat type to match
590
+ */
591
+ hasChatType(chatType) {
592
+ return Context.has.chatType(chatType)(this);
593
+ }
594
+ /**
595
+ * Returns `true` if this context object contains the given callback query,
596
+ * or if the contained callback query data matches the given regular
597
+ * expression. It returns `false` otherwise. This uses the same logic as
598
+ * `bot.callbackQuery`.
599
+ *
600
+ * @param trigger The string or regex to match
601
+ */
602
+ hasCallbackQuery(trigger) {
603
+ return Context.has.callbackQuery(trigger)(this);
604
+ }
605
+ /**
606
+ * Returns `true` if this context object contains the given game query, or
607
+ * if the contained game query matches the given regular expression. It
608
+ * returns `false` otherwise. This uses the same logic as `bot.gameQuery`.
609
+ *
610
+ * @param trigger The string or regex to match
611
+ */
612
+ hasGameQuery(trigger) {
613
+ return Context.has.gameQuery(trigger)(this);
614
+ }
615
+ /**
616
+ * Returns `true` if this context object contains the given inline query, or
617
+ * if the contained inline query matches the given regular expression. It
618
+ * returns `false` otherwise. This uses the same logic as `bot.inlineQuery`.
619
+ *
620
+ * @param trigger The string or regex to match
621
+ */
622
+ hasInlineQuery(trigger) {
623
+ return Context.has.inlineQuery(trigger)(this);
624
+ }
625
+ /**
626
+ * Returns `true` if this context object contains the chosen inline result,
627
+ * or if the contained chosen inline result matches the given regular
628
+ * expression. It returns `false` otherwise. This uses the same logic as
629
+ * `bot.chosenInlineResult`.
630
+ *
631
+ * @param trigger The string or regex to match
632
+ */
633
+ hasChosenInlineResult(trigger) {
634
+ return Context.has.chosenInlineResult(trigger)(this);
635
+ }
636
+ /**
637
+ * Returns `true` if this context object contains the given pre-checkout
638
+ * query, or if the contained pre-checkout query matches the given regular
639
+ * expression. It returns `false` otherwise. This uses the same logic as
640
+ * `bot.preCheckoutQuery`.
641
+ *
642
+ * @param trigger The string or regex to match
643
+ */
644
+ hasPreCheckoutQuery(trigger) {
645
+ return Context.has.preCheckoutQuery(trigger)(this);
646
+ }
647
+ /**
648
+ * Returns `true` if this context object contains the given shipping query,
649
+ * or if the contained shipping query matches the given regular expression.
650
+ * It returns `false` otherwise. This uses the same logic as
651
+ * `bot.shippingQuery`.
652
+ *
653
+ * @param trigger The string or regex to match
654
+ */
655
+ hasShippingQuery(trigger) {
656
+ return Context.has.shippingQuery(trigger)(this);
657
+ }
658
+ // API
659
+ /**
660
+ * Context-aware alias for `api.sendMessage`. Use this method to send text messages. On success, the sent Message is returned.
661
+ *
662
+ * @param text Text of the message to be sent, 1-4096 characters after entities parsing
663
+ * @param other Optional remaining parameters, confer the official reference below
664
+ * @param signal Optional `AbortSignal` to cancel the request
665
+ *
666
+ * **Official reference:** https://core.telegram.org/bots/api#sendmessage
667
+ */
668
+ reply(text, other, signal) {
669
+ return this.api.sendMessage(orThrow(this.chatId, "sendMessage"), text, { business_connection_id: this.businessConnectionId, ...other }, signal);
670
+ }
671
+ /**
672
+ * Context-aware alias for `api.forwardMessage`. Use this method to forward messages of any kind. Service messages and messages with protected content can't be forwarded. On success, the sent Message is returned.
673
+ *
674
+ * @param chat_id Unique identifier for the target chat or username of the target channel (in the format @channelusername)
675
+ * @param other Optional remaining parameters, confer the official reference below
676
+ * @param signal Optional `AbortSignal` to cancel the request
677
+ *
678
+ * **Official reference:** https://core.telegram.org/bots/api#forwardmessage
679
+ */
680
+ forwardMessage(chat_id, other, signal) {
681
+ return this.api.forwardMessage(chat_id, orThrow(this.chatId, "forwardMessage"), orThrow(this.msgId, "forwardMessage"), other, signal);
682
+ }
683
+ /**
684
+ * Context-aware alias for `api.forwardMessages`. Use this method to forward multiple messages of any kind. If some of the specified messages can't be found or forwarded, they are skipped. Service messages and messages with protected content can't be forwarded. Album grouping is kept for forwarded messages. On success, an array of MessageId of the sent messages is returned.
685
+ *
686
+ * @param chat_id Unique identifier for the target chat or username of the target channel (in the format @channelusername)
687
+ * @param message_ids A list of 1-100 identifiers of messages in the current chat to forward. The identifiers must be specified in a strictly increasing order.
688
+ * @param other Optional remaining parameters, confer the official reference below
689
+ * @param signal Optional `AbortSignal` to cancel the request
690
+ *
691
+ * **Official reference:** https://core.telegram.org/bots/api#forwardmessages
692
+ */
693
+ forwardMessages(chat_id, message_ids, other, signal) {
694
+ return this.api.forwardMessages(chat_id, orThrow(this.chatId, "forwardMessages"), message_ids, other, signal);
695
+ }
696
+ /**
697
+ * Context-aware alias for `api.copyMessage`. Use this method to copy messages of any kind. Service messages, paid media messages, giveaway messages, giveaway winners messages, and invoice messages can't be copied. A quiz poll can be copied only if the value of the field correct_option_id is known to the bot. The method is analogous to the method forwardMessage, but the copied message doesn't have a link to the original message. Returns the MessageId of the sent message on success.
698
+ *
699
+ * @param chat_id Unique identifier for the target chat or username of the target channel (in the format @channelusername)
700
+ * @param other Optional remaining parameters, confer the official reference below
701
+ * @param signal Optional `AbortSignal` to cancel the request
702
+ *
703
+ * **Official reference:** https://core.telegram.org/bots/api#copymessage
704
+ */
705
+ copyMessage(chat_id, other, signal) {
706
+ return this.api.copyMessage(chat_id, orThrow(this.chatId, "copyMessage"), orThrow(this.msgId, "copyMessage"), other, signal);
707
+ }
708
+ /**
709
+ * Context-aware alias for `api.copyMessages`. Use this method to copy messages of any kind. If some of the specified messages can't be found or copied, they are skipped. Service messages, paid media messages, giveaway messages, giveaway winners messages, and invoice messages can't be copied. A quiz poll can be copied only if the value of the field correct_option_id is known to the bot. The method is analogous to the method forwardMessages, but the copied messages don't have a link to the original message. Album grouping is kept for copied messages. On success, an array of MessageId of the sent messages is returned.
710
+ *
711
+ * @param chat_id Unique identifier for the target chat or username of the target channel (in the format @channelusername)
712
+ * @param message_ids A list of 1-100 identifiers of messages in the current chat to copy. The identifiers must be specified in a strictly increasing order.
713
+ * @param other Optional remaining parameters, confer the official reference below
714
+ * @param signal Optional `AbortSignal` to cancel the request
715
+ *
716
+ * **Official reference:** https://core.telegram.org/bots/api#copymessages
717
+ */
718
+ copyMessages(chat_id, message_ids, other, signal) {
719
+ return this.api.copyMessages(chat_id, orThrow(this.chatId, "copyMessages"), message_ids, other, signal);
720
+ }
721
+ /**
722
+ * Context-aware alias for `api.sendPhoto`. Use this method to send photos. On success, the sent Message is returned.
723
+ *
724
+ * @param photo Photo to send. Pass a file_id as String to send a photo that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get a photo from the Internet, or upload a new photo using multipart/form-data. The photo must be at most 10 MB in size. The photo's width and height must not exceed 10000 in total. Width and height ratio must be at most 20.
725
+ * @param other Optional remaining parameters, confer the official reference below
726
+ * @param signal Optional `AbortSignal` to cancel the request
727
+ *
728
+ * **Official reference:** https://core.telegram.org/bots/api#sendphoto
729
+ */
730
+ replyWithPhoto(photo, other, signal) {
731
+ return this.api.sendPhoto(orThrow(this.chatId, "sendPhoto"), photo, { business_connection_id: this.businessConnectionId, ...other }, signal);
732
+ }
733
+ /**
734
+ * Context-aware alias for `api.sendAudio`. Use this method to send audio files, if you want Telegram clients to display them in the music player. Your audio must be in the .MP3 or .M4A format. On success, the sent Message is returned. Bots can currently send audio files of up to 50 MB in size, this limit may be changed in the future.
735
+ *
736
+ * For sending voice messages, use the sendVoice method instead.
737
+ *
738
+ * @param audio Audio file to send. Pass a file_id as String to send an audio file that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get an audio file from the Internet, or upload a new one using multipart/form-data.
739
+ * @param other Optional remaining parameters, confer the official reference below
740
+ * @param signal Optional `AbortSignal` to cancel the request
741
+ *
742
+ * **Official reference:** https://core.telegram.org/bots/api#sendaudio
743
+ */
744
+ replyWithAudio(audio, other, signal) {
745
+ return this.api.sendAudio(orThrow(this.chatId, "sendAudio"), audio, { business_connection_id: this.businessConnectionId, ...other }, signal);
746
+ }
747
+ /**
748
+ * Context-aware alias for `api.sendDocument`. Use this method to send general files. On success, the sent Message is returned. Bots can currently send files of any type of up to 50 MB in size, this limit may be changed in the future.
749
+ *
750
+ * @param document File to send. Pass a file_id as String to send a file that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get a file from the Internet, or upload a new one using multipart/form-data.
751
+ * @param other Optional remaining parameters, confer the official reference below
752
+ * @param signal Optional `AbortSignal` to cancel the request
753
+ *
754
+ * **Official reference:** https://core.telegram.org/bots/api#senddocument
755
+ */
756
+ replyWithDocument(document, other, signal) {
757
+ return this.api.sendDocument(orThrow(this.chatId, "sendDocument"), document, { business_connection_id: this.businessConnectionId, ...other }, signal);
758
+ }
759
+ /**
760
+ * Context-aware alias for `api.sendVideo`. Use this method to send video files, Telegram clients support mp4 videos (other formats may be sent as Document). On success, the sent Message is returned. Bots can currently send video files of up to 50 MB in size, this limit may be changed in the future.
761
+ *
762
+ * @param video Video to send. Pass a file_id as String to send a video that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get a video from the Internet, or upload a new video using multipart/form-data.
763
+ * @param other Optional remaining parameters, confer the official reference below
764
+ * @param signal Optional `AbortSignal` to cancel the request
765
+ *
766
+ * **Official reference:** https://core.telegram.org/bots/api#sendvideo
767
+ */
768
+ replyWithVideo(video, other, signal) {
769
+ return this.api.sendVideo(orThrow(this.chatId, "sendVideo"), video, { business_connection_id: this.businessConnectionId, ...other }, signal);
770
+ }
771
+ /**
772
+ * Context-aware alias for `api.sendAnimation`. Use this method to send animation files (GIF or H.264/MPEG-4 AVC video without sound). On success, the sent Message is returned. Bots can currently send animation files of up to 50 MB in size, this limit may be changed in the future.
773
+ *
774
+ * @param animation Animation to send. Pass a file_id as String to send an animation that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get an animation from the Internet, or upload a new animation using multipart/form-data.
775
+ * @param other Optional remaining parameters, confer the official reference below
776
+ * @param signal Optional `AbortSignal` to cancel the request
777
+ *
778
+ * **Official reference:** https://core.telegram.org/bots/api#sendanimation
779
+ */
780
+ replyWithAnimation(animation, other, signal) {
781
+ return this.api.sendAnimation(orThrow(this.chatId, "sendAnimation"), animation, { business_connection_id: this.businessConnectionId, ...other }, signal);
782
+ }
783
+ /**
784
+ * Context-aware alias for `api.sendVoice`. Use this method to send audio files, if you want Telegram clients to display the file as a playable voice message. For this to work, your audio must be in an .OGG file encoded with OPUS (other formats may be sent as Audio or Document). On success, the sent Message is returned. Bots can currently send voice messages of up to 50 MB in size, this limit may be changed in the future.
785
+ *
786
+ * @param voice Audio file to send. Pass a file_id as String to send a file that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get a file from the Internet, or upload a new one using multipart/form-data.
787
+ * @param other Optional remaining parameters, confer the official reference below
788
+ * @param signal Optional `AbortSignal` to cancel the request
789
+ *
790
+ * **Official reference:** https://core.telegram.org/bots/api#sendvoice
791
+ */
792
+ replyWithVoice(voice, other, signal) {
793
+ return this.api.sendVoice(orThrow(this.chatId, "sendVoice"), voice, { business_connection_id: this.businessConnectionId, ...other }, signal);
794
+ }
795
+ /**
796
+ * Context-aware alias for `api.sendVideoNote`. Use this method to send video messages. On success, the sent Message is returned.
797
+ * As of v.4.0, Telegram clients support rounded square mp4 videos of up to 1 minute long.
798
+ *
799
+ * @param video_note Video note to send. Pass a file_id as String to send a video note that exists on the Telegram servers (recommended) or upload a new video using multipart/form-data.. Sending video notes by a URL is currently unsupported
800
+ * @param other Optional remaining parameters, confer the official reference below
801
+ * @param signal Optional `AbortSignal` to cancel the request
802
+ *
803
+ * **Official reference:** https://core.telegram.org/bots/api#sendvideonote
804
+ */
805
+ replyWithVideoNote(video_note, other, signal) {
806
+ return this.api.sendVideoNote(orThrow(this.chatId, "sendVideoNote"), video_note, { business_connection_id: this.businessConnectionId, ...other }, signal);
807
+ }
808
+ /**
809
+ * Context-aware alias for `api.sendMediaGroup`. Use this method to send a group of photos, videos, documents or audios as an album. Documents and audio files can be only grouped in an album with messages of the same type. On success, an array of Messages that were sent is returned.
810
+ *
811
+ * @param media An array describing messages to be sent, must include 2-10 items
812
+ * @param other Optional remaining parameters, confer the official reference below
813
+ * @param signal Optional `AbortSignal` to cancel the request
814
+ *
815
+ * **Official reference:** https://core.telegram.org/bots/api#sendmediagroup
816
+ */
817
+ replyWithMediaGroup(media, other, signal) {
818
+ return this.api.sendMediaGroup(orThrow(this.chatId, "sendMediaGroup"), media, { business_connection_id: this.businessConnectionId, ...other }, signal);
819
+ }
820
+ /**
821
+ * Context-aware alias for `api.sendLocation`. Use this method to send point on the map. On success, the sent Message is returned.
822
+ *
823
+ * @param latitude Latitude of the location
824
+ * @param longitude Longitude of the location
825
+ * @param other Optional remaining parameters, confer the official reference below
826
+ * @param signal Optional `AbortSignal` to cancel the request
827
+ *
828
+ * **Official reference:** https://core.telegram.org/bots/api#sendlocation
829
+ */
830
+ replyWithLocation(latitude, longitude, other, signal) {
831
+ return this.api.sendLocation(orThrow(this.chatId, "sendLocation"), latitude, longitude, { business_connection_id: this.businessConnectionId, ...other }, signal);
832
+ }
833
+ /**
834
+ * Context-aware alias for `api.editMessageLiveLocation`. Use this method to edit live location messages. A location can be edited until its live_period expires or editing is explicitly disabled by a call to stopMessageLiveLocation. On success, if the edited message is not an inline message, the edited Message is returned, otherwise True is returned.
835
+ *
836
+ * @param latitude Latitude of new location
837
+ * @param longitude Longitude of new location
838
+ * @param other Optional remaining parameters, confer the official reference below
839
+ * @param signal Optional `AbortSignal` to cancel the request
840
+ *
841
+ * **Official reference:** https://core.telegram.org/bots/api#editmessagelivelocation
842
+ */
843
+ editMessageLiveLocation(latitude, longitude, other, signal) {
844
+ const inlineId = this.inlineMessageId;
845
+ return inlineId !== undefined
846
+ ? this.api.editMessageLiveLocationInline(inlineId, latitude, longitude, { business_connection_id: this.businessConnectionId, ...other }, signal)
847
+ : this.api.editMessageLiveLocation(orThrow(this.chatId, "editMessageLiveLocation"), orThrow(this.msgId, "editMessageLiveLocation"), latitude, longitude, { business_connection_id: this.businessConnectionId, ...other }, signal);
848
+ }
849
+ /**
850
+ * Context-aware alias for `api.stopMessageLiveLocation`. Use this method to stop updating a live location message before live_period expires. On success, if the message is not an inline message, the edited Message is returned, otherwise True is returned.
851
+ *
852
+ * @param other Optional remaining parameters, confer the official reference below
853
+ * @param signal Optional `AbortSignal` to cancel the request
854
+ *
855
+ * **Official reference:** https://core.telegram.org/bots/api#stopmessagelivelocation
856
+ */
857
+ stopMessageLiveLocation(other, signal) {
858
+ const inlineId = this.inlineMessageId;
859
+ return inlineId !== undefined
860
+ ? this.api.stopMessageLiveLocationInline(inlineId, { business_connection_id: this.businessConnectionId, ...other }, signal)
861
+ : this.api.stopMessageLiveLocation(orThrow(this.chatId, "stopMessageLiveLocation"), orThrow(this.msgId, "stopMessageLiveLocation"), { business_connection_id: this.businessConnectionId, ...other }, signal);
862
+ }
863
+ /**
864
+ * Context-aware alias for `api.sendPaidMedia`. Use this method to send paid media. On success, the sent Message is returned.
865
+ *
866
+ * @param star_count The number of Telegram Stars that must be paid to buy access to the media
867
+ * @param media An array describing the media to be sent; up to 10 items
868
+ * @param other Optional remaining parameters, confer the official reference below
869
+ * @param signal Optional `AbortSignal` to cancel the request
870
+ *
871
+ * **Official reference:** https://core.telegram.org/bots/api#sendpaidmedia
872
+ */
873
+ sendPaidMedia(star_count, media, other, signal) {
874
+ return this.api.sendPaidMedia(orThrow(this.chatId, "sendPaidMedia"), star_count, media, { business_connection_id: this.businessConnectionId, ...other }, signal);
875
+ }
876
+ /**
877
+ * Context-aware alias for `api.sendVenue`. Use this method to send information about a venue. On success, the sent Message is returned.
878
+ *
879
+ * @param latitude Latitude of the venue
880
+ * @param longitude Longitude of the venue
881
+ * @param title Name of the venue
882
+ * @param address Address of the venue
883
+ * @param other Optional remaining parameters, confer the official reference below
884
+ * @param signal Optional `AbortSignal` to cancel the request
885
+ *
886
+ * **Official reference:** https://core.telegram.org/bots/api#sendvenue
887
+ */
888
+ replyWithVenue(latitude, longitude, title, address, other, signal) {
889
+ return this.api.sendVenue(orThrow(this.chatId, "sendVenue"), latitude, longitude, title, address, { business_connection_id: this.businessConnectionId, ...other }, signal);
890
+ }
891
+ /**
892
+ * Context-aware alias for `api.sendContact`. Use this method to send phone contacts. On success, the sent Message is returned.
893
+ *
894
+ * @param phone_number Contact's phone number
895
+ * @param first_name Contact's first name
896
+ * @param other Optional remaining parameters, confer the official reference below
897
+ * @param signal Optional `AbortSignal` to cancel the request
898
+ *
899
+ * **Official reference:** https://core.telegram.org/bots/api#sendcontact
900
+ */
901
+ replyWithContact(phone_number, first_name, other, signal) {
902
+ return this.api.sendContact(orThrow(this.chatId, "sendContact"), phone_number, first_name, { business_connection_id: this.businessConnectionId, ...other }, signal);
903
+ }
904
+ /**
905
+ * Context-aware alias for `api.sendPoll`. Use this method to send a native poll. On success, the sent Message is returned.
906
+ *
907
+ * @param question Poll question, 1-300 characters
908
+ * @param options A list of answer options, 2-10 strings 1-100 characters each
909
+ * @param other Optional remaining parameters, confer the official reference below
910
+ * @param signal Optional `AbortSignal` to cancel the request
911
+ *
912
+ * **Official reference:** https://core.telegram.org/bots/api#sendpoll
913
+ */
914
+ replyWithPoll(question, options, other, signal) {
915
+ return this.api.sendPoll(orThrow(this.chatId, "sendPoll"), question, options, { business_connection_id: this.businessConnectionId, ...other }, signal);
916
+ }
917
+ /**
918
+ * Context-aware alias for `api.sendDice`. Use this method to send an animated emoji that will display a random value. On success, the sent Message is returned.
919
+ *
920
+ * @param emoji Emoji on which the dice throw animation is based. Currently, must be one of “🎲”, “🎯”, “🏀”, “⚽”, “🎳”, or “🎰”. Dice can have values 1-6 for “🎲”, “🎯” and “🎳”, values 1-5 for “🏀” and “⚽”, and values 1-64 for “🎰”. Defaults to “🎲”
921
+ * @param other Optional remaining parameters, confer the official reference below
922
+ * @param signal Optional `AbortSignal` to cancel the request
923
+ *
924
+ * **Official reference:** https://core.telegram.org/bots/api#senddice
925
+ */
926
+ replyWithDice(emoji, other, signal) {
927
+ return this.api.sendDice(orThrow(this.chatId, "sendDice"), emoji, { business_connection_id: this.businessConnectionId, ...other }, signal);
928
+ }
929
+ /**
930
+ * Context-aware alias for `api.sendChatAction`. Use this method when you need to tell the user that something is happening on the bot's side. The status is set for 5 seconds or less (when a message arrives from your bot, Telegram clients clear its typing status). Returns True on success.
931
+ *
932
+ * Example: The ImageBot needs some time to process a request and upload the image. Instead of sending a text message along the lines of “Retrieving image, please wait…”, the bot may use sendChatAction with action = upload_photo. The user will see a “sending photo” status for the bot.
933
+ *
934
+ * We only recommend using this method when a response from the bot will take a noticeable amount of time to arrive.
935
+ *
936
+ * @param action Type of action to broadcast. Choose one, depending on what the user is about to receive: typing for text messages, upload_photo for photos, record_video or upload_video for videos, record_voice or upload_voice for voice notes, upload_document for general files, choose_sticker for stickers, find_location for location data, record_video_note or upload_video_note for video notes.
937
+ * @param other Optional remaining parameters, confer the official reference below
938
+ * @param signal Optional `AbortSignal` to cancel the request
939
+ *
940
+ * **Official reference:** https://core.telegram.org/bots/api#sendchataction
941
+ */
942
+ replyWithChatAction(action, other, signal) {
943
+ return this.api.sendChatAction(orThrow(this.chatId, "sendChatAction"), action, { business_connection_id: this.businessConnectionId, ...other }, signal);
944
+ }
945
+ /**
946
+ * Context-aware alias for `api.setMessageReaction`. Use this method to change the chosen reactions on a message. Service messages of some types can't be reacted to. Automatically forwarded messages from a channel to its discussion group have the same available reactions as messages in the channel. Bots can't use paid reactions. Returns True on success.
947
+ *
948
+ * @param reaction A list of reaction types to set on the message. Currently, as non-premium users, bots can set up to one reaction per message. A custom emoji reaction can be used if it is either already present on the message or explicitly allowed by chat administrators. Paid reactions can't be used by bots.
949
+ * @param other Optional remaining parameters, confer the official reference below
950
+ * @param signal Optional `AbortSignal` to cancel the request
951
+ *
952
+ * **Official reference:** https://core.telegram.org/bots/api#setmessagereaction
953
+ */
954
+ react(reaction, other, signal) {
955
+ return this.api.setMessageReaction(orThrow(this.chatId, "setMessageReaction"), orThrow(this.msgId, "setMessageReaction"), typeof reaction === "string"
956
+ ? [{ type: "emoji", emoji: reaction }]
957
+ : (Array.isArray(reaction) ? reaction : [reaction])
958
+ .map((emoji) => typeof emoji === "string"
959
+ ? { type: "emoji", emoji }
960
+ : emoji), other, signal);
961
+ }
962
+ /**
963
+ * Context-aware alias for `api.getUserProfilePhotos`. Use this method to get a list of profile pictures for a user. Returns a UserProfilePhotos object.
964
+ *
965
+ * @param user_id Unique identifier of the target user
966
+ * @param other Optional remaining parameters, confer the official reference below
967
+ * @param signal Optional `AbortSignal` to cancel the request
968
+ *
969
+ * **Official reference:** https://core.telegram.org/bots/api#getuserprofilephotos
970
+ */
971
+ getUserProfilePhotos(other, signal) {
972
+ return this.api.getUserProfilePhotos(orThrow(this.from, "getUserProfilePhotos").id, other, signal);
973
+ }
974
+ /**
975
+ * Contex-aware alias for `api.serUserEmojiStatus`. Changes the emoji status for a given user that previously allowed the bot to manage their emoji status via the Mini App method requestEmojiStatusAccess. Returns True on success.
976
+ *
977
+ * @param other Optional remaining parameters, confer the official reference below
978
+ * @param signal Optional `AbortSignal` to cancel the request
979
+ *
980
+ * **Official reference:** https://core.telegram.org/bots/api#setuseremojistatus
981
+ */
982
+ setUserEmojiStatus(other, signal) {
983
+ return this.api.setUserEmojiStatus(orThrow(this.from, "setUserEmojiStatus").id, other, signal);
984
+ }
985
+ /**
986
+ * Context-aware alias for `api.getUserChatBoosts`. Use this method to get the list of boosts added to a chat by a user. Requires administrator rights in the chat. Returns a UserChatBoosts object.
987
+ *
988
+ * @param chat_id Unique identifier for the chat or username of the channel (in the format @channelusername)
989
+ * @param signal Optional `AbortSignal` to cancel the request
990
+ *
991
+ * **Official reference:** https://core.telegram.org/bots/api#getuserchatboosts
992
+ */
993
+ getUserChatBoosts(chat_id, signal) {
994
+ return this.api.getUserChatBoosts(chat_id, orThrow(this.from, "getUserChatBoosts").id, signal);
995
+ }
996
+ /**
997
+ * Context-aware alias for `api.getBusinessConnection`. Use this method to get information about the connection of the bot with a business account. Returns a BusinessConnection object on success.
998
+ * @param signal Optional `AbortSignal` to cancel the request
999
+ *
1000
+ * **Official reference:** https://core.telegram.org/bots/api#getbusinessconnection
1001
+ */
1002
+ getBusinessConnection(signal) {
1003
+ return this.api.getBusinessConnection(orThrow(this.businessConnectionId, "getBusinessConnection"), signal);
1004
+ }
1005
+ /**
1006
+ * Context-aware alias for `api.getFile`. Use this method to get basic info about a file and prepare it for downloading. For the moment, bots can download files of up to 20MB in size. On success, a File object is returned. The file can then be downloaded via the link https://api.telegram.org/file/bot<token>/<file_path>, where <file_path> is taken from the response. It is guaranteed that the link will be valid for at least 1 hour. When the link expires, a new one can be requested by calling getFile again.
1007
+ *
1008
+ * Note: This function may not preserve the original file name and MIME type. You should save the file's MIME type and name (if available) when the File object is received.
1009
+ *
1010
+ * @param signal Optional `AbortSignal` to cancel the request
1011
+ *
1012
+ * **Official reference:** https://core.telegram.org/bots/api#getfile
1013
+ */
1014
+ getFile(signal) {
1015
+ var _a, _b, _c, _d, _e, _f;
1016
+ const m = orThrow(this.msg, "getFile");
1017
+ const file = m.photo !== undefined
1018
+ ? m.photo[m.photo.length - 1]
1019
+ : (_f = (_e = (_d = (_c = (_b = (_a = m.animation) !== null && _a !== void 0 ? _a : m.audio) !== null && _b !== void 0 ? _b : m.document) !== null && _c !== void 0 ? _c : m.video) !== null && _d !== void 0 ? _d : m.video_note) !== null && _e !== void 0 ? _e : m.voice) !== null && _f !== void 0 ? _f : m.sticker;
1020
+ return this.api.getFile(orThrow(file, "getFile").file_id, signal);
1021
+ }
1022
+ /** @deprecated Use `banAuthor` instead. */
1023
+ kickAuthor(...args) {
1024
+ return this.banAuthor(...args);
1025
+ }
1026
+ /**
1027
+ * Context-aware alias for `api.banChatMember`. Use this method to ban a user in a group, a supergroup or a channel. In the case of supergroups and channels, the user will not be able to return to the chat on their own using invite links, etc., unless unbanned first. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns True on success.
1028
+ *
1029
+ * @param other Optional remaining parameters, confer the official reference below
1030
+ * @param signal Optional `AbortSignal` to cancel the request
1031
+ *
1032
+ * **Official reference:** https://core.telegram.org/bots/api#banchatmember
1033
+ */
1034
+ banAuthor(other, signal) {
1035
+ return this.api.banChatMember(orThrow(this.chatId, "banAuthor"), orThrow(this.from, "banAuthor").id, other, signal);
1036
+ }
1037
+ /** @deprecated Use `banChatMember` instead. */
1038
+ kickChatMember(...args) {
1039
+ return this.banChatMember(...args);
1040
+ }
1041
+ /**
1042
+ * Context-aware alias for `api.banChatMember`. Use this method to ban a user in a group, a supergroup or a channel. In the case of supergroups and channels, the user will not be able to return to the chat on their own using invite links, etc., unless unbanned first. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns True on success.
1043
+ *
1044
+ * @param user_id Unique identifier of the target user
1045
+ * @param other Optional remaining parameters, confer the official reference below
1046
+ * @param signal Optional `AbortSignal` to cancel the request
1047
+ *
1048
+ * **Official reference:** https://core.telegram.org/bots/api#banchatmember
1049
+ */
1050
+ banChatMember(user_id, other, signal) {
1051
+ return this.api.banChatMember(orThrow(this.chatId, "banChatMember"), user_id, other, signal);
1052
+ }
1053
+ /**
1054
+ * Context-aware alias for `api.unbanChatMember`. Use this method to unban a previously banned user in a supergroup or channel. The user will not return to the group or channel automatically, but will be able to join via link, etc. The bot must be an administrator for this to work. By default, this method guarantees that after the call the user is not a member of the chat, but will be able to join it. So if the user is a member of the chat they will also be removed from the chat. If you don't want this, use the parameter only_if_banned. Returns True on success.
1055
+ *
1056
+ * @param user_id Unique identifier of the target user
1057
+ * @param other Optional remaining parameters, confer the official reference below
1058
+ * @param signal Optional `AbortSignal` to cancel the request
1059
+ *
1060
+ * **Official reference:** https://core.telegram.org/bots/api#unbanchatmember
1061
+ */
1062
+ unbanChatMember(user_id, other, signal) {
1063
+ return this.api.unbanChatMember(orThrow(this.chatId, "unbanChatMember"), user_id, other, signal);
1064
+ }
1065
+ /**
1066
+ * Context-aware alias for `api.restrictChatMember`. Use this method to restrict a user in a supergroup. The bot must be an administrator in the supergroup for this to work and must have the appropriate administrator rights. Pass True for all permissions to lift restrictions from a user. Returns True on success.
1067
+ *
1068
+ * @param permissions An object for new user permissions
1069
+ * @param other Optional remaining parameters, confer the official reference below
1070
+ * @param signal Optional `AbortSignal` to cancel the request
1071
+ *
1072
+ * **Official reference:** https://core.telegram.org/bots/api#restrictchatmember
1073
+ */
1074
+ restrictAuthor(permissions, other, signal) {
1075
+ return this.api.restrictChatMember(orThrow(this.chatId, "restrictAuthor"), orThrow(this.from, "restrictAuthor").id, permissions, other, signal);
1076
+ }
1077
+ /**
1078
+ * Context-aware alias for `api.restrictChatMember`. Use this method to restrict a user in a supergroup. The bot must be an administrator in the supergroup for this to work and must have the appropriate administrator rights. Pass True for all permissions to lift restrictions from a user. Returns True on success.
1079
+ *
1080
+ * @param user_id Unique identifier of the target user
1081
+ * @param permissions An object for new user permissions
1082
+ * @param other Optional remaining parameters, confer the official reference below
1083
+ * @param signal Optional `AbortSignal` to cancel the request
1084
+ *
1085
+ * **Official reference:** https://core.telegram.org/bots/api#restrictchatmember
1086
+ */
1087
+ restrictChatMember(user_id, permissions, other, signal) {
1088
+ return this.api.restrictChatMember(orThrow(this.chatId, "restrictChatMember"), user_id, permissions, other, signal);
1089
+ }
1090
+ /**
1091
+ * Context-aware alias for `api.promoteChatMember`. Use this method to promote or demote a user in a supergroup or a channel. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Pass False for all boolean parameters to demote a user. Returns True on success.
1092
+ *
1093
+ * @param other Optional remaining parameters, confer the official reference below
1094
+ * @param signal Optional `AbortSignal` to cancel the request
1095
+ *
1096
+ * **Official reference:** https://core.telegram.org/bots/api#promotechatmember
1097
+ */
1098
+ promoteAuthor(other, signal) {
1099
+ return this.api.promoteChatMember(orThrow(this.chatId, "promoteAuthor"), orThrow(this.from, "promoteAuthor").id, other, signal);
1100
+ }
1101
+ /**
1102
+ * Context-aware alias for `api.promoteChatMember`. Use this method to promote or demote a user in a supergroup or a channel. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Pass False for all boolean parameters to demote a user. Returns True on success.
1103
+ *
1104
+ * @param user_id Unique identifier of the target user
1105
+ * @param other Optional remaining parameters, confer the official reference below
1106
+ * @param signal Optional `AbortSignal` to cancel the request
1107
+ *
1108
+ * **Official reference:** https://core.telegram.org/bots/api#promotechatmember
1109
+ */
1110
+ promoteChatMember(user_id, other, signal) {
1111
+ return this.api.promoteChatMember(orThrow(this.chatId, "promoteChatMember"), user_id, other, signal);
1112
+ }
1113
+ /**
1114
+ * Context-aware alias for `api.setChatAdministratorCustomTitle`. Use this method to set a custom title for an administrator in a supergroup promoted by the bot. Returns True on success.
1115
+ *
1116
+ * @param custom_title New custom title for the administrator; 0-16 characters, emoji are not allowed
1117
+ * @param signal Optional `AbortSignal` to cancel the request
1118
+ *
1119
+ * **Official reference:** https://core.telegram.org/bots/api#setchatadministratorcustomtitle
1120
+ */
1121
+ setChatAdministratorAuthorCustomTitle(custom_title, signal) {
1122
+ return this.api.setChatAdministratorCustomTitle(orThrow(this.chatId, "setChatAdministratorAuthorCustomTitle"), orThrow(this.from, "setChatAdministratorAuthorCustomTitle").id, custom_title, signal);
1123
+ }
1124
+ /**
1125
+ * Context-aware alias for `api.setChatAdministratorCustomTitle`. Use this method to set a custom title for an administrator in a supergroup promoted by the bot. Returns True on success.
1126
+ *
1127
+ * @param user_id Unique identifier of the target user
1128
+ * @param custom_title New custom title for the administrator; 0-16 characters, emoji are not allowed
1129
+ * @param signal Optional `AbortSignal` to cancel the request
1130
+ *
1131
+ * **Official reference:** https://core.telegram.org/bots/api#setchatadministratorcustomtitle
1132
+ */
1133
+ setChatAdministratorCustomTitle(user_id, custom_title, signal) {
1134
+ return this.api.setChatAdministratorCustomTitle(orThrow(this.chatId, "setChatAdministratorCustomTitle"), user_id, custom_title, signal);
1135
+ }
1136
+ /**
1137
+ * Context-aware alias for `api.banChatSenderChat`. Use this method to ban a channel chat in a supergroup or a channel. Until the chat is unbanned, the owner of the banned chat won't be able to send messages on behalf of any of their channels. The bot must be an administrator in the supergroup or channel for this to work and must have the appropriate administrator rights. Returns True on success.
1138
+ *
1139
+ * @param sender_chat_id Unique identifier of the target sender chat
1140
+ * @param signal Optional `AbortSignal` to cancel the request
1141
+ *
1142
+ * **Official reference:** https://core.telegram.org/bots/api#banchatsenderchat
1143
+ */
1144
+ banChatSenderChat(sender_chat_id, signal) {
1145
+ return this.api.banChatSenderChat(orThrow(this.chatId, "banChatSenderChat"), sender_chat_id, signal);
1146
+ }
1147
+ /**
1148
+ * Context-aware alias for `api.unbanChatSenderChat`. Use this method to unban a previously banned channel chat in a supergroup or channel. The bot must be an administrator for this to work and must have the appropriate administrator rights. Returns True on success.
1149
+ *
1150
+ * @param sender_chat_id Unique identifier of the target sender chat
1151
+ * @param signal Optional `AbortSignal` to cancel the request
1152
+ *
1153
+ * **Official reference:** https://core.telegram.org/bots/api#unbanchatsenderchat
1154
+ */
1155
+ unbanChatSenderChat(sender_chat_id, signal) {
1156
+ return this.api.unbanChatSenderChat(orThrow(this.chatId, "unbanChatSenderChat"), sender_chat_id, signal);
1157
+ }
1158
+ /**
1159
+ * Context-aware alias for `api.setChatPermissions`. Use this method to set default chat permissions for all members. The bot must be an administrator in the group or a supergroup for this to work and must have the can_restrict_members administrator rights. Returns True on success.
1160
+ *
1161
+ * @param permissions New default chat permissions
1162
+ * @param other Optional remaining parameters, confer the official reference below
1163
+ * @param signal Optional `AbortSignal` to cancel the request
1164
+ *
1165
+ * **Official reference:** https://core.telegram.org/bots/api#setchatpermissions
1166
+ */
1167
+ setChatPermissions(permissions, other, signal) {
1168
+ return this.api.setChatPermissions(orThrow(this.chatId, "setChatPermissions"), permissions, other, signal);
1169
+ }
1170
+ /**
1171
+ * Context-aware alias for `api.exportChatInviteLink`. Use this method to generate a new primary invite link for a chat; any previously generated primary link is revoked. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns the new invite link as String on success.
1172
+ *
1173
+ * Note: Each administrator in a chat generates their own invite links. Bots can't use invite links generated by other administrators. If you want your bot to work with invite links, it will need to generate its own link using exportChatInviteLink or by calling the getChat method. If your bot needs to generate a new primary invite link replacing its previous one, use exportChatInviteLink again.
1174
+ *
1175
+ * @param signal Optional `AbortSignal` to cancel the request
1176
+ *
1177
+ * **Official reference:** https://core.telegram.org/bots/api#exportchatinvitelink
1178
+ */
1179
+ exportChatInviteLink(signal) {
1180
+ return this.api.exportChatInviteLink(orThrow(this.chatId, "exportChatInviteLink"), signal);
1181
+ }
1182
+ /**
1183
+ * Context-aware alias for `api.createChatInviteLink`. Use this method to create an additional invite link for a chat. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. The link can be revoked using the method revokeChatInviteLink. Returns the new invite link as ChatInviteLink object.
1184
+ *
1185
+ * @param other Optional remaining parameters, confer the official reference below
1186
+ * @param signal Optional `AbortSignal` to cancel the request
1187
+ *
1188
+ * **Official reference:** https://core.telegram.org/bots/api#createchatinvitelink
1189
+ */
1190
+ createChatInviteLink(other, signal) {
1191
+ return this.api.createChatInviteLink(orThrow(this.chatId, "createChatInviteLink"), other, signal);
1192
+ }
1193
+ /**
1194
+ * Context-aware alias for `api.editChatInviteLink`. Use this method to edit a non-primary invite link created by the bot. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns the edited invite link as a ChatInviteLink object.
1195
+ *
1196
+ * @param invite_link The invite link to edit
1197
+ * @param other Optional remaining parameters, confer the official reference below
1198
+ * @param signal Optional `AbortSignal` to cancel the request
1199
+ *
1200
+ * **Official reference:** https://core.telegram.org/bots/api#editchatinvitelink
1201
+ */
1202
+ editChatInviteLink(invite_link, other, signal) {
1203
+ return this.api.editChatInviteLink(orThrow(this.chatId, "editChatInviteLink"), invite_link, other, signal);
1204
+ }
1205
+ /**
1206
+ * Context-aware alias for `api.createChatSubscriptionInviteLink`. Use this method to create a subscription invite link for a channel chat. The bot must have the can_invite_users administrator rights. The link can be edited using the method editChatSubscriptionInviteLink or revoked using the method revokeChatInviteLink. Returns the new invite link as a ChatInviteLink object.
1207
+ *
1208
+ * @param subscription_period The number of seconds the subscription will be active for before the next payment. Currently, it must always be 2592000 (30 days).
1209
+ * @param subscription_price The amount of Telegram Stars a user must pay initially and after each subsequent subscription period to be a member of the chat; 1-2500
1210
+ * @param other Optional remaining parameters, confer the official reference below
1211
+ * @param signal Optional `AbortSignal` to cancel the request
1212
+ *
1213
+ * **Official reference:** https://core.telegram.org/bots/api#createchatsubscriptioninvitelink
1214
+ */
1215
+ createChatSubscriptionInviteLink(subscription_period, subscription_price, other, signal) {
1216
+ return this.api.createChatSubscriptionInviteLink(orThrow(this.chatId, "createChatSubscriptionInviteLink"), subscription_period, subscription_price, other, signal);
1217
+ }
1218
+ /**
1219
+ * Context-aware alias for `api.editChatSubscriptionInviteLink`. Use this method to edit a subscription invite link created by the bot. The bot must have the can_invite_users administrator rights. Returns the edited invite link as a ChatInviteLink object.
1220
+ *
1221
+ * @param invite_link The invite link to edit
1222
+ * @param other Optional remaining parameters, confer the official reference below
1223
+ * @param signal Optional `AbortSignal` to cancel the request
1224
+ *
1225
+ * **Official reference:** https://core.telegram.org/bots/api#editchatsubscriptioninvitelink
1226
+ */
1227
+ editChatSubscriptionInviteLink(invite_link, other, signal) {
1228
+ return this.api.editChatSubscriptionInviteLink(orThrow(this.chatId, "editChatSubscriptionInviteLink"), invite_link, other, signal);
1229
+ }
1230
+ /**
1231
+ * Context-aware alias for `api.revokeChatInviteLink`. Use this method to revoke an invite link created by the bot. If the primary link is revoked, a new link is automatically generated. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns the revoked invite link as ChatInviteLink object.
1232
+ *
1233
+ * @param invite_link The invite link to revoke
1234
+ * @param signal Optional `AbortSignal` to cancel the request
1235
+ *
1236
+ * **Official reference:** https://core.telegram.org/bots/api#revokechatinvitelink
1237
+ */
1238
+ revokeChatInviteLink(invite_link, signal) {
1239
+ return this.api.revokeChatInviteLink(orThrow(this.chatId, "editChatInviteLink"), invite_link, signal);
1240
+ }
1241
+ /**
1242
+ * Context-aware alias for `api.approveChatJoinRequest`. Use this method to approve a chat join request. The bot must be an administrator in the chat for this to work and must have the can_invite_users administrator right. Returns True on success.
1243
+ *
1244
+ * @param user_id Unique identifier of the target user
1245
+ * @param signal Optional `AbortSignal` to cancel the request
1246
+ *
1247
+ * **Official reference:** https://core.telegram.org/bots/api#approvechatjoinrequest
1248
+ */
1249
+ approveChatJoinRequest(user_id, signal) {
1250
+ return this.api.approveChatJoinRequest(orThrow(this.chatId, "approveChatJoinRequest"), user_id, signal);
1251
+ }
1252
+ /**
1253
+ * Context-aware alias for `api.declineChatJoinRequest`. Use this method to decline a chat join request. The bot must be an administrator in the chat for this to work and must have the can_invite_users administrator right. Returns True on success.
1254
+ *
1255
+ * @param user_id Unique identifier of the target user
1256
+ * @param signal Optional `AbortSignal` to cancel the request
1257
+ *
1258
+ * **Official reference:** https://core.telegram.org/bots/api#declinechatjoinrequest
1259
+ */
1260
+ declineChatJoinRequest(user_id, signal) {
1261
+ return this.api.declineChatJoinRequest(orThrow(this.chatId, "declineChatJoinRequest"), user_id, signal);
1262
+ }
1263
+ /**
1264
+ * Context-aware alias for `api.setChatPhoto`. Use this method to set a new profile photo for the chat. Photos can't be changed for private chats. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns True on success.
1265
+ *
1266
+ * @param photo New chat photo, uploaded using multipart/form-data
1267
+ * @param signal Optional `AbortSignal` to cancel the request
1268
+ *
1269
+ * **Official reference:** https://core.telegram.org/bots/api#setchatphoto
1270
+ */
1271
+ setChatPhoto(photo, signal) {
1272
+ return this.api.setChatPhoto(orThrow(this.chatId, "setChatPhoto"), photo, signal);
1273
+ }
1274
+ /**
1275
+ * Context-aware alias for `api.deleteChatPhoto`. Use this method to delete a chat photo. Photos can't be changed for private chats. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns True on success.
1276
+ *
1277
+ * @param signal Optional `AbortSignal` to cancel the request
1278
+ *
1279
+ * **Official reference:** https://core.telegram.org/bots/api#deletechatphoto
1280
+ */
1281
+ deleteChatPhoto(signal) {
1282
+ return this.api.deleteChatPhoto(orThrow(this.chatId, "deleteChatPhoto"), signal);
1283
+ }
1284
+ /**
1285
+ * Context-aware alias for `api.setChatTitle`. Use this method to change the title of a chat. Titles can't be changed for private chats. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns True on success.
1286
+ *
1287
+ * @param title New chat title, 1-255 characters
1288
+ * @param signal Optional `AbortSignal` to cancel the request
1289
+ *
1290
+ * **Official reference:** https://core.telegram.org/bots/api#setchattitle
1291
+ */
1292
+ setChatTitle(title, signal) {
1293
+ return this.api.setChatTitle(orThrow(this.chatId, "setChatTitle"), title, signal);
1294
+ }
1295
+ /**
1296
+ * Context-aware alias for `api.setChatDescription`. Use this method to change the description of a group, a supergroup or a channel. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns True on success.
1297
+ *
1298
+ * @param description New chat description, 0-255 characters
1299
+ * @param signal Optional `AbortSignal` to cancel the request
1300
+ *
1301
+ * **Official reference:** https://core.telegram.org/bots/api#setchatdescription
1302
+ */
1303
+ setChatDescription(description, signal) {
1304
+ return this.api.setChatDescription(orThrow(this.chatId, "setChatDescription"), description, signal);
1305
+ }
1306
+ /**
1307
+ * Context-aware alias for `api.pinChatMessage`. Use this method to add a message to the list of pinned messages in a chat. If the chat is not a private chat, the bot must be an administrator in the chat for this to work and must have the 'can_pin_messages' administrator right in a supergroup or 'can_edit_messages' administrator right in a channel. Returns True on success.
1308
+ *
1309
+ * @param message_id Identifier of a message to pin
1310
+ * @param other Optional remaining parameters, confer the official reference below
1311
+ * @param signal Optional `AbortSignal` to cancel the request
1312
+ *
1313
+ * **Official reference:** https://core.telegram.org/bots/api#pinchatmessage
1314
+ */
1315
+ pinChatMessage(message_id, other, signal) {
1316
+ return this.api.pinChatMessage(orThrow(this.chatId, "pinChatMessage"), message_id, { business_connection_id: this.businessConnectionId, ...other }, signal);
1317
+ }
1318
+ /**
1319
+ * Context-aware alias for `api.unpinChatMessage`. Use this method to remove a message from the list of pinned messages in a chat. If the chat is not a private chat, the bot must be an administrator in the chat for this to work and must have the 'can_pin_messages' administrator right in a supergroup or 'can_edit_messages' administrator right in a channel. Returns True on success.
1320
+ *
1321
+ * @param message_id Identifier of a message to unpin. If not specified, the most recent pinned message (by sending date) will be unpinned.
1322
+ * @param signal Optional `AbortSignal` to cancel the request
1323
+ *
1324
+ * **Official reference:** https://core.telegram.org/bots/api#unpinchatmessage
1325
+ */
1326
+ unpinChatMessage(message_id, other, signal) {
1327
+ return this.api.unpinChatMessage(orThrow(this.chatId, "unpinChatMessage"), message_id, { business_connection_id: this.businessConnectionId, ...other }, signal);
1328
+ }
1329
+ /**
1330
+ * Context-aware alias for `api.unpinAllChatMessages`. Use this method to clear the list of pinned messages in a chat. If the chat is not a private chat, the bot must be an administrator in the chat for this to work and must have the 'can_pin_messages' administrator right in a supergroup or 'can_edit_messages' administrator right in a channel. Returns True on success.
1331
+ *
1332
+ * @param signal Optional `AbortSignal` to cancel the request
1333
+ *
1334
+ * **Official reference:** https://core.telegram.org/bots/api#unpinallchatmessages
1335
+ */
1336
+ unpinAllChatMessages(signal) {
1337
+ return this.api.unpinAllChatMessages(orThrow(this.chatId, "unpinAllChatMessages"), signal);
1338
+ }
1339
+ /**
1340
+ * Context-aware alias for `api.leaveChat`. Use this method for your bot to leave a group, supergroup or channel. Returns True on success.
1341
+ *
1342
+ * @param signal Optional `AbortSignal` to cancel the request
1343
+ *
1344
+ * **Official reference:** https://core.telegram.org/bots/api#leavechat
1345
+ */
1346
+ leaveChat(signal) {
1347
+ return this.api.leaveChat(orThrow(this.chatId, "leaveChat"), signal);
1348
+ }
1349
+ /**
1350
+ * Context-aware alias for `api.getChat`. Use this method to get up to date information about the chat (current name of the user for one-on-one conversations, current username of a user, group or channel, etc.). Returns a Chat object on success.
1351
+ *
1352
+ * @param signal Optional `AbortSignal` to cancel the request
1353
+ *
1354
+ * **Official reference:** https://core.telegram.org/bots/api#getchat
1355
+ */
1356
+ getChat(signal) {
1357
+ return this.api.getChat(orThrow(this.chatId, "getChat"), signal);
1358
+ }
1359
+ /**
1360
+ * Context-aware alias for `api.getChatAdministrators`. Use this method to get a list of administrators in a chat, which aren't bots. Returns an Array of ChatMember objects.
1361
+ *
1362
+ * @param signal Optional `AbortSignal` to cancel the request
1363
+ *
1364
+ * **Official reference:** https://core.telegram.org/bots/api#getchatadministrators
1365
+ */
1366
+ getChatAdministrators(signal) {
1367
+ return this.api.getChatAdministrators(orThrow(this.chatId, "getChatAdministrators"), signal);
1368
+ }
1369
+ /** @deprecated Use `getChatMembersCount` instead. */
1370
+ getChatMembersCount(...args) {
1371
+ return this.getChatMemberCount(...args);
1372
+ }
1373
+ /**
1374
+ * Context-aware alias for `api.getChatMemberCount`. Use this method to get the number of members in a chat. Returns Int on success.
1375
+ *
1376
+ * @param signal Optional `AbortSignal` to cancel the request
1377
+ *
1378
+ * **Official reference:** https://core.telegram.org/bots/api#getchatmembercount
1379
+ */
1380
+ getChatMemberCount(signal) {
1381
+ return this.api.getChatMemberCount(orThrow(this.chatId, "getChatMemberCount"), signal);
1382
+ }
1383
+ /**
1384
+ * Context-aware alias for `api.getChatMember`. Use this method to get information about a member of a chat. The method is guaranteed to work only if the bot is an administrator in the chat. Returns a ChatMember object on success.
1385
+ *
1386
+ * @param signal Optional `AbortSignal` to cancel the request
1387
+ *
1388
+ * **Official reference:** https://core.telegram.org/bots/api#getchatmember
1389
+ */
1390
+ getAuthor(signal) {
1391
+ return this.api.getChatMember(orThrow(this.chatId, "getAuthor"), orThrow(this.from, "getAuthor").id, signal);
1392
+ }
1393
+ /**
1394
+ * Context-aware alias for `api.getChatMember`. Use this method to get information about a member of a chat. The method is guaranteed to work only if the bot is an administrator in the chat. Returns a ChatMember object on success.
1395
+ *
1396
+ * @param user_id Unique identifier of the target user
1397
+ * @param signal Optional `AbortSignal` to cancel the request
1398
+ *
1399
+ * **Official reference:** https://core.telegram.org/bots/api#getchatmember
1400
+ */
1401
+ getChatMember(user_id, signal) {
1402
+ return this.api.getChatMember(orThrow(this.chatId, "getChatMember"), user_id, signal);
1403
+ }
1404
+ /**
1405
+ * Context-aware alias for `api.setChatStickerSet`. Use this method to set a new group sticker set for a supergroup. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Use the field can_set_sticker_set ly returned in getChat requests to check if the bot can use this method. Returns True on success.
1406
+ *
1407
+ * @param sticker_set_name Name of the sticker set to be set as the group sticker set
1408
+ * @param signal Optional `AbortSignal` to cancel the request
1409
+ *
1410
+ * **Official reference:** https://core.telegram.org/bots/api#setchatstickerset
1411
+ */
1412
+ setChatStickerSet(sticker_set_name, signal) {
1413
+ return this.api.setChatStickerSet(orThrow(this.chatId, "setChatStickerSet"), sticker_set_name, signal);
1414
+ }
1415
+ /**
1416
+ * Context-aware alias for `api.deleteChatStickerSet`. Use this method to delete a group sticker set from a supergroup. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Use the field can_set_sticker_set ly returned in getChat requests to check if the bot can use this method. Returns True on success.
1417
+ *
1418
+ * @param signal Optional `AbortSignal` to cancel the request
1419
+ *
1420
+ * **Official reference:** https://core.telegram.org/bots/api#deletechatstickerset
1421
+ */
1422
+ deleteChatStickerSet(signal) {
1423
+ return this.api.deleteChatStickerSet(orThrow(this.chatId, "deleteChatStickerSet"), signal);
1424
+ }
1425
+ /**
1426
+ * Context-aware alias for `api.createForumTopic`. Use this method to create a topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights. Returns information about the created topic as a ForumTopic object.
1427
+ *
1428
+ * @param name Topic name, 1-128 characters
1429
+ * @param other Optional remaining parameters, confer the official reference below
1430
+ * @param signal Optional `AbortSignal` to cancel the request
1431
+ *
1432
+ * **Official reference:** https://core.telegram.org/bots/api#createforumtopic
1433
+ */
1434
+ createForumTopic(name, other, signal) {
1435
+ return this.api.createForumTopic(orThrow(this.chatId, "createForumTopic"), name, other, signal);
1436
+ }
1437
+ /**
1438
+ * Context-aware alias for `api.editForumTopic`. Use this method to edit name and icon of a topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights, unless it is the creator of the topic. Returns True on success.
1439
+ *
1440
+ * @param other Optional remaining parameters, confer the official reference below
1441
+ * @param signal Optional `AbortSignal` to cancel the request
1442
+ *
1443
+ * **Official reference:** https://core.telegram.org/bots/api#editforumtopic
1444
+ */
1445
+ editForumTopic(other, signal) {
1446
+ const message = orThrow(this.msg, "editForumTopic");
1447
+ const thread = orThrow(message.message_thread_id, "editForumTopic");
1448
+ return this.api.editForumTopic(message.chat.id, thread, other, signal);
1449
+ }
1450
+ /**
1451
+ * Context-aware alias for `api.closeForumTopic`. Use this method to close an open topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights, unless it is the creator of the topic. Returns True on success.
1452
+ *
1453
+ * @param signal Optional `AbortSignal` to cancel the request
1454
+ *
1455
+ * **Official reference:** https://core.telegram.org/bots/api#closeforumtopic
1456
+ */
1457
+ closeForumTopic(signal) {
1458
+ const message = orThrow(this.msg, "closeForumTopic");
1459
+ const thread = orThrow(message.message_thread_id, "closeForumTopic");
1460
+ return this.api.closeForumTopic(message.chat.id, thread, signal);
1461
+ }
1462
+ /**
1463
+ * Context-aware alias for `api.reopenForumTopic`. Use this method to reopen a closed topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights, unless it is the creator of the topic. Returns True on success.
1464
+ *
1465
+ * @param signal Optional `AbortSignal` to cancel the request
1466
+ *
1467
+ * **Official reference:** https://core.telegram.org/bots/api#reopenforumtopic
1468
+ */
1469
+ reopenForumTopic(signal) {
1470
+ const message = orThrow(this.msg, "reopenForumTopic");
1471
+ const thread = orThrow(message.message_thread_id, "reopenForumTopic");
1472
+ return this.api.reopenForumTopic(message.chat.id, thread, signal);
1473
+ }
1474
+ /**
1475
+ * Context-aware alias for `api.deleteForumTopic`. Use this method to delete a forum topic along with all its messages in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the can_delete_messages administrator rights. Returns True on success.
1476
+ *
1477
+ * @param signal Optional `AbortSignal` to cancel the request
1478
+ *
1479
+ * **Official reference:** https://core.telegram.org/bots/api#deleteforumtopic
1480
+ */
1481
+ deleteForumTopic(signal) {
1482
+ const message = orThrow(this.msg, "deleteForumTopic");
1483
+ const thread = orThrow(message.message_thread_id, "deleteForumTopic");
1484
+ return this.api.deleteForumTopic(message.chat.id, thread, signal);
1485
+ }
1486
+ /**
1487
+ * Context-aware alias for `api.unpinAllForumTopicMessages`. Use this method to clear the list of pinned messages in a forum topic. The bot must be an administrator in the chat for this to work and must have the can_pin_messages administrator right in the supergroup. Returns True on success.
1488
+ *
1489
+ * @param signal Optional `AbortSignal` to cancel the request
1490
+ *
1491
+ * **Official reference:** https://core.telegram.org/bots/api#unpinallforumtopicmessages
1492
+ */
1493
+ unpinAllForumTopicMessages(signal) {
1494
+ const message = orThrow(this.msg, "unpinAllForumTopicMessages");
1495
+ const thread = orThrow(message.message_thread_id, "unpinAllForumTopicMessages");
1496
+ return this.api.unpinAllForumTopicMessages(message.chat.id, thread, signal);
1497
+ }
1498
+ /**
1499
+ * Context-aware alias for `api.editGeneralForumTopic`. Use this method to edit the name of the 'General' topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights. Returns True on success.
1500
+ *
1501
+ * @param name New topic name, 1-128 characters
1502
+ * @param signal Optional `AbortSignal` to cancel the request
1503
+ *
1504
+ * **Official reference:** https://core.telegram.org/bots/api#editgeneralforumtopic
1505
+ */
1506
+ editGeneralForumTopic(name, signal) {
1507
+ return this.api.editGeneralForumTopic(orThrow(this.chatId, "editGeneralForumTopic"), name, signal);
1508
+ }
1509
+ /**
1510
+ * Context-aware alias for `api.closeGeneralForumTopic`. Use this method to close an open 'General' topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights. Returns True on success.
1511
+ *
1512
+ * @param signal Optional `AbortSignal` to cancel the request
1513
+ *
1514
+ * **Official reference:** https://core.telegram.org/bots/api#closegeneralforumtopic
1515
+ */
1516
+ closeGeneralForumTopic(signal) {
1517
+ return this.api.closeGeneralForumTopic(orThrow(this.chatId, "closeGeneralForumTopic"), signal);
1518
+ }
1519
+ /**
1520
+ * Context-aware alias for `api.reopenGeneralForumTopic`. Use this method to reopen a closed 'General' topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights. The topic will be automatically unhidden if it was hidden. Returns True on success. *
1521
+ *
1522
+ * @param signal Optional `AbortSignal` to cancel the request
1523
+ *
1524
+ * **Official reference:** https://core.telegram.org/bots/api#reopengeneralforumtopic
1525
+ */
1526
+ reopenGeneralForumTopic(signal) {
1527
+ return this.api.reopenGeneralForumTopic(orThrow(this.chatId, "reopenGeneralForumTopic"), signal);
1528
+ }
1529
+ /**
1530
+ * Context-aware alias for `api.hideGeneralForumTopic`. Use this method to hide the 'General' topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights. The topic will be automatically closed if it was open. Returns True on success.
1531
+ *
1532
+ * @param signal Optional `AbortSignal` to cancel the request
1533
+ *
1534
+ * **Official reference:** https://core.telegram.org/bots/api#hidegeneralforumtopic
1535
+ */
1536
+ hideGeneralForumTopic(signal) {
1537
+ return this.api.hideGeneralForumTopic(orThrow(this.chatId, "hideGeneralForumTopic"), signal);
1538
+ }
1539
+ /**
1540
+ * Context-aware alias for `api.unhideGeneralForumTopic`. Use this method to unhide the 'General' topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights. Returns True on success.
1541
+ *
1542
+ * @param signal Optional `AbortSignal` to cancel the request
1543
+ *
1544
+ * **Official reference:** https://core.telegram.org/bots/api#unhidegeneralforumtopic
1545
+ */
1546
+ unhideGeneralForumTopic(signal) {
1547
+ return this.api.unhideGeneralForumTopic(orThrow(this.chatId, "unhideGeneralForumTopic"), signal);
1548
+ }
1549
+ /**
1550
+ * Context-aware alias for `api.unpinAllGeneralForumTopicMessages`. Use this method to clear the list of pinned messages in a General forum topic. The bot must be an administrator in the chat for this to work and must have the can_pin_messages administrator right in the supergroup. Returns True on success.
1551
+ *
1552
+ * @param signal Optional `AbortSignal` to cancel the request
1553
+ *
1554
+ * **Official reference:** https://core.telegram.org/bots/api#unpinallgeneralforumtopicmessages
1555
+ */
1556
+ unpinAllGeneralForumTopicMessages(signal) {
1557
+ return this.api.unpinAllGeneralForumTopicMessages(orThrow(this.chatId, "unpinAllGeneralForumTopicMessages"), signal);
1558
+ }
1559
+ /**
1560
+ * Context-aware alias for `api.answerCallbackQuery`. Use this method to send answers to callback queries sent from inline keyboards. The answer will be displayed to the user as a notification at the top of the chat screen or as an alert. On success, True is returned.
1561
+ *
1562
+ * Alternatively, the user can be redirected to the specified Game URL. For this option to work, you must first create a game for your bot via @BotFather and accept the terms. Otherwise, you may use links like t.me/your_bot?start=XXXX that open your bot with a parameter.
1563
+ *
1564
+ * @param other Optional remaining parameters, confer the official reference below
1565
+ * @param signal Optional `AbortSignal` to cancel the request
1566
+ *
1567
+ * **Official reference:** https://core.telegram.org/bots/api#answercallbackquery
1568
+ */
1569
+ answerCallbackQuery(other, signal) {
1570
+ return this.api.answerCallbackQuery(orThrow(this.callbackQuery, "answerCallbackQuery").id, typeof other === "string" ? { text: other } : other, signal);
1571
+ }
1572
+ /**
1573
+ * Context-aware alias for `api.setChatMenuButton`. Use this method to change the bot's menu button in a private chat, or the default menu button. Returns True on success.
1574
+ *
1575
+ * @param other Optional remaining parameters, confer the official reference below
1576
+ * @param signal Optional `AbortSignal` to cancel the request
1577
+ *
1578
+ * **Official reference:** https://core.telegram.org/bots/api#setchatmenubutton
1579
+ */
1580
+ setChatMenuButton(other, signal) {
1581
+ return this.api.setChatMenuButton(other, signal);
1582
+ }
1583
+ /**
1584
+ * Context-aware alias for `api.getChatMenuButton`. Use this method to get the current value of the bot's menu button in a private chat, or the default menu button. Returns MenuButton on success.
1585
+ *
1586
+ * @param other Optional remaining parameters, confer the official reference below
1587
+ * @param signal Optional `AbortSignal` to cancel the request
1588
+ *
1589
+ * **Official reference:** https://core.telegram.org/bots/api#getchatmenubutton
1590
+ */
1591
+ getChatMenuButton(other, signal) {
1592
+ return this.api.getChatMenuButton(other, signal);
1593
+ }
1594
+ /**
1595
+ * Context-aware alias for `api.setMyDefaultAdministratorRights`. Use this method to the change the default administrator rights requested by the bot when it's added as an administrator to groups or channels. These rights will be suggested to users, but they are are free to modify the list before adding the bot. Returns True on success.
1596
+ *
1597
+ * @param other Optional remaining parameters, confer the official reference below
1598
+ * @param signal Optional `AbortSignal` to cancel the request
1599
+ *
1600
+ * **Official reference:** https://core.telegram.org/bots/api#setmydefaultadministratorrights
1601
+ */
1602
+ setMyDefaultAdministratorRights(other, signal) {
1603
+ return this.api.setMyDefaultAdministratorRights(other, signal);
1604
+ }
1605
+ /**
1606
+ * Context-aware alias for `api.getMyDefaultAdministratorRights`. Use this method to get the current default administrator rights of the bot. Returns ChatAdministratorRights on success.
1607
+ *
1608
+ * @param other Optional remaining parameters, confer the official reference below
1609
+ * @param signal Optional `AbortSignal` to cancel the request
1610
+ */
1611
+ getMyDefaultAdministratorRights(other, signal) {
1612
+ return this.api.getMyDefaultAdministratorRights(other, signal);
1613
+ }
1614
+ /**
1615
+ * Context-aware alias for `api.editMessageText`. Use this method to edit text and game messages. On success, if the edited message is not an inline message, the edited Message is returned, otherwise True is returned. Note that business messages that were not sent by the bot and do not contain an inline keyboard can only be edited within 48 hours from the time they were sent.
1616
+ *
1617
+ * @param text New text of the message, 1-4096 characters after entities parsing
1618
+ * @param other Optional remaining parameters, confer the official reference below
1619
+ * @param signal Optional `AbortSignal` to cancel the request
1620
+ *
1621
+ * **Official reference:** https://core.telegram.org/bots/api#editmessagetext
1622
+ */
1623
+ editMessageText(text, other, signal) {
1624
+ var _a, _b, _c, _d, _e;
1625
+ const inlineId = this.inlineMessageId;
1626
+ return inlineId !== undefined
1627
+ ? this.api.editMessageTextInline(inlineId, text, { business_connection_id: this.businessConnectionId, ...other }, signal)
1628
+ : this.api.editMessageText(orThrow(this.chatId, "editMessageText"), orThrow((_d = (_b = (_a = this.msg) === null || _a === void 0 ? void 0 : _a.message_id) !== null && _b !== void 0 ? _b : (_c = this.messageReaction) === null || _c === void 0 ? void 0 : _c.message_id) !== null && _d !== void 0 ? _d : (_e = this.messageReactionCount) === null || _e === void 0 ? void 0 : _e.message_id, "editMessageText"), text, { business_connection_id: this.businessConnectionId, ...other }, signal);
1629
+ }
1630
+ /**
1631
+ * Context-aware alias for `api.editMessageCaption`. Use this method to edit captions of messages. On success, if the edited message is not an inline message, the edited Message is returned, otherwise True is returned. Note that business messages that were not sent by the bot and do not contain an inline keyboard can only be edited within 48 hours from the time they were sent.
1632
+ *
1633
+ * @param other Optional remaining parameters, confer the official reference below
1634
+ * @param signal Optional `AbortSignal` to cancel the request
1635
+ *
1636
+ * **Official reference:** https://core.telegram.org/bots/api#editmessagecaption
1637
+ */
1638
+ editMessageCaption(other, signal) {
1639
+ var _a, _b, _c, _d, _e;
1640
+ const inlineId = this.inlineMessageId;
1641
+ return inlineId !== undefined
1642
+ ? this.api.editMessageCaptionInline(inlineId, { business_connection_id: this.businessConnectionId, ...other }, signal)
1643
+ : this.api.editMessageCaption(orThrow(this.chatId, "editMessageCaption"), orThrow((_d = (_b = (_a = this.msg) === null || _a === void 0 ? void 0 : _a.message_id) !== null && _b !== void 0 ? _b : (_c = this.messageReaction) === null || _c === void 0 ? void 0 : _c.message_id) !== null && _d !== void 0 ? _d : (_e = this.messageReactionCount) === null || _e === void 0 ? void 0 : _e.message_id, "editMessageCaption"), { business_connection_id: this.businessConnectionId, ...other }, signal);
1644
+ }
1645
+ /**
1646
+ * Context-aware alias for `api.editMessageMedia`. Use this method to edit animation, audio, document, photo, or video messages, or to add media to text messages. If a message is part of a message album, then it can be edited only to an audio for audio albums, only to a document for document albums and to a photo or a video otherwise. When an inline message is edited, a new file can't be uploaded; use a previously uploaded file via its file_id or specify a URL. On success, if the edited message is not an inline message, the edited Message is returned, otherwise True is returned. Note that business messages that were not sent by the bot and do not contain an inline keyboard can only be edited within 48 hours from the time they were sent.
1647
+ *
1648
+ * @param media An object for a new media content of the message
1649
+ * @param other Optional remaining parameters, confer the official reference below
1650
+ * @param signal Optional `AbortSignal` to cancel the request
1651
+ *
1652
+ * **Official reference:** https://core.telegram.org/bots/api#editmessagemedia
1653
+ */
1654
+ editMessageMedia(media, other, signal) {
1655
+ var _a, _b, _c, _d, _e;
1656
+ const inlineId = this.inlineMessageId;
1657
+ return inlineId !== undefined
1658
+ ? this.api.editMessageMediaInline(inlineId, media, { business_connection_id: this.businessConnectionId, ...other }, signal)
1659
+ : this.api.editMessageMedia(orThrow(this.chatId, "editMessageMedia"), orThrow((_d = (_b = (_a = this.msg) === null || _a === void 0 ? void 0 : _a.message_id) !== null && _b !== void 0 ? _b : (_c = this.messageReaction) === null || _c === void 0 ? void 0 : _c.message_id) !== null && _d !== void 0 ? _d : (_e = this.messageReactionCount) === null || _e === void 0 ? void 0 : _e.message_id, "editMessageMedia"), media, { business_connection_id: this.businessConnectionId, ...other }, signal);
1660
+ }
1661
+ /**
1662
+ * Context-aware alias for `api.editMessageReplyMarkup`. Use this method to edit only the reply markup of messages. On success, if the edited message is not an inline message, the edited Message is returned, otherwise True is returned. Note that business messages that were not sent by the bot and do not contain an inline keyboard can only be edited within 48 hours from the time they were sent.
1663
+ *
1664
+ * @param other Optional remaining parameters, confer the official reference below
1665
+ * @param signal Optional `AbortSignal` to cancel the request
1666
+ *
1667
+ * **Official reference:** https://core.telegram.org/bots/api#editmessagereplymarkup
1668
+ */
1669
+ editMessageReplyMarkup(other, signal) {
1670
+ var _a, _b, _c, _d, _e;
1671
+ const inlineId = this.inlineMessageId;
1672
+ return inlineId !== undefined
1673
+ ? this.api.editMessageReplyMarkupInline(inlineId, { business_connection_id: this.businessConnectionId, ...other }, signal)
1674
+ : this.api.editMessageReplyMarkup(orThrow(this.chatId, "editMessageReplyMarkup"), orThrow((_d = (_b = (_a = this.msg) === null || _a === void 0 ? void 0 : _a.message_id) !== null && _b !== void 0 ? _b : (_c = this.messageReaction) === null || _c === void 0 ? void 0 : _c.message_id) !== null && _d !== void 0 ? _d : (_e = this.messageReactionCount) === null || _e === void 0 ? void 0 : _e.message_id, "editMessageReplyMarkup"), { business_connection_id: this.businessConnectionId, ...other }, signal);
1675
+ }
1676
+ /**
1677
+ * Context-aware alias for `api.stopPoll`. Use this method to stop a poll which was sent by the bot. On success, the stopped Poll is returned.
1678
+ *
1679
+ * @param other Optional remaining parameters, confer the official reference below
1680
+ * @param signal Optional `AbortSignal` to cancel the request
1681
+ *
1682
+ * **Official reference:** https://core.telegram.org/bots/api#stoppoll
1683
+ */
1684
+ stopPoll(other, signal) {
1685
+ var _a, _b, _c, _d, _e;
1686
+ return this.api.stopPoll(orThrow(this.chatId, "stopPoll"), orThrow((_d = (_b = (_a = this.msg) === null || _a === void 0 ? void 0 : _a.message_id) !== null && _b !== void 0 ? _b : (_c = this.messageReaction) === null || _c === void 0 ? void 0 : _c.message_id) !== null && _d !== void 0 ? _d : (_e = this.messageReactionCount) === null || _e === void 0 ? void 0 : _e.message_id, "stopPoll"), { business_connection_id: this.businessConnectionId, ...other }, signal);
1687
+ }
1688
+ /**
1689
+ * Context-aware alias for `api.deleteMessage`. Use this method to delete a message, including service messages, with the following limitations:
1690
+ * - A message can only be deleted if it was sent less than 48 hours ago.
1691
+ * - A dice message in a private chat can only be deleted if it was sent more than 24 hours ago.
1692
+ * - Bots can delete outgoing messages in private chats, groups, and supergroups.
1693
+ * - Bots can delete incoming messages in private chats.
1694
+ * - Bots granted can_post_messages permissions can delete outgoing messages in channels.
1695
+ * - If the bot is an administrator of a group, it can delete any message there.
1696
+ * - If the bot has can_delete_messages permission in a supergroup or a channel, it can delete any message there.
1697
+ * Returns True on success.
1698
+ *
1699
+ * @param signal Optional `AbortSignal` to cancel the request
1700
+ *
1701
+ * **Official reference:** https://core.telegram.org/bots/api#deletemessage
1702
+ */
1703
+ deleteMessage(signal) {
1704
+ var _a, _b, _c, _d, _e;
1705
+ return this.api.deleteMessage(orThrow(this.chatId, "deleteMessage"), orThrow((_d = (_b = (_a = this.msg) === null || _a === void 0 ? void 0 : _a.message_id) !== null && _b !== void 0 ? _b : (_c = this.messageReaction) === null || _c === void 0 ? void 0 : _c.message_id) !== null && _d !== void 0 ? _d : (_e = this.messageReactionCount) === null || _e === void 0 ? void 0 : _e.message_id, "deleteMessage"), signal);
1706
+ }
1707
+ /**
1708
+ * Context-aware alias for `api.deleteMessages`. Use this method to delete multiple messages simultaneously. Returns True on success.
1709
+ *
1710
+ * @param chat_id Unique identifier for the target chat or username of the target channel (in the format @channelusername)
1711
+ * @param message_ids A list of 1-100 identifiers of messages to delete. See deleteMessage for limitations on which messages can be deleted
1712
+ * @param signal Optional `AbortSignal` to cancel the request
1713
+ *
1714
+ * **Official reference:** https://core.telegram.org/bots/api#deletemessages
1715
+ */
1716
+ deleteMessages(message_ids, signal) {
1717
+ return this.api.deleteMessages(orThrow(this.chatId, "deleteMessages"), message_ids, signal);
1718
+ }
1719
+ /**
1720
+ * Context-aware alias for `api.sendSticker`. Use this method to send static .WEBP, animated .TGS, or video .WEBM stickers. On success, the sent Message is returned.
1721
+ *
1722
+ * @param sticker Sticker to send. Pass a file_id as String to send a file that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get a .WEBP sticker from the Internet, or upload a new .WEBP, .TGS, or .WEBM sticker using multipart/form-data. Video and animated stickers can't be sent via an HTTP URL.
1723
+ * @param other Optional remaining parameters, confer the official reference below
1724
+ * @param signal Optional `AbortSignal` to cancel the request
1725
+ *
1726
+ * **Official reference:** https://core.telegram.org/bots/api#sendsticker
1727
+ */
1728
+ replyWithSticker(sticker, other, signal) {
1729
+ return this.api.sendSticker(orThrow(this.chatId, "sendSticker"), sticker, { business_connection_id: this.businessConnectionId, ...other }, signal);
1730
+ }
1731
+ /**
1732
+ * Use this method to get information about custom emoji stickers by their identifiers. Returns an Array of Sticker objects.
1733
+ *
1734
+ * @param custom_emoji_ids A list of custom emoji identifiers
1735
+ * @param signal Optional `AbortSignal` to cancel the request
1736
+ *
1737
+ * **Official reference:** https://core.telegram.org/bots/api#getcustomemojistickers
1738
+ */
1739
+ getCustomEmojiStickers(signal) {
1740
+ var _a, _b;
1741
+ return this.api.getCustomEmojiStickers(((_b = (_a = this.msg) === null || _a === void 0 ? void 0 : _a.entities) !== null && _b !== void 0 ? _b : [])
1742
+ .filter((e) => e.type === "custom_emoji")
1743
+ .map((e) => e.custom_emoji_id), signal);
1744
+ }
1745
+ /**
1746
+ * Context-aware alias for `api.sendGift`. Sends a gift to the given user. The gift can't be converted to Telegram Stars by the receiver. Returns True on success.
1747
+ *
1748
+ * @param gift_id Identifier of the gift
1749
+ * @param other Optional remaining parameters, confer the official reference below
1750
+ * @param signal Optional `AbortSignal` to cancel the request
1751
+ *
1752
+ * **Official reference:** https://core.telegram.org/bots/api#sendgift
1753
+ */
1754
+ replyWithGift(gift_id, other, signal) {
1755
+ return this.api.sendGift(orThrow(this.from, "sendGift").id, gift_id, other, signal);
1756
+ }
1757
+ /**
1758
+ * Context-aware alias for `api.sendGift`. Sends a gift to the given channel chat. The gift can't be converted to Telegram Stars by the receiver. Returns True on success.
1759
+ *
1760
+ * @param gift_id Identifier of the gift
1761
+ * @param other Optional remaining parameters, confer the official reference below
1762
+ * @param signal Optional `AbortSignal` to cancel the request
1763
+ *
1764
+ * **Official reference:** https://core.telegram.org/bots/api#sendgift
1765
+ */
1766
+ replyWithGiftToChannel(gift_id, other, signal) {
1767
+ return this.api.sendGiftToChannel(orThrow(this.chat, "sendGift").id, gift_id, other, signal);
1768
+ }
1769
+ /**
1770
+ * Context-aware alias for `api.answerInlineQuery`. Use this method to send answers to an inline query. On success, True is returned.
1771
+ * No more than 50 results per query are allowed.
1772
+ *
1773
+ * Example: An inline bot that sends YouTube videos can ask the user to connect the bot to their YouTube account to adapt search results accordingly. To do this, it displays a 'Connect your YouTube account' button above the results, or even before showing any. The user presses the button, switches to a private chat with the bot and, in doing so, passes a start parameter that instructs the bot to return an OAuth link. Once done, the bot can offer a switch_inline button so that the user can easily return to the chat where they wanted to use the bot's inline capabilities.
1774
+ *
1775
+ * @param results An array of results for the inline query
1776
+ * @param other Optional remaining parameters, confer the official reference below
1777
+ * @param signal Optional `AbortSignal` to cancel the request
1778
+ *
1779
+ * **Official reference:** https://core.telegram.org/bots/api#answerinlinequery
1780
+ */
1781
+ answerInlineQuery(results, other, signal) {
1782
+ return this.api.answerInlineQuery(orThrow(this.inlineQuery, "answerInlineQuery").id, results, other, signal);
1783
+ }
1784
+ /**
1785
+ * Context-aware alias for `api.savePreparedInlineMessage`. Stores a message that can be sent by a user of a Mini App. Returns a PreparedInlineMessage object.
1786
+ *
1787
+ * @param result An object describing the message to be sent
1788
+ * @param other Optional remaining parameters, confer the official reference below
1789
+ * @param signal Optional `AbortSignal` to cancel the request
1790
+ *
1791
+ * **Official reference:** https://core.telegram.org/bots/api#savepreparedinlinemessage
1792
+ */
1793
+ savePreparedInlineMessage(result, other, signal) {
1794
+ return this.api.savePreparedInlineMessage(orThrow(this.from, "savePreparedInlineMessage").id, result, other, signal);
1795
+ }
1796
+ /**
1797
+ * Context-aware alias for `api.sendInvoice`. Use this method to send invoices. On success, the sent Message is returned.
1798
+ *
1799
+ * @param title Product name, 1-32 characters
1800
+ * @param description Product description, 1-255 characters
1801
+ * @param payload Bot-defined invoice payload, 1-128 bytes. This will not be displayed to the user, use for your internal processes.
1802
+ * @param currency Three-letter ISO 4217 currency code, see more on currencies
1803
+ * @param prices Price breakdown, a list of components (e.g. product price, tax, discount, delivery cost, delivery tax, bonus, etc.)
1804
+ * @param other Optional remaining parameters, confer the official reference below
1805
+ * @param signal Optional `AbortSignal` to cancel the request
1806
+ *
1807
+ * **Official reference:** https://core.telegram.org/bots/api#sendinvoice
1808
+ */
1809
+ replyWithInvoice(title, description, payload, currency, prices, other, signal) {
1810
+ return this.api.sendInvoice(orThrow(this.chatId, "sendInvoice"), title, description, payload, currency, prices, other, signal);
1811
+ }
1812
+ /**
1813
+ * Context-aware alias for `api.answerShippingQuery`. If you sent an invoice requesting a shipping address and the parameter is_flexible was specified, the Bot API will send an Update with a shipping_query field to the bot. Use this method to reply to shipping queries. On success, True is returned.
1814
+ *
1815
+ * @param shipping_query_id Unique identifier for the query to be answered
1816
+ * @param ok Pass True if delivery to the specified address is possible and False if there are any problems (for example, if delivery to the specified address is not possible)
1817
+ * @param other Optional remaining parameters, confer the official reference below
1818
+ * @param signal Optional `AbortSignal` to cancel the request
1819
+ *
1820
+ * **Official reference:** https://core.telegram.org/bots/api#answershippingquery
1821
+ */
1822
+ answerShippingQuery(ok, other, signal) {
1823
+ return this.api.answerShippingQuery(orThrow(this.shippingQuery, "answerShippingQuery").id, ok, other, signal);
1824
+ }
1825
+ /**
1826
+ * Context-aware alias for `api.answerPreCheckoutQuery`. Once the user has confirmed their payment and shipping details, the Bot API sends the final confirmation in the form of an Update with the field pre_checkout_query. Use this method to respond to such pre-checkout queries. On success, True is returned. Note: The Bot API must receive an answer within 10 seconds after the pre-checkout query was sent.
1827
+ *
1828
+ * @param ok Specify True if everything is alright (goods are available, etc.) and the bot is ready to proceed with the order. Use False if there are any problems.
1829
+ * @param other Optional remaining parameters, confer the official reference below
1830
+ * @param signal Optional `AbortSignal` to cancel the request
1831
+ *
1832
+ * **Official reference:** https://core.telegram.org/bots/api#answerprecheckoutquery
1833
+ */
1834
+ answerPreCheckoutQuery(ok, other, signal) {
1835
+ return this.api.answerPreCheckoutQuery(orThrow(this.preCheckoutQuery, "answerPreCheckoutQuery").id, ok, typeof other === "string" ? { error_message: other } : other, signal);
1836
+ }
1837
+ /**
1838
+ * Context-aware alias for `api.refundStarPayment`. Refunds a successful payment in Telegram Stars.
1839
+ *
1840
+ * @param signal Optional `AbortSignal` to cancel the request
1841
+ *
1842
+ * **Official reference:** https://core.telegram.org/bots/api#refundstarpayment
1843
+ */
1844
+ refundStarPayment(signal) {
1845
+ var _a;
1846
+ return this.api.refundStarPayment(orThrow(this.from, "refundStarPayment").id, orThrow((_a = this.msg) === null || _a === void 0 ? void 0 : _a.successful_payment, "refundStarPayment")
1847
+ .telegram_payment_charge_id, signal);
1848
+ }
1849
+ /**
1850
+ * Context-aware alias for `api.editUserStarSubscription`. Allows the bot to cancel or re-enable extension of a subscription paid in Telegram Stars. Returns True on success.
1851
+ *
1852
+ * @param telegram_payment_charge_id Telegram payment identifier for the subscription
1853
+ * @param is_canceled Pass True to cancel extension of the user subscription; the subscription must be active up to the end of the current subscription period. Pass False to allow the user to re-enable a subscription that was previously canceled by the bot.
1854
+ * @param signal Optional `AbortSignal` to cancel the request
1855
+ *
1856
+ * **Official reference:** https://core.telegram.org/bots/api#edituserstarsubscription
1857
+ */
1858
+ editUserStarSubscription(telegram_payment_charge_id, is_canceled, signal) {
1859
+ return this.api.editUserStarSubscription(orThrow(this.from, "editUserStarSubscription").id, telegram_payment_charge_id, is_canceled, signal);
1860
+ }
1861
+ /**
1862
+ * Context-aware alias for `api.verifyUser`. Verifies a user on behalf of the organization which is represented by the bot. Returns True on success.
1863
+ *
1864
+ * @param other Optional remaining parameters, confer the official reference below
1865
+ * @param signal Optional `AbortSignal` to cancel the request
1866
+ *
1867
+ * **Official reference:** https://core.telegram.org/bots/api#verifyuser
1868
+ */
1869
+ verifyUser(other, signal) {
1870
+ return this.api.verifyUser(orThrow(this.from, "verifyUser").id, other, signal);
1871
+ }
1872
+ /**
1873
+ * Context-aware alias for `api.verifyChat`. Verifies a chat on behalf of the organization which is represented by the bot. Returns True on success.
1874
+ *
1875
+ * @param other Optional remaining parameters, confer the official reference below
1876
+ * @param signal Optional `AbortSignal` to cancel the request
1877
+ *
1878
+ * **Official reference:** https://core.telegram.org/bots/api#verifychat
1879
+ */
1880
+ verifyChat(other, signal) {
1881
+ return this.api.verifyChat(orThrow(this.chatId, "verifyChat"), other, signal);
1882
+ }
1883
+ /**
1884
+ * Context-aware alias for `api.removeUserVerification`. Removes verification from a user who is currently verified on behalf of the organization represented by the bot. Returns True on success.
1885
+ *
1886
+ * @param signal Optional `AbortSignal` to cancel the request
1887
+ *
1888
+ * **Official reference:** https://core.telegram.org/bots/api#removeuserverification
1889
+ */
1890
+ removeUserVerification(signal) {
1891
+ return this.api.removeUserVerification(orThrow(this.from, "removeUserVerification").id, signal);
1892
+ }
1893
+ /**
1894
+ * Context-aware alias for `api.removeChatVerification`. Removes verification from a chat that is currently verified on behalf of the organization represented by the bot. Returns True on success.
1895
+ *
1896
+ * @param signal Optional `AbortSignal` to cancel the request
1897
+ *
1898
+ * **Official reference:** https://core.telegram.org/bots/api#removechatverification
1899
+ */
1900
+ removeChatVerification(signal) {
1901
+ return this.api.removeChatVerification(orThrow(this.chatId, "removeChatVerification"), signal);
1902
+ }
1903
+ /**
1904
+ * Context-aware alias for `api.setPassportDataErrors`. Informs a user that some of the Telegram Passport elements they provided contains errors. The user will not be able to re-submit their Passport to you until the errors are fixed (the contents of the field for which you returned the error must change). Returns True on success.
1905
+ *
1906
+ * Use this if the data submitted by the user doesn't satisfy the standards your service requires for any reason. For example, if a birthday date seems invalid, a submitted document is blurry, a scan shows evidence of tampering, etc. Supply some details in the error message to make sure the user knows how to correct the issues.
1907
+ *
1908
+ * @param errors An array describing the errors
1909
+ * @param signal Optional `AbortSignal` to cancel the request
1910
+ *
1911
+ * **Official reference:** https://core.telegram.org/bots/api#setpassportdataerrors
1912
+ */
1913
+ setPassportDataErrors(errors, signal) {
1914
+ return this.api.setPassportDataErrors(orThrow(this.from, "setPassportDataErrors").id, errors, signal);
1915
+ }
1916
+ /**
1917
+ * Context-aware alias for `api.sendGame`. Use this method to send a game. On success, the sent Message is returned.
1918
+ *
1919
+ * @param game_short_name Short name of the game, serves as the unique identifier for the game. Set up your games via BotFather.
1920
+ * @param other Optional remaining parameters, confer the official reference below
1921
+ * @param signal Optional `AbortSignal` to cancel the request
1922
+ *
1923
+ * **Official reference:** https://core.telegram.org/bots/api#sendgame
1924
+ */
1925
+ replyWithGame(game_short_name, other, signal) {
1926
+ return this.api.sendGame(orThrow(this.chatId, "sendGame"), game_short_name, { business_connection_id: this.businessConnectionId, ...other }, signal);
1927
+ }
1928
+ }
1929
+ exports.Context = Context;
1930
+ // PROBING SHORTCUTS
1931
+ /**
1932
+ * `Context.has` is an object that contains a number of useful functions for
1933
+ * probing context objects. Each of these functions can generate a predicate
1934
+ * function, to which you can pass context objects in order to check if a
1935
+ * condition holds for the respective context object.
1936
+ *
1937
+ * For example, you can call `Context.has.filterQuery(":text")` to generate
1938
+ * a predicate function that tests context objects for containing text:
1939
+ * ```ts
1940
+ * const hasText = Context.has.filterQuery(":text");
1941
+ *
1942
+ * if (hasText(ctx0)) {} // `ctx0` matches the filter query `:text`
1943
+ * if (hasText(ctx1)) {} // `ctx1` matches the filter query `:text`
1944
+ * if (hasText(ctx2)) {} // `ctx2` matches the filter query `:text`
1945
+ * ```
1946
+ * These predicate functions are used internally by the has-methods that are
1947
+ * installed on every context object. This means that calling
1948
+ * `ctx.has(":text")` is equivalent to
1949
+ * `Context.has.filterQuery(":text")(ctx)`.
1950
+ */
1951
+ Context.has = checker;
1952
+ // === Util functions
1953
+ function orThrow(value, method) {
1954
+ if (value === undefined) {
1955
+ throw new Error(`Missing information for API call to ${method}`);
1956
+ }
1957
+ return value;
1958
+ }
1959
+ function triggerFn(trigger) {
1960
+ return toArray(trigger).map((t) => typeof t === "string"
1961
+ ? (txt) => (txt === t ? t : null)
1962
+ : (txt) => txt.match(t));
1963
+ }
1964
+ function match(ctx, content, triggers) {
1965
+ for (const t of triggers) {
1966
+ const res = t(content);
1967
+ if (res) {
1968
+ ctx.match = res;
1969
+ return true;
1970
+ }
1971
+ }
1972
+ return false;
1973
+ }
1974
+ function toArray(e) {
1975
+ return Array.isArray(e) ? e : [e];
1976
+ }