grammy-tools 1.36.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +339 -0
  3. package/out/bot.d.ts +314 -0
  4. package/out/bot.js +669 -0
  5. package/out/composer.d.ts +764 -0
  6. package/out/composer.js +704 -0
  7. package/out/context.d.ts +1618 -0
  8. package/out/context.js +1976 -0
  9. package/out/convenience/constants.d.ts +98 -0
  10. package/out/convenience/constants.js +37 -0
  11. package/out/convenience/frameworks.d.ts +216 -0
  12. package/out/convenience/frameworks.js +370 -0
  13. package/out/convenience/inline_query.d.ts +401 -0
  14. package/out/convenience/inline_query.js +461 -0
  15. package/out/convenience/input_media.d.ts +72 -0
  16. package/out/convenience/input_media.js +82 -0
  17. package/out/convenience/keyboard.d.ts +763 -0
  18. package/out/convenience/keyboard.js +935 -0
  19. package/out/convenience/session.d.ts +345 -0
  20. package/out/convenience/session.js +455 -0
  21. package/out/convenience/webhook.d.ts +59 -0
  22. package/out/convenience/webhook.js +80 -0
  23. package/out/core/api.d.ts +1628 -0
  24. package/out/core/api.js +1907 -0
  25. package/out/core/client.d.ts +180 -0
  26. package/out/core/client.js +226 -0
  27. package/out/core/error.d.ts +53 -0
  28. package/out/core/error.js +87 -0
  29. package/out/core/payload.d.ts +39 -0
  30. package/out/core/payload.js +199 -0
  31. package/out/filter.d.ts +959 -0
  32. package/out/filter.js +378 -0
  33. package/out/mod.d.ts +14 -0
  34. package/out/mod.js +43 -0
  35. package/out/platform.node.d.ts +16 -0
  36. package/out/platform.node.js +43 -0
  37. package/out/shim.node.d.ts +2 -0
  38. package/out/shim.node.js +7 -0
  39. package/out/types.d.ts +1 -0
  40. package/out/types.js +17 -0
  41. package/out/types.node.d.ts +78 -0
  42. package/out/types.node.js +107 -0
  43. package/out/web.d.ts +1 -0
  44. package/out/web.mjs +5172 -0
  45. package/package.json +71 -0
@@ -0,0 +1,763 @@
1
+ import { type CopyTextButton, type InlineKeyboardButton, type KeyboardButton, type KeyboardButtonPollType, type KeyboardButtonRequestChat, type KeyboardButtonRequestUsers, type LoginUrl, type SwitchInlineQueryChosenChat, type WebAppInfo } from "../types.js";
2
+ type KeyboardButtonSource = string | KeyboardButton;
3
+ type KeyboardSource = KeyboardButtonSource[][] | Keyboard;
4
+ /**
5
+ * Use this class to simplify building a custom keyboard (something like this:
6
+ * https://core.telegram.org/bots/features#keyboards).
7
+ *
8
+ * ```ts
9
+ * // Build a custom keyboard:
10
+ * const keyboard = new Keyboard()
11
+ * .text('A').text('B').row()
12
+ * .text('C').text('D')
13
+ *
14
+ * // Now you can send it like so:
15
+ * await ctx.reply('Here is your custom keyboard!', {
16
+ * reply_markup: keyboard
17
+ * })
18
+ * ```
19
+ *
20
+ * If you already have some source data which you would like to turn into a
21
+ * keyboard button object, you can use the static equivalents which every button
22
+ * has. You can use them to create a two-dimensional keyboard button array. The
23
+ * resulting array can be turned into a keyboard instance.
24
+ *
25
+ * ```ts
26
+ * const button = Keyboard.text('push my buttons')
27
+ * const array = [[button]]
28
+ * const keyboard = Keyboard.from(array)
29
+ * ```
30
+ *
31
+ * If you want to create text buttons only, you can directly use a
32
+ * two-dimensional string array and turn it into a keyboard.
33
+ *
34
+ * ```ts
35
+ * const data = [['A', 'B'], ['C', 'D']]
36
+ * const keyboard = Keyboard.from(data)
37
+ * ```
38
+ *
39
+ * Be sure to check out the
40
+ * [documentation](https://grammy.dev/plugins/keyboard#custom-keyboards) on
41
+ * custom keyboards in grammY.
42
+ */
43
+ export declare class Keyboard {
44
+ readonly keyboard: KeyboardButton[][];
45
+ /**
46
+ * Requests clients to always show the keyboard when the regular keyboard is
47
+ * hidden. Defaults to false, in which case the custom keyboard can be
48
+ * hidden and opened with a keyboard icon.
49
+ */
50
+ is_persistent?: boolean;
51
+ /**
52
+ * Show the current keyboard only to those users that are mentioned in the
53
+ * text of the message object.
54
+ */
55
+ selective?: boolean;
56
+ /**
57
+ * Hide the keyboard after a button is pressed.
58
+ */
59
+ one_time_keyboard?: boolean;
60
+ /**
61
+ * Resize the current keyboard according to its buttons. Usually, this will
62
+ * make the keyboard smaller.
63
+ */
64
+ resize_keyboard?: boolean;
65
+ /**
66
+ * Placeholder to be shown in the input field when the keyboard is active.
67
+ */
68
+ input_field_placeholder?: string;
69
+ /**
70
+ * Initialize a new `Keyboard` with an optional two-dimensional array of
71
+ * `KeyboardButton` objects. This is the nested array that holds the custom
72
+ * keyboard. It will be extended every time you call one of the provided
73
+ * methods.
74
+ *
75
+ * @param keyboard An optional initial two-dimensional button array
76
+ */
77
+ constructor(keyboard?: KeyboardButton[][]);
78
+ /**
79
+ * Allows you to add your own `KeyboardButton` objects if you already have
80
+ * them for some reason. You most likely want to call one of the other
81
+ * methods.
82
+ *
83
+ * @param buttons The buttons to add
84
+ */
85
+ add(...buttons: KeyboardButton[]): this;
86
+ /**
87
+ * Adds a 'line break'. Call this method to make sure that the next added
88
+ * buttons will be on a new row.
89
+ *
90
+ * You may pass a number of `KeyboardButton` objects if you already have the
91
+ * instances for some reason. You most likely don't want to pass any
92
+ * arguments to `row`.
93
+ *
94
+ * @param buttons A number of buttons to add to the next row
95
+ */
96
+ row(...buttons: KeyboardButton[]): this;
97
+ /**
98
+ * Adds a new text button. This button will simply send the given text as a
99
+ * text message back to your bot if a user clicks on it.
100
+ *
101
+ * @param text The text to display
102
+ */
103
+ text(text: string): this;
104
+ /**
105
+ * Creates a new text button. This button will simply send the given text as
106
+ * a text message back to your bot if a user clicks on it.
107
+ *
108
+ * @param text The text to display
109
+ */
110
+ static text(text: string): KeyboardButton.CommonButton;
111
+ /**
112
+ * Adds a new request users button. When the user presses the button, a list
113
+ * of suitable users will be opened. Tapping on any number of users will
114
+ * send their identifiers to the bot in a “users_shared” service message.
115
+ * Available in private chats only.
116
+ *
117
+ * @param text The text to display
118
+ * @param requestId A signed 32-bit identifier of the request
119
+ * @param options Options object for further requirements
120
+ */
121
+ requestUsers(text: string, requestId: number, options?: Omit<KeyboardButtonRequestUsers, "request_id">): this;
122
+ /**
123
+ * Creates a new request users button. When the user presses the button, a
124
+ * list of suitable users will be opened. Tapping on any number of users
125
+ * will send their identifiers to the bot in a “users_shared” service
126
+ * message. Available in private chats only.
127
+ *
128
+ * @param text The text to display
129
+ * @param requestId A signed 32-bit identifier of the request
130
+ * @param options Options object for further requirements
131
+ */
132
+ static requestUsers(text: string, requestId: number, options?: Omit<KeyboardButtonRequestUsers, "request_id">): KeyboardButton.RequestUsersButton;
133
+ /**
134
+ * Adds a new request chat button. When the user presses the button, a list
135
+ * of suitable users will be opened. Tapping on a chat will send its
136
+ * identifier to the bot in a “chat_shared” service message. Available in
137
+ * private chats only.
138
+ *
139
+ * @param text The text to display
140
+ * @param requestId A signed 32-bit identifier of the request
141
+ * @param options Options object for further requirements
142
+ */
143
+ requestChat(text: string, requestId: number, options?: Omit<KeyboardButtonRequestChat, "request_id">): this;
144
+ /**
145
+ * Creates a new request chat button. When the user presses the button, a
146
+ * list of suitable users will be opened. Tapping on a chat will send its
147
+ * identifier to the bot in a “chat_shared” service message. Available in
148
+ * private chats only.
149
+ *
150
+ * @param text The text to display
151
+ * @param requestId A signed 32-bit identifier of the request
152
+ * @param options Options object for further requirements
153
+ */
154
+ static requestChat(text: string, requestId: number, options?: Omit<KeyboardButtonRequestChat, "request_id">): KeyboardButton.RequestChatButton;
155
+ /**
156
+ * Adds a new contact request button. The user's phone number will be sent
157
+ * as a contact when the button is pressed. Available in private chats only.
158
+ *
159
+ * @param text The text to display
160
+ */
161
+ requestContact(text: string): this;
162
+ /**
163
+ * Creates a new contact request button. The user's phone number will be
164
+ * sent as a contact when the button is pressed. Available in private chats
165
+ * only.
166
+ *
167
+ * @param text The text to display
168
+ */
169
+ static requestContact(text: string): KeyboardButton.RequestContactButton;
170
+ /**
171
+ * Adds a new location request button. The user's current location will be
172
+ * sent when the button is pressed. Available in private chats only.
173
+ *
174
+ * @param text The text to display
175
+ */
176
+ requestLocation(text: string): this;
177
+ /**
178
+ * Creates a new location request button. The user's current location will
179
+ * be sent when the button is pressed. Available in private chats only.
180
+ *
181
+ * @param text The text to display
182
+ */
183
+ static requestLocation(text: string): KeyboardButton.RequestLocationButton;
184
+ /**
185
+ * Adds a new poll request button. The user will be asked to create a poll
186
+ * and send it to the bot when the button is pressed. Available in private
187
+ * chats only.
188
+ *
189
+ * @param text The text to display
190
+ * @param type The type of permitted polls to create, omit if the user may
191
+ * send a poll of any type
192
+ */
193
+ requestPoll(text: string, type?: KeyboardButtonPollType["type"]): this;
194
+ /**
195
+ * Creates a new poll request button. The user will be asked to create a
196
+ * poll and send it to the bot when the button is pressed. Available in
197
+ * private chats only.
198
+ *
199
+ * @param text The text to display
200
+ * @param type The type of permitted polls to create, omit if the user may
201
+ * send a poll of any type
202
+ */
203
+ static requestPoll(text: string, type?: KeyboardButtonPollType["type"]): KeyboardButton.RequestPollButton;
204
+ /**
205
+ * Adds a new web app button. The Web App that will be launched when the
206
+ * user presses the button. The Web App will be able to send a
207
+ * “web_app_data” service message. Available in private chats only.
208
+ *
209
+ * @param text The text to display
210
+ * @param url An HTTPS URL of a Web App to be opened with additional data
211
+ */
212
+ webApp(text: string, url: string): this;
213
+ /**
214
+ * Creates a new web app button. The Web App that will be launched when the
215
+ * user presses the button. The Web App will be able to send a
216
+ * “web_app_data” service message. Available in private chats only.
217
+ *
218
+ * @param text The text to display
219
+ * @param url An HTTPS URL of a Web App to be opened with additional data
220
+ */
221
+ static webApp(text: string, url: string): KeyboardButton.WebAppButton;
222
+ /**
223
+ * Make the current keyboard persistent. See
224
+ * https://grammy.dev/plugins/keyboard#persistent-keyboards for more
225
+ * details.
226
+ *
227
+ * Keyboards are not persistent by default, use this function to enable it
228
+ * (without any parameters or pass `true`). Pass `false` to force the
229
+ * keyboard to not persist.
230
+ *
231
+ * @param isEnabled `true` if the keyboard should persist, and `false` otherwise
232
+ */
233
+ persistent(isEnabled?: boolean): this;
234
+ /**
235
+ * Make the current keyboard selective. See
236
+ * https://grammy.dev/plugins/keyboard#selectively-send-custom-keyboards
237
+ * for more details.
238
+ *
239
+ * Keyboards are non-selective by default, use this function to enable it
240
+ * (without any parameters or pass `true`). Pass `false` to force the
241
+ * keyboard to be non-selective.
242
+ *
243
+ * @param isEnabled `true` if the keyboard should be selective, and `false` otherwise
244
+ */
245
+ selected(isEnabled?: boolean): this;
246
+ /**
247
+ * Make the current keyboard one-time. See
248
+ * https://grammy.dev/plugins/keyboard#one-time-custom-keyboards for
249
+ * more details.
250
+ *
251
+ * Keyboards are non-one-time by default, use this function to enable it
252
+ * (without any parameters or pass `true`). Pass `false` to force the
253
+ * keyboard to be non-one-time.
254
+ *
255
+ * @param isEnabled `true` if the keyboard should be one-time, and `false` otherwise
256
+ */
257
+ oneTime(isEnabled?: boolean): this;
258
+ /**
259
+ * Make the current keyboard resized. See
260
+ * https://grammy.dev/plugins/keyboard#resize-custom-keyboard for more
261
+ * details.
262
+ *
263
+ * Keyboards are non-resized by default, use this function to enable it
264
+ * (without any parameters or pass `true`). Pass `false` to force the
265
+ * keyboard to be non-resized.
266
+ *
267
+ * @param isEnabled `true` if the keyboard should be resized, and `false` otherwise
268
+ */
269
+ resized(isEnabled?: boolean): this;
270
+ /**
271
+ * Set the current keyboard's input field placeholder. See
272
+ * https://grammy.dev/plugins/keyboard#input-field-placeholder for more
273
+ * details.
274
+ *
275
+ * @param value The placeholder text
276
+ */
277
+ placeholder(value: string): this;
278
+ /**
279
+ * Creates a new keyboard that contains the transposed grid of buttons of
280
+ * this keyboard. This means that the resulting keyboard has the rows and
281
+ * columns flipped.
282
+ *
283
+ * Note that buttons can only span multiple columns, but never multiple
284
+ * rows. This means that if the given arrays have different lengths, some
285
+ * buttons might flow up in the layout. In these cases, transposing a
286
+ * keyboard a second time will not undo the first transposition.
287
+ *
288
+ * Here are some examples.
289
+ *
290
+ * ```
291
+ * original transposed
292
+ * [ a ] ~> [ a ]
293
+ *
294
+ * [ a ]
295
+ * [a b c] ~> [ b ]
296
+ * [ c ]
297
+ *
298
+ * [ a b ] [a c e]
299
+ * [ c d ] ~> [ b d ]
300
+ * [ e ]
301
+ *
302
+ * [ a b ] [a c d]
303
+ * [ c ] ~> [ b e ]
304
+ * [d e f] [ f ]
305
+ * ```
306
+ */
307
+ toTransposed(): Keyboard;
308
+ /**
309
+ * Creates a new keyboard with the same buttons but reflowed into a given
310
+ * number of columns as if the buttons were text elements. Optionally, you
311
+ * can specify if the flow should make sure to fill up the last row.
312
+ *
313
+ * This method is idempotent, so calling it a second time will effectively
314
+ * clone this keyboard without reordering the buttons.
315
+ *
316
+ * Here are some examples.
317
+ *
318
+ * ```
319
+ * original flowed
320
+ * [ a ] ~> [ a ] (4 columns)
321
+ *
322
+ * [ a ]
323
+ * [a b c] ~> [ b ] (1 column)
324
+ * [ c ]
325
+ *
326
+ * [ a b ] [a b c]
327
+ * [ c d ] ~> [ d e ] (3 columns)
328
+ * [ e ]
329
+ *
330
+ * [ a b ] [abcde]
331
+ * [ c ] ~> [ f ] (5 columns)
332
+ * [d e f]
333
+ *
334
+ * [a b c] [ a ]
335
+ * [d e f] ~> [b c d] (3 colums, { fillLastRow: true })
336
+ * [g h i] [e f g]
337
+ * [ j ] [h i j]
338
+ * ```
339
+ *
340
+ * @param columns Maximum number of buttons per row
341
+ * @param options Optional flowing behavior
342
+ */
343
+ toFlowed(columns: number, options?: FlowOptions): Keyboard;
344
+ /**
345
+ * Creates and returns a deep copy of this keyboard.
346
+ *
347
+ * Optionally takes a new grid of buttons to replace the current buttons. If
348
+ * specified, only the options will be cloned, and the given buttons will be
349
+ * used instead.
350
+ */
351
+ clone(keyboard?: KeyboardButton[][]): Keyboard;
352
+ /**
353
+ * Appends the buttons of the given keyboards to this keyboard. If other
354
+ * options are specified in these keyboards, they will be ignored.
355
+ *
356
+ * @param sources A number of keyboards to append
357
+ */
358
+ append(...sources: KeyboardSource[]): this;
359
+ /**
360
+ * Returns the keyboard that was build. Note that it doesn't return
361
+ * `resize_keyboard` or other options that may be set. You don't usually
362
+ * need to call this method. It is no longer useful.
363
+ */
364
+ build(): KeyboardButton[][];
365
+ /**
366
+ * Turns a two-dimensional keyboard button array into a keyboard instance.
367
+ * You can use the static button builder methods to create keyboard button
368
+ * objects.
369
+ *
370
+ * @param source A two-dimensional button array
371
+ */
372
+ static from(source: KeyboardSource): Keyboard;
373
+ }
374
+ type InlineKeyboardSource = InlineKeyboardButton[][] | InlineKeyboard;
375
+ /**
376
+ * Use this class to simplify building an inline keyboard (something like this:
377
+ * https://core.telegram.org/bots/features#inline-keyboards).
378
+ *
379
+ * ```ts
380
+ * // Build an inline keyboard:
381
+ * const keyboard = new InlineKeyboard()
382
+ * .text('A').text('B', 'callback-data').row()
383
+ * .text('C').text('D').row()
384
+ * .url('Telegram', 'telegram.org')
385
+ *
386
+ * // Send the keyboard:
387
+ * await ctx.reply('Here is your inline keyboard!', {
388
+ * reply_markup: keyboard
389
+ * })
390
+ * ```
391
+ *
392
+ * If you already have some source data which you would like to turn into an
393
+ * inline button object, you can use the static equivalents which every inline
394
+ * button has. You can use them to create a two-dimensional inline button array.
395
+ * The resulting array can be turned into a keyboard instance.
396
+ *
397
+ * ```ts
398
+ * const button = InlineKeyboard.text('GO', 'go')
399
+ * const array = [[button]]
400
+ * const keyboard = InlineKeyboard.from(array)
401
+ * ```
402
+ *
403
+ * Be sure to to check the
404
+ * [documentation](https://grammy.dev/plugins/keyboard#inline-keyboards) on
405
+ * inline keyboards in grammY.
406
+ */
407
+ export declare class InlineKeyboard {
408
+ readonly inline_keyboard: InlineKeyboardButton[][];
409
+ /**
410
+ * Initialize a new `InlineKeyboard` with an optional two-dimensional array
411
+ * of `InlineKeyboardButton` objects. This is the nested array that holds
412
+ * the inline keyboard. It will be extended every time you call one of the
413
+ * provided methods.
414
+ *
415
+ * @param inline_keyboard An optional initial two-dimensional button array
416
+ */
417
+ constructor(inline_keyboard?: InlineKeyboardButton[][]);
418
+ /**
419
+ * Allows you to add your own `InlineKeyboardButton` objects if you already
420
+ * have them for some reason. You most likely want to call one of the other
421
+ * methods.
422
+ *
423
+ * @param buttons The buttons to add
424
+ */
425
+ add(...buttons: InlineKeyboardButton[]): this;
426
+ /**
427
+ * Adds a 'line break'. Call this method to make sure that the next added
428
+ * buttons will be on a new row.
429
+ *
430
+ * You may pass a number of `InlineKeyboardButton` objects if you already
431
+ * have the instances for some reason. You most likely don't want to pass
432
+ * any arguments to `row`.
433
+ *
434
+ * @param buttons A number of buttons to add to the next row
435
+ */
436
+ row(...buttons: InlineKeyboardButton[]): this;
437
+ /**
438
+ * Adds a new URL button. Telegram clients will open the provided URL when
439
+ * the button is pressed.
440
+ *
441
+ * @param text The text to display
442
+ * @param url HTTP or tg:// url to be opened when the button is pressed. Links tg://user?id=<user_id> can be used to mention a user by their ID without using a username, if this is allowed by their privacy settings.
443
+ */
444
+ url(text: string, url: string): this;
445
+ /**
446
+ * Creates a new URL button. Telegram clients will open the provided URL
447
+ * when the button is pressed.
448
+ *
449
+ * @param text The text to display
450
+ * @param url HTTP or tg:// url to be opened when the button is pressed. Links tg://user?id=<user_id> can be used to mention a user by their ID without using a username, if this is allowed by their privacy settings.
451
+ */
452
+ static url(text: string, url: string): InlineKeyboardButton.UrlButton;
453
+ /**
454
+ * Adds a new callback query button. The button contains a text and a custom
455
+ * payload. This payload will be sent back to your bot when the button is
456
+ * pressed. If you omit the payload, the display text will be sent back to
457
+ * your bot.
458
+ *
459
+ * Your bot will receive an update every time a user presses any of the text
460
+ * buttons. You can listen to these updates like this:
461
+ * ```ts
462
+ * // Specific buttons:
463
+ * bot.callbackQuery('button-data', ctx => { ... })
464
+ * // Any button of any inline keyboard:
465
+ * bot.on('callback_query:data', ctx => { ... })
466
+ * ```
467
+ *
468
+ * @param text The text to display
469
+ * @param data The callback data to send back to your bot (default = text)
470
+ */
471
+ text(text: string, data?: string): this;
472
+ /**
473
+ * Creates a new callback query button. The button contains a text and a
474
+ * custom payload. This payload will be sent back to your bot when the
475
+ * button is pressed. If you omit the payload, the display text will be sent
476
+ * back to your bot.
477
+ *
478
+ * Your bot will receive an update every time a user presses any of the text
479
+ * buttons. You can listen to these updates like this:
480
+ * ```ts
481
+ * // Specific buttons:
482
+ * bot.callbackQuery('button-data', ctx => { ... })
483
+ * // Any button of any inline keyboard:
484
+ * bot.on('callback_query:data', ctx => { ... })
485
+ * ```
486
+ *
487
+ * @param text The text to display
488
+ * @param data The callback data to send back to your bot (default = text)
489
+ */
490
+ static text(text: string, data?: string): InlineKeyboardButton.CallbackButton;
491
+ /**
492
+ * Adds a new web app button, confer https://core.telegram.org/bots/webapps
493
+ *
494
+ * @param text The text to display
495
+ * @param url An HTTPS URL of a Web App to be opened with additional data
496
+ */
497
+ webApp(text: string, url: string | WebAppInfo): this;
498
+ /**
499
+ * Creates a new web app button, confer https://core.telegram.org/bots/webapps
500
+ *
501
+ * @param text The text to display
502
+ * @param url An HTTPS URL of a Web App to be opened with additional data
503
+ */
504
+ static webApp(text: string, url: string | WebAppInfo): InlineKeyboardButton.WebAppButton;
505
+ /**
506
+ * Adds a new login button. This can be used as a replacement for the
507
+ * Telegram Login Widget. You must specify an HTTPS URL used to
508
+ * automatically authorize the user.
509
+ *
510
+ * @param text The text to display
511
+ * @param loginUrl The login URL as string or `LoginUrl` object
512
+ */
513
+ login(text: string, loginUrl: string | LoginUrl): this;
514
+ /**
515
+ * Creates a new login button. This can be used as a replacement for the
516
+ * Telegram Login Widget. You must specify an HTTPS URL used to
517
+ * automatically authorize the user.
518
+ *
519
+ * @param text The text to display
520
+ * @param loginUrl The login URL as string or `LoginUrl` object
521
+ */
522
+ static login(text: string, loginUrl: string | LoginUrl): InlineKeyboardButton.LoginButton;
523
+ /**
524
+ * Adds a new inline query button. Telegram clients will let the user pick a
525
+ * chat when this button is pressed. This will start an inline query. The
526
+ * selected chat will be prefilled with the name of your bot. You may
527
+ * provide a text that is specified along with it.
528
+ *
529
+ * Your bot will in turn receive updates for inline queries. You can listen
530
+ * to inline query updates like this:
531
+ * ```ts
532
+ * bot.on('inline_query', ctx => { ... })
533
+ * ```
534
+ *
535
+ * @param text The text to display
536
+ * @param query The (optional) inline query string to prefill
537
+ */
538
+ switchInline(text: string, query?: string): this;
539
+ /**
540
+ * Creates a new inline query button. Telegram clients will let the user pick a
541
+ * chat when this button is pressed. This will start an inline query. The
542
+ * selected chat will be prefilled with the name of your bot. You may
543
+ * provide a text that is specified along with it.
544
+ *
545
+ * Your bot will in turn receive updates for inline queries. You can listen
546
+ * to inline query updates like this:
547
+ * ```ts
548
+ * bot.on('inline_query', ctx => { ... })
549
+ * ```
550
+ *
551
+ * @param text The text to display
552
+ * @param query The (optional) inline query string to prefill
553
+ */
554
+ static switchInline(text: string, query?: string): InlineKeyboardButton.SwitchInlineButton;
555
+ /**
556
+ * Adds a new inline query button that acts on the current chat. The
557
+ * selected chat will be prefilled with the name of your bot. You may
558
+ * provide a text that is specified along with it. This will start an inline
559
+ * query.
560
+ *
561
+ * Your bot will in turn receive updates for inline queries. You can listen
562
+ * to inline query updates like this:
563
+ * ```ts
564
+ * bot.on('inline_query', ctx => { ... })
565
+ * ```
566
+ *
567
+ * @param text The text to display
568
+ * @param query The (optional) inline query string to prefill
569
+ */
570
+ switchInlineCurrent(text: string, query?: string): this;
571
+ /**
572
+ * Creates a new inline query button that acts on the current chat. The
573
+ * selected chat will be prefilled with the name of your bot. You may
574
+ * provide a text that is specified along with it. This will start an inline
575
+ * query.
576
+ *
577
+ * Your bot will in turn receive updates for inline queries. You can listen
578
+ * to inline query updates like this:
579
+ * ```ts
580
+ * bot.on('inline_query', ctx => { ... })
581
+ * ```
582
+ *
583
+ * @param text The text to display
584
+ * @param query The (optional) inline query string to prefill
585
+ */
586
+ static switchInlineCurrent(text: string, query?: string): InlineKeyboardButton.SwitchInlineCurrentChatButton;
587
+ /**
588
+ * Adds a new inline query button. Telegram clients will let the user pick a
589
+ * chat when this button is pressed. This will start an inline query. The
590
+ * selected chat will be prefilled with the name of your bot. You may
591
+ * provide a text that is specified along with it.
592
+ *
593
+ * Your bot will in turn receive updates for inline queries. You can listen
594
+ * to inline query updates like this:
595
+ * ```ts
596
+ * bot.on('inline_query', ctx => { ... })
597
+ * ```
598
+ *
599
+ * @param text The text to display
600
+ * @param query The query object describing which chats can be picked
601
+ */
602
+ switchInlineChosen(text: string, query?: SwitchInlineQueryChosenChat): this;
603
+ /**
604
+ * Creates a new inline query button. Telegram clients will let the user pick a
605
+ * chat when this button is pressed. This will start an inline query. The
606
+ * selected chat will be prefilled with the name of your bot. You may
607
+ * provide a text that is specified along with it.
608
+ *
609
+ * Your bot will in turn receive updates for inline queries. You can listen
610
+ * to inline query updates like this:
611
+ * ```ts
612
+ * bot.on('inline_query', ctx => { ... })
613
+ * ```
614
+ *
615
+ * @param text The text to display
616
+ * @param query The query object describing which chats can be picked
617
+ */
618
+ static switchInlineChosen(text: string, query?: SwitchInlineQueryChosenChat): InlineKeyboardButton.SwitchInlineChosenChatButton;
619
+ /**
620
+ * Adds a new copy text button. When clicked, the specified text will be
621
+ * copied to the clipboard.
622
+ *
623
+ * @param text The text to display
624
+ * @param copyText The text to be copied to the clipboard
625
+ */
626
+ copyText(text: string, copyText: string | CopyTextButton): this;
627
+ /**
628
+ * Creates a new copy text button. When clicked, the specified text will be
629
+ * copied to the clipboard.
630
+ *
631
+ * @param text The text to display
632
+ * @param copyText The text to be copied to the clipboard
633
+ */
634
+ static copyText(text: string, copyText: string | CopyTextButton): InlineKeyboardButton.CopyTextButtonButton;
635
+ /**
636
+ * Adds a new game query button, confer
637
+ * https://core.telegram.org/bots/api#games
638
+ *
639
+ * This type of button must always be the first button in the first row.
640
+ *
641
+ * @param text The text to display
642
+ */
643
+ game(text: string): this;
644
+ /**
645
+ * Creates a new game query button, confer
646
+ * https://core.telegram.org/bots/api#games
647
+ *
648
+ * This type of button must always be the first button in the first row.
649
+ *
650
+ * @param text The text to display
651
+ */
652
+ static game(text: string): InlineKeyboardButton.GameButton;
653
+ /**
654
+ * Adds a new payment button, confer
655
+ * https://core.telegram.org/bots/api#payments
656
+ *
657
+ * This type of button must always be the first button in the first row and
658
+ * can only be used in invoice messages.
659
+ *
660
+ * @param text The text to display. Substrings “⭐” and “XTR” in the buttons's text will be replaced with a Telegram Star icon.
661
+ */
662
+ pay(text: string): this;
663
+ /**
664
+ * Create a new payment button, confer
665
+ * https://core.telegram.org/bots/api#payments
666
+ *
667
+ * This type of button must always be the first button in the first row and
668
+ * can only be used in invoice messages.
669
+ *
670
+ * @param text The text to display. Substrings “⭐” and “XTR” in the buttons's text will be replaced with a Telegram Star icon.
671
+ */
672
+ static pay(text: string): InlineKeyboardButton.PayButton;
673
+ /**
674
+ * Creates a new inline keyboard that contains the transposed grid of
675
+ * buttons of this inline keyboard. This means that the resulting inline
676
+ * keyboard has the rows and columns flipped.
677
+ *
678
+ * Note that inline buttons can only span multiple columns, but never
679
+ * multiple rows. This means that if the given arrays have different
680
+ * lengths, some buttons might flow up in the layout. In these cases,
681
+ * transposing an inline keyboard a second time will not undo the first
682
+ * transposition.
683
+ *
684
+ * Here are some examples.
685
+ *
686
+ * ```
687
+ * original transposed
688
+ * [ a ] ~> [ a ]
689
+ *
690
+ * [ a ]
691
+ * [a b c] ~> [ b ]
692
+ * [ c ]
693
+ *
694
+ * [ a b ] [a c e]
695
+ * [ c d ] ~> [ b d ]
696
+ * [ e ]
697
+ *
698
+ * [ a b ] [a c d]
699
+ * [ c ] ~> [ b e ]
700
+ * [d e f] [ f ]
701
+ * ```
702
+ */
703
+ toTransposed(): InlineKeyboard;
704
+ /**
705
+ * Creates a new inline keyboard with the same buttons but reflowed into a
706
+ * given number of columns as if the buttons were text elements. Optionally,
707
+ * you can specify if the flow should make sure to fill up the last row.
708
+ *
709
+ * This method is idempotent, so calling it a second time will effectively
710
+ * clone this inline keyboard without reordering the buttons.
711
+ *
712
+ * Here are some examples.
713
+ *
714
+ * ```
715
+ * original flowed
716
+ * [ a ] ~> [ a ] (4 columns)
717
+ *
718
+ * [ a ]
719
+ * [a b c] ~> [ b ] (1 column)
720
+ * [ c ]
721
+ *
722
+ * [ a b ] [a b c]
723
+ * [ c d ] ~> [ d e ] (3 columns)
724
+ * [ e ]
725
+ *
726
+ * [ a b ] [abcde]
727
+ * [ c ] ~> [ f ] (5 columns)
728
+ * [d e f]
729
+ *
730
+ * [a b c] [ a ]
731
+ * [d e f] ~> [b c d] (3 colums, { fillLastRow: true })
732
+ * [g h i] [e f g]
733
+ * [ j ] [h i j]
734
+ * ```
735
+ *
736
+ * @param columns Maximum number of buttons per row
737
+ * @param options Optional flowing behavior
738
+ */
739
+ toFlowed(columns: number, options?: FlowOptions): InlineKeyboard;
740
+ /**
741
+ * Creates and returns a deep copy of this inline keyboard.
742
+ */
743
+ clone(): InlineKeyboard;
744
+ /**
745
+ * Appends the buttons of the given inline keyboards to this keyboard.
746
+ *
747
+ * @param sources A number of inline keyboards to append
748
+ */
749
+ append(...sources: InlineKeyboardSource[]): this;
750
+ /**
751
+ * Turns a two-dimensional inline button array into an inline keyboard
752
+ * instance. You can use the static button builder methods to create inline
753
+ * button objects.
754
+ *
755
+ * @param source A two-dimensional inline button array
756
+ */
757
+ static from(source: InlineKeyboardSource): InlineKeyboard;
758
+ }
759
+ interface FlowOptions {
760
+ /** Set to `true` to completely fill up the last row */
761
+ fillLastRow?: boolean;
762
+ }
763
+ export {};