@tgify/tgify 0.1.0 → 0.1.4

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 (42) hide show
  1. package/LICENSE +23 -23
  2. package/README.md +356 -356
  3. package/lib/cli.mjs +9 -9
  4. package/package.json +1 -1
  5. package/src/button.ts +182 -182
  6. package/src/composer.ts +1008 -1008
  7. package/src/context.ts +1661 -1661
  8. package/src/core/helpers/args.ts +63 -63
  9. package/src/core/helpers/check.ts +71 -71
  10. package/src/core/helpers/compact.ts +18 -18
  11. package/src/core/helpers/deunionize.ts +26 -26
  12. package/src/core/helpers/formatting.ts +119 -119
  13. package/src/core/helpers/util.ts +96 -96
  14. package/src/core/network/client.ts +396 -396
  15. package/src/core/network/error.ts +29 -29
  16. package/src/core/network/multipart-stream.ts +45 -45
  17. package/src/core/network/polling.ts +94 -94
  18. package/src/core/network/webhook.ts +58 -58
  19. package/src/core/types/typegram.ts +54 -54
  20. package/src/filters.ts +109 -109
  21. package/src/format.ts +110 -110
  22. package/src/future.ts +213 -213
  23. package/src/index.ts +17 -17
  24. package/src/input.ts +59 -59
  25. package/src/markup.ts +142 -142
  26. package/src/middleware.ts +24 -24
  27. package/src/reactions.ts +118 -118
  28. package/src/router.ts +55 -55
  29. package/src/scenes/base.ts +52 -52
  30. package/src/scenes/context.ts +136 -136
  31. package/src/scenes/index.ts +21 -21
  32. package/src/scenes/stage.ts +71 -71
  33. package/src/scenes/wizard/context.ts +58 -58
  34. package/src/scenes/wizard/index.ts +63 -63
  35. package/src/scenes.ts +1 -1
  36. package/src/session.ts +204 -204
  37. package/src/telegraf.ts +354 -354
  38. package/src/telegram-types.ts +219 -219
  39. package/src/telegram.ts +1635 -1635
  40. package/src/types.ts +2 -2
  41. package/src/utils.ts +1 -1
  42. package/typings/telegraf.d.ts.map +1 -1
package/src/telegram.ts CHANGED
@@ -1,1635 +1,1635 @@
1
- import * as tg from './core/types/typegram'
2
- import * as tt from './telegram-types'
3
- import ApiClient from './core/network/client'
4
- import { isAbsolute } from 'path'
5
- import { URL } from 'url'
6
- import { FmtString } from './format'
7
- import { fmtCaption } from './core/helpers/util'
8
-
9
- export class Telegram extends ApiClient {
10
- /**
11
- * Get basic information about the bot
12
- */
13
- getMe() {
14
- return this.callApi('getMe', {})
15
- }
16
-
17
- /**
18
- * Get basic info about a file and prepare it for downloading.
19
- * @param fileId Id of file to get link to
20
- */
21
- getFile(fileId: string) {
22
- return this.callApi('getFile', { file_id: fileId })
23
- }
24
-
25
- /**
26
- * Get download link to a file.
27
- */
28
- async getFileLink(fileId: string | tg.File) {
29
- if (typeof fileId === 'string') {
30
- fileId = await this.getFile(fileId)
31
- } else if (fileId.file_path === undefined) {
32
- fileId = await this.getFile(fileId.file_id)
33
- }
34
-
35
- // Local bot API instances return the absolute path to the file
36
- if (fileId.file_path !== undefined && isAbsolute(fileId.file_path)) {
37
- const url = new URL(this.options.apiRoot)
38
- url.port = ''
39
- url.pathname = fileId.file_path
40
- url.protocol = 'file:'
41
- return url
42
- }
43
-
44
- return new URL(
45
- `./file/${this.options.apiMode}${this.token}${
46
- this.options.testEnv ? '/test' : ''
47
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
48
- }/${fileId.file_path!}`,
49
- this.options.apiRoot
50
- )
51
- }
52
-
53
- /**
54
- * Directly request incoming updates.
55
- * You should probably use `Telegraf::launch` instead.
56
- */
57
- getUpdates(
58
- timeout: number,
59
- limit: number,
60
- offset: number,
61
- allowedUpdates: readonly tt.UpdateType[] | undefined
62
- ) {
63
- return this.callApi('getUpdates', {
64
- allowed_updates: allowedUpdates,
65
- limit,
66
- offset,
67
- timeout,
68
- })
69
- }
70
-
71
- getWebhookInfo() {
72
- return this.callApi('getWebhookInfo', {})
73
- }
74
-
75
- getGameHighScores(
76
- userId: number,
77
- inlineMessageId: string | undefined,
78
- chatId: number | undefined,
79
- messageId: number | undefined
80
- ) {
81
- return this.callApi('getGameHighScores', {
82
- user_id: userId,
83
- inline_message_id: inlineMessageId,
84
- chat_id: chatId,
85
- message_id: messageId,
86
- })
87
- }
88
-
89
- setGameScore(
90
- userId: number,
91
- score: number,
92
- inlineMessageId: string | undefined,
93
- chatId: number | undefined,
94
- messageId: number | undefined,
95
- editMessage = true,
96
- force = false
97
- ) {
98
- return this.callApi('setGameScore', {
99
- force,
100
- score,
101
- user_id: userId,
102
- inline_message_id: inlineMessageId,
103
- chat_id: chatId,
104
- message_id: messageId,
105
- disable_edit_message: !editMessage,
106
- })
107
- }
108
-
109
- /**
110
- * Specify a url to receive incoming updates via an outgoing webhook.
111
- * @param url HTTPS url to send updates to. Use an empty string to remove webhook integration
112
- */
113
- setWebhook(url: string, extra?: tt.ExtraSetWebhook) {
114
- return this.callApi('setWebhook', {
115
- url,
116
- ...extra,
117
- })
118
- }
119
-
120
- /**
121
- * Remove webhook integration.
122
- */
123
- deleteWebhook(extra?: { drop_pending_updates?: boolean }) {
124
- return this.callApi('deleteWebhook', {
125
- ...extra,
126
- })
127
- }
128
-
129
- /**
130
- * Send a text message.
131
- * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
132
- * @param text Text of the message to be sent
133
- */
134
- sendMessage(
135
- chatId: number | string,
136
- text: string | FmtString,
137
- extra?: tt.ExtraReplyMessage
138
- ) {
139
- const t = FmtString.normalise(text)
140
- return this.callApi('sendMessage', { chat_id: chatId, ...extra, ...t })
141
- }
142
-
143
- /**
144
- * Forward existing message.
145
- * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
146
- * @param fromChatId Unique identifier for the chat where the original message was sent (or channel username in the format @channelusername)
147
- * @param messageId Message identifier in the chat specified in from_chat_id
148
- */
149
- forwardMessage(
150
- chatId: number | string,
151
- fromChatId: number | string,
152
- messageId: number,
153
- extra?: tt.ExtraForwardMessage
154
- ) {
155
- return this.callApi('forwardMessage', {
156
- chat_id: chatId,
157
- from_chat_id: fromChatId,
158
- message_id: messageId,
159
- ...extra,
160
- })
161
- }
162
-
163
- /**
164
- * 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.
165
- * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
166
- * @param fromChatId Unique identifier for the chat where the original messages were sent (or channel username in the format @channelusername)
167
- * @param messageIds Identifiers of 1-100 messages in the chat from_chat_id to forward. The identifiers must be specified in a strictly increasing order.
168
- */
169
- forwardMessages(
170
- chatId: number | string,
171
- fromChatId: number | string,
172
- messageIds: number[],
173
- extra?: tt.ExtraForwardMessages
174
- ) {
175
- return this.callApi('forwardMessages', {
176
- chat_id: chatId,
177
- from_chat_id: fromChatId,
178
- message_ids: messageIds,
179
- ...extra,
180
- })
181
- }
182
-
183
- /**
184
- * Use this method when you need to tell the user that something is happening on the bot's side.
185
- * The status is set for 5 seconds or less (when a message arrives from your bot, Telegram clients clear its typing status).
186
- * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
187
- */
188
- sendChatAction(
189
- chat_id: number | string,
190
- action: tt.ChatAction,
191
- extra?: tt.ExtraSendChatAction
192
- ) {
193
- return this.callApi('sendChatAction', { chat_id, action, ...extra })
194
- }
195
-
196
- /**
197
- * Use this method to change the chosen reactions on a message. Service messages can't be reacted to.
198
- * Automatically forwarded messages from a channel to its discussion group have the same available
199
- * reactions as messages in the channel. In albums, bots must react to the first message.
200
- * @param chat_id Unique identifier for the target chat or username of the target channel (in the format `@channelusername`)
201
- * @param message_id Identifier of the target message
202
- * @param reaction New list of reaction types to set on the message. Currently, as non-premium users, bots can set up
203
- * to one reaction per message. A custom emoji reaction can be used if it is either already present on the message
204
- * or explicitly allowed by chat administrators.
205
- * @param is_big Pass True to set the reaction with a big animation
206
- * @returns
207
- */
208
- setMessageReaction(
209
- chat_id: number | string,
210
- message_id: number,
211
- reaction?: tg.ReactionType[],
212
- is_big?: boolean
213
- ) {
214
- return this.callApi('setMessageReaction', {
215
- chat_id,
216
- message_id,
217
- reaction,
218
- is_big,
219
- })
220
- }
221
-
222
- getUserProfilePhotos(userId: number, offset?: number, limit?: number) {
223
- return this.callApi('getUserProfilePhotos', {
224
- user_id: userId,
225
- offset,
226
- limit,
227
- })
228
- }
229
-
230
- /**
231
- * Send point on the map.
232
- * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
233
- */
234
- sendLocation(
235
- chatId: number | string,
236
- latitude: number,
237
- longitude: number,
238
- extra?: tt.ExtraLocation
239
- ) {
240
- return this.callApi('sendLocation', {
241
- chat_id: chatId,
242
- latitude,
243
- longitude,
244
- ...extra,
245
- })
246
- }
247
-
248
- sendVenue(
249
- chatId: number | string,
250
- latitude: number,
251
- longitude: number,
252
- title: string,
253
- address: string,
254
- extra?: tt.ExtraVenue
255
- ) {
256
- return this.callApi('sendVenue', {
257
- latitude,
258
- longitude,
259
- title,
260
- address,
261
- chat_id: chatId,
262
- ...extra,
263
- })
264
- }
265
-
266
- /**
267
- * @param chatId Unique identifier for the target private chat
268
- */
269
- sendInvoice(
270
- chatId: number | string,
271
- invoice: tt.NewInvoiceParameters,
272
- extra?: tt.ExtraInvoice
273
- ) {
274
- return this.callApi('sendInvoice', {
275
- chat_id: chatId,
276
- ...invoice,
277
- ...extra,
278
- })
279
- }
280
-
281
- sendContact(
282
- chatId: number | string,
283
- phoneNumber: string,
284
- firstName: string,
285
- extra?: tt.ExtraContact
286
- ) {
287
- return this.callApi('sendContact', {
288
- chat_id: chatId,
289
- phone_number: phoneNumber,
290
- first_name: firstName,
291
- ...extra,
292
- })
293
- }
294
-
295
- /**
296
- * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
297
- */
298
- sendPhoto(
299
- chatId: number | string,
300
- photo: tg.Opts<'sendPhoto'>['photo'],
301
- extra?: tt.ExtraPhoto
302
- ) {
303
- return this.callApi('sendPhoto', {
304
- chat_id: chatId,
305
- photo,
306
- ...fmtCaption(extra),
307
- })
308
- }
309
-
310
- /**
311
- * Send a dice, which will have a random value from 1 to 6.
312
- * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
313
- */
314
- sendDice(chatId: number | string, extra?: tt.ExtraDice) {
315
- return this.callApi('sendDice', { chat_id: chatId, ...extra })
316
- }
317
-
318
- /**
319
- * Send general files. Bots can currently send files of any type of up to 50 MB in size, this limit may be changed in the future.
320
- * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
321
- */
322
- sendDocument(
323
- chatId: number | string,
324
- document: tg.Opts<'sendDocument'>['document'],
325
- extra?: tt.ExtraDocument
326
- ) {
327
- return this.callApi('sendDocument', {
328
- chat_id: chatId,
329
- document,
330
- ...fmtCaption(extra),
331
- })
332
- }
333
-
334
- /**
335
- * Send audio files, if you want Telegram clients to display them in the music player.
336
- * Your audio must be in the .mp3 format.
337
- * Bots can currently send audio files of up to 50 MB in size, this limit may be changed in the future.
338
- * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
339
- */
340
- sendAudio(
341
- chatId: number | string,
342
- audio: tg.Opts<'sendAudio'>['audio'],
343
- extra?: tt.ExtraAudio
344
- ) {
345
- return this.callApi('sendAudio', {
346
- chat_id: chatId,
347
- audio,
348
- ...fmtCaption(extra),
349
- })
350
- }
351
-
352
- /**
353
- * Send .webp, animated .tgs, or video .webm stickers
354
- * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
355
- */
356
- sendSticker(
357
- chatId: number | string,
358
- sticker: tg.Opts<'sendSticker'>['sticker'],
359
- extra?: tt.ExtraSticker
360
- ) {
361
- return this.callApi('sendSticker', { chat_id: chatId, sticker, ...extra })
362
- }
363
-
364
- /**
365
- * Send video files, Telegram clients support mp4 videos (other formats may be sent as Document).
366
- * Bots can currently send video files of up to 50 MB in size, this limit may be changed in the future.
367
- * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
368
- */
369
- sendVideo(
370
- chatId: number | string,
371
- video: tg.Opts<'sendVideo'>['video'],
372
- extra?: tt.ExtraVideo
373
- ) {
374
- return this.callApi('sendVideo', {
375
- chat_id: chatId,
376
- video,
377
- ...fmtCaption(extra),
378
- })
379
- }
380
-
381
- /**
382
- * Send .gif animations.
383
- * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
384
- */
385
- sendAnimation(
386
- chatId: number | string,
387
- animation: tg.Opts<'sendAnimation'>['animation'],
388
- extra?: tt.ExtraAnimation
389
- ) {
390
- return this.callApi('sendAnimation', {
391
- chat_id: chatId,
392
- animation,
393
- ...fmtCaption(extra),
394
- })
395
- }
396
-
397
- /**
398
- * Send video messages.
399
- * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
400
- */
401
- sendVideoNote(
402
- chatId: number | string,
403
- videoNote: string | tg.InputFileVideoNote,
404
- extra?: tt.ExtraVideoNote
405
- ) {
406
- return this.callApi('sendVideoNote', {
407
- chat_id: chatId,
408
- video_note: videoNote,
409
- ...extra,
410
- })
411
- }
412
-
413
- /**
414
- * 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.
415
- * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
416
- */
417
- sendVoice(
418
- chatId: number | string,
419
- voice: tg.Opts<'sendVoice'>['voice'],
420
- extra?: tt.ExtraVoice
421
- ) {
422
- return this.callApi('sendVoice', {
423
- chat_id: chatId,
424
- voice,
425
- ...fmtCaption(extra),
426
- })
427
- }
428
-
429
- /**
430
- * @param chatId Unique identifier for the target chat
431
- * @param gameShortName Short name of the game, serves as the unique identifier for the game. Set up your games via Botfather.
432
- */
433
- sendGame(chatId: number, gameName: string, extra?: tt.ExtraGame) {
434
- return this.callApi('sendGame', {
435
- chat_id: chatId,
436
- game_short_name: gameName,
437
- ...extra,
438
- })
439
- }
440
-
441
- /**
442
- * Send a group of photos or videos as an album.
443
- * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
444
- * @param media A JSON-serialized array describing photos and videos to be sent, must include 2–10 items
445
- */
446
- sendMediaGroup(
447
- chatId: number | string,
448
- media: tt.MediaGroup,
449
- extra?: tt.ExtraMediaGroup
450
- ) {
451
- return this.callApi('sendMediaGroup', { chat_id: chatId, media, ...extra })
452
- }
453
-
454
- /**
455
- * Send a native poll.
456
- * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
457
- * @param question Poll question, 1-255 characters
458
- * @param options A JSON-serialized list of answer options, 2-10 strings 1-100 characters each
459
- */
460
- sendPoll(
461
- chatId: number | string,
462
- question: string,
463
- options: readonly string[],
464
- extra?: tt.ExtraPoll
465
- ) {
466
- return this.callApi('sendPoll', {
467
- chat_id: chatId,
468
- type: 'regular',
469
- question,
470
- options,
471
- ...extra,
472
- })
473
- }
474
-
475
- /**
476
- * Send a native quiz.
477
- * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
478
- * @param question Poll question, 1-255 characters
479
- * @param options A JSON-serialized list of answer options, 2-10 strings 1-100 characters each
480
- */
481
- sendQuiz(
482
- chatId: number | string,
483
- question: string,
484
- options: readonly string[],
485
- extra?: tt.ExtraPoll
486
- ) {
487
- return this.callApi('sendPoll', {
488
- chat_id: chatId,
489
- type: 'quiz',
490
- question,
491
- options,
492
- ...extra,
493
- })
494
- }
495
-
496
- /**
497
- * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
498
- * @param messageId Identifier of the original message with the poll
499
- */
500
- stopPoll(
501
- chatId: number | string,
502
- messageId: number,
503
- extra?: tt.ExtraStopPoll
504
- ) {
505
- return this.callApi('stopPoll', {
506
- chat_id: chatId,
507
- message_id: messageId,
508
- ...extra,
509
- })
510
- }
511
-
512
- /**
513
- * 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.).
514
- * @param chatId Unique identifier for the target chat or username of the target supergroup or channel (in the format @channelusername)
515
- */
516
- getChat(chatId: number | string) {
517
- return this.callApi('getChat', { chat_id: chatId })
518
- }
519
-
520
- /**
521
- * @param chatId Unique identifier for the target chat or username of the target supergroup or channel (in the format @channelusername)
522
- */
523
- getChatAdministrators(chatId: number | string) {
524
- return this.callApi('getChatAdministrators', { chat_id: chatId })
525
- }
526
-
527
- /**
528
- * Get information about a member of a chat.
529
- * @param chatId Unique identifier for the target chat or username of the target supergroup or channel (in the format @channelusername)
530
- * @param userId Unique identifier of the target user
531
- */
532
- getChatMember(chatId: string | number, userId: number) {
533
- return this.callApi('getChatMember', { chat_id: chatId, user_id: userId })
534
- }
535
-
536
- /**
537
- * Get the number of members in a chat.
538
- * @param chatId Unique identifier for the target chat or username of the target supergroup or channel (in the format @channelusername)
539
- */
540
- getChatMembersCount(chatId: string | number) {
541
- return this.callApi('getChatMembersCount', { chat_id: chatId })
542
- }
543
-
544
- /**
545
- * Send answers to an inline query.
546
- * No more than 50 results per query are allowed.
547
- */
548
- answerInlineQuery(
549
- inlineQueryId: string,
550
- results: readonly tg.InlineQueryResult[],
551
- extra?: tt.ExtraAnswerInlineQuery
552
- ) {
553
- return this.callApi('answerInlineQuery', {
554
- inline_query_id: inlineQueryId,
555
- results,
556
- ...extra,
557
- })
558
- }
559
-
560
- setChatPermissions(
561
- chatId: number | string,
562
- permissions: tg.ChatPermissions,
563
- extra?: tt.ExtraSetChatPermissions
564
- ) {
565
- return this.callApi('setChatPermissions', {
566
- chat_id: chatId,
567
- permissions,
568
- ...extra,
569
- })
570
- }
571
-
572
- /**
573
- * Kick a user from a group, a supergroup or a channel. In the case of supergroups and channels, the user will not be able to return to the group 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 admin rights.
574
- * @param chatId Unique identifier for the target group or username of the target supergroup or channel (in the format `@channelusername`)
575
- * @param untilDate Date when the user will be unbanned, unix time. If user is banned for more than 366 days or less than 30 seconds from the current time they are considered to be banned forever
576
- */
577
- banChatMember(
578
- chatId: number | string,
579
- userId: number,
580
- untilDate?: number,
581
- extra?: tt.ExtraBanChatMember
582
- ) {
583
- return this.callApi('banChatMember', {
584
- chat_id: chatId,
585
- user_id: userId,
586
- until_date: untilDate,
587
- ...extra,
588
- })
589
- }
590
-
591
- /**
592
- * Kick a user from a group, a supergroup or a channel. In the case of supergroups and channels, the user will not be able to return to the group 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 admin rights.
593
- * @param chatId Unique identifier for the target group or username of the target supergroup or channel (in the format `@channelusername`)
594
- * @param untilDate Date when the user will be unbanned, unix time. If user is banned for more than 366 days or less than 30 seconds from the current time they are considered to be banned forever
595
- * @deprecated since API 5.3. Use {@link Telegram.banChatMember}
596
- */
597
- get kickChatMember() {
598
- return this.banChatMember
599
- }
600
-
601
- /**
602
- * 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 admin rights. Pass False for all boolean parameters to demote a user.
603
- * @param chatId Unique identifier for the target chat or username of the target channel (in the format `@channelusername`)
604
- */
605
- promoteChatMember(
606
- chatId: number | string,
607
- userId: number,
608
- extra: tt.ExtraPromoteChatMember
609
- ) {
610
- return this.callApi('promoteChatMember', {
611
- chat_id: chatId,
612
- user_id: userId,
613
- ...extra,
614
- })
615
- }
616
-
617
- /**
618
- * Restrict a user in a supergroup. The bot must be an administrator in the supergroup for this to work and must have the appropriate admin rights. Pass True for all boolean parameters to lift restrictions from a user.
619
- * @param chatId Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername)
620
- */
621
- restrictChatMember(
622
- chatId: string | number,
623
- userId: number,
624
- extra: tt.ExtraRestrictChatMember
625
- ) {
626
- return this.callApi('restrictChatMember', {
627
- chat_id: chatId,
628
- user_id: userId,
629
- ...extra,
630
- })
631
- }
632
-
633
- setChatAdministratorCustomTitle(
634
- chatId: number | string,
635
- userId: number,
636
- title: string
637
- ) {
638
- return this.callApi('setChatAdministratorCustomTitle', {
639
- chat_id: chatId,
640
- user_id: userId,
641
- custom_title: title,
642
- })
643
- }
644
-
645
- /**
646
- * Export an invite link to a supergroup or a channel. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights.
647
- * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
648
- */
649
- exportChatInviteLink(chatId: number | string) {
650
- return this.callApi('exportChatInviteLink', { chat_id: chatId })
651
- }
652
-
653
- createChatInviteLink(
654
- chatId: number | string,
655
- extra?: tt.ExtraCreateChatInviteLink
656
- ) {
657
- return this.callApi('createChatInviteLink', {
658
- chat_id: chatId,
659
- ...extra,
660
- })
661
- }
662
-
663
- createInvoiceLink(invoice: tt.NewInvoiceLinkParameters) {
664
- return this.callApi('createInvoiceLink', {
665
- ...invoice,
666
- })
667
- }
668
-
669
- editChatInviteLink(
670
- chatId: number | string,
671
- inviteLink: string,
672
- extra?: tt.ExtraEditChatInviteLink
673
- ) {
674
- return this.callApi('editChatInviteLink', {
675
- chat_id: chatId,
676
- invite_link: inviteLink,
677
- ...extra,
678
- })
679
- }
680
-
681
- revokeChatInviteLink(chatId: number | string, inviteLink: string) {
682
- return this.callApi('revokeChatInviteLink', {
683
- chat_id: chatId,
684
- invite_link: inviteLink,
685
- })
686
- }
687
-
688
- setChatPhoto(
689
- chatId: number | string,
690
- photo: tg.Opts<'setChatPhoto'>['photo']
691
- ) {
692
- return this.callApi('setChatPhoto', { chat_id: chatId, photo })
693
- }
694
-
695
- deleteChatPhoto(chatId: number | string) {
696
- return this.callApi('deleteChatPhoto', { chat_id: chatId })
697
- }
698
-
699
- /**
700
- * 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 admin rights.
701
- * @param chatId Unique identifier for the target group or username of the target supergroup or channel (in the format `@channelusername`)
702
- * @param title New chat title, 1-255 characters
703
- */
704
- setChatTitle(chatId: number | string, title: string) {
705
- return this.callApi('setChatTitle', { chat_id: chatId, title })
706
- }
707
-
708
- setChatDescription(chatId: number | string, description?: string) {
709
- return this.callApi('setChatDescription', { chat_id: chatId, description })
710
- }
711
-
712
- /**
713
- * Pin a message in a group, a supergroup, or a channel. The bot must be an administrator in the chat for this to work and must have the 'can_pin_messages' admin right in the supergroup or 'can_edit_messages' admin right in the channel.
714
- * @param chatId Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername)
715
- */
716
- pinChatMessage(
717
- chatId: number | string,
718
- messageId: number,
719
- extra?: { disable_notification?: boolean }
720
- ) {
721
- return this.callApi('pinChatMessage', {
722
- chat_id: chatId,
723
- message_id: messageId,
724
- ...extra,
725
- })
726
- }
727
-
728
- /**
729
- * Unpin a message in a group, a supergroup, or a channel. The bot must be an administrator in the chat for this to work and must have the 'can_pin_messages' admin right in the supergroup or 'can_edit_messages' admin right in the channel.
730
- * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
731
- */
732
- unpinChatMessage(chatId: number | string, messageId?: number) {
733
- return this.callApi('unpinChatMessage', {
734
- chat_id: chatId,
735
- message_id: messageId,
736
- })
737
- }
738
-
739
- /**
740
- * Clear the list of pinned messages in a chat.
741
- * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
742
- */
743
- unpinAllChatMessages(chatId: number | string) {
744
- return this.callApi('unpinAllChatMessages', { chat_id: chatId })
745
- }
746
-
747
- /**
748
- * Use this method for your bot to leave a group, supergroup or channel.
749
- * @param chatId Unique identifier for the target chat or username of the target supergroup or channel (in the format @channelusername)
750
- */
751
- leaveChat(chatId: number | string) {
752
- return this.callApi('leaveChat', { chat_id: chatId })
753
- }
754
-
755
- /**
756
- * Unban a user from a supergroup or a channel. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights.
757
- * @param chatId Unique identifier for the target group or username of the target supergroup or channel (in the format @username)
758
- * @param userId Unique identifier of the target user
759
- */
760
- unbanChatMember(
761
- chatId: number | string,
762
- userId: number,
763
- extra?: { only_if_banned?: boolean }
764
- ) {
765
- return this.callApi('unbanChatMember', {
766
- chat_id: chatId,
767
- user_id: userId,
768
- ...extra,
769
- })
770
- }
771
-
772
- answerCbQuery(
773
- callbackQueryId: string,
774
- text?: string,
775
- extra?: tt.ExtraAnswerCbQuery
776
- ) {
777
- return this.callApi('answerCallbackQuery', {
778
- text,
779
- callback_query_id: callbackQueryId,
780
- ...extra,
781
- })
782
- }
783
-
784
- answerGameQuery(callbackQueryId: string, url: string) {
785
- return this.callApi('answerCallbackQuery', {
786
- url,
787
- callback_query_id: callbackQueryId,
788
- })
789
- }
790
-
791
- /**
792
- * 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.
793
- * @param chat_id Unique identifier for the chat or username of the channel (in the format `@channelusername`)
794
- * @param user_id Unique identifier of the target user
795
- */
796
- getUserChatBoosts(chat_id: number | string, user_id: number) {
797
- return this.callApi('getUserChatBoosts', {
798
- chat_id,
799
- user_id,
800
- })
801
- }
802
-
803
- /**
804
- * If you sent an invoice requesting a shipping address and the parameter is_flexible was specified,
805
- * the Bot API will send an Update with a shipping_query field to the bot.
806
- * Reply to shipping queries.
807
- * @param ok Specify 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)
808
- * @param shippingOptions Required if ok is True. A JSON-serialized array of available shipping options.
809
- * @param errorMessage Required if ok is False. Error message in human readable form that explains why it is impossible to complete the order (e.g. "Sorry, delivery to your desired address is unavailable'). Telegram will display this message to the user.
810
- */
811
- answerShippingQuery(
812
- shippingQueryId: string,
813
- ok: boolean,
814
- shippingOptions: readonly tg.ShippingOption[] | undefined,
815
- errorMessage: string | undefined
816
- ) {
817
- return this.callApi('answerShippingQuery', {
818
- ok,
819
- shipping_query_id: shippingQueryId,
820
- shipping_options: shippingOptions,
821
- error_message: errorMessage,
822
- })
823
- }
824
-
825
- /**
826
- * 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.
827
- * Respond to such pre-checkout queries. On success, True is returned.
828
- * Note: The Bot API must receive an answer within 10 seconds after the pre-checkout query was sent.
829
- * @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.
830
- * @param errorMessage Required if ok is False. Error message in human readable form that explains the reason for failure to proceed with the checkout (e.g. "Sorry, somebody just bought the last of our amazing black T-shirts while you were busy filling out your payment details. Please choose a different color or garment!"). Telegram will display this message to the user.
831
- */
832
- answerPreCheckoutQuery(
833
- preCheckoutQueryId: string,
834
- ok: boolean,
835
- errorMessage?: string
836
- ) {
837
- return this.callApi('answerPreCheckoutQuery', {
838
- ok,
839
- pre_checkout_query_id: preCheckoutQueryId,
840
- error_message: errorMessage,
841
- })
842
- }
843
-
844
- answerWebAppQuery(webAppQueryId: string, result: tg.InlineQueryResult) {
845
- return this.callApi('answerWebAppQuery', {
846
- web_app_query_id: webAppQueryId,
847
- result,
848
- })
849
- }
850
-
851
- /**
852
- * Edit text and game messages sent by the bot or via the bot (for inline bots).
853
- * On success, if edited message is sent by the bot, the edited Message is returned, otherwise True is returned.
854
- * @param chatId Required if inlineMessageId is not specified. Unique identifier for the target chat or username of the target channel (in the format @channelusername)
855
- * @param messageId Required if inlineMessageId is not specified. Identifier of the sent message
856
- * @param inlineMessageId Required if chatId and messageId are not specified. Identifier of the inline message
857
- * @param text New text of the message
858
- */
859
- editMessageText(
860
- chatId: number | string | undefined,
861
- messageId: number | undefined,
862
- inlineMessageId: string | undefined,
863
- text: string | FmtString,
864
- extra?: tt.ExtraEditMessageText
865
- ) {
866
- const t = FmtString.normalise(text)
867
- return this.callApi('editMessageText', {
868
- chat_id: chatId,
869
- message_id: messageId,
870
- inline_message_id: inlineMessageId,
871
- ...extra,
872
- ...t,
873
- })
874
- }
875
-
876
- /**
877
- * Edit captions of messages sent by the bot or via the bot (for inline bots).
878
- * On success, if edited message is sent by the bot, the edited Message is returned, otherwise True is returned.
879
- * @param chatId Required if inlineMessageId is not specified. Unique identifier for the target chat or username of the target channel (in the format @channelusername)
880
- * @param messageId Required if inlineMessageId is not specified. Identifier of the sent message
881
- * @param inlineMessageId Required if chatId and messageId are not specified. Identifier of the inline message
882
- * @param caption New caption of the message
883
- * @param markup A JSON-serialized object for an inline keyboard.
884
- */
885
- editMessageCaption(
886
- chatId: number | string | undefined,
887
- messageId: number | undefined,
888
- inlineMessageId: string | undefined,
889
- caption: string | FmtString | undefined,
890
- extra?: tt.ExtraEditMessageCaption
891
- ) {
892
- return this.callApi('editMessageCaption', {
893
- chat_id: chatId,
894
- message_id: messageId,
895
- inline_message_id: inlineMessageId,
896
- ...extra,
897
- ...fmtCaption({ caption }),
898
- })
899
- }
900
-
901
- /**
902
- * Edit animation, audio, document, photo, or video messages.
903
- * If a message is a part of a message album, then it can be edited only to a photo or a video.
904
- * Otherwise, message type can be changed arbitrarily.
905
- * When inline message is edited, new file can't be uploaded.
906
- * Use previously uploaded file via its file_id or specify a URL.
907
- * @param chatId Required if inlineMessageId is not specified. Unique identifier for the target chat or username of the target channel (in the format @channelusername)
908
- * @param messageId Required if inlineMessageId is not specified. Identifier of the sent message
909
- * @param inlineMessageId Required if chatId and messageId are not specified. Identifier of the inline message
910
- * @param media New media of message
911
- * @param extra Additional parameters, such as reply_markup
912
- */
913
- editMessageMedia(
914
- chatId: number | string | undefined,
915
- messageId: number | undefined,
916
- inlineMessageId: string | undefined,
917
- media: tt.WrapCaption<tg.InputMedia>,
918
- extra?: tt.ExtraEditMessageMedia
919
- ) {
920
- return this.callApi('editMessageMedia', {
921
- chat_id: chatId,
922
- message_id: messageId,
923
- inline_message_id: inlineMessageId,
924
- media: fmtCaption(media),
925
- ...extra,
926
- })
927
- }
928
-
929
- /**
930
- * Edit only the reply markup of messages sent by the bot or via the bot (for inline bots).
931
- * @param chatId Required if inlineMessageId is not specified. Unique identifier for the target chat or username of the target channel (in the format @channelusername)
932
- * @param messageId Required if inlineMessageId is not specified. Identifier of the sent message
933
- * @param inlineMessageId Required if chatId and messageId are not specified. Identifier of the inline message
934
- * @param markup A JSON-serialized object for an inline keyboard.
935
- * @returns If edited message is sent by the bot, the edited Message is returned, otherwise True is returned.
936
- */
937
- editMessageReplyMarkup(
938
- chatId: number | string | undefined,
939
- messageId: number | undefined,
940
- inlineMessageId: string | undefined,
941
- markup: tg.InlineKeyboardMarkup | undefined
942
- ) {
943
- return this.callApi('editMessageReplyMarkup', {
944
- chat_id: chatId,
945
- message_id: messageId,
946
- inline_message_id: inlineMessageId,
947
- reply_markup: markup,
948
- })
949
- }
950
-
951
- editMessageLiveLocation(
952
- chatId: number | string | undefined,
953
- messageId: number | undefined,
954
- inlineMessageId: string | undefined,
955
- latitude: number,
956
- longitude: number,
957
- extra?: tt.ExtraEditMessageLiveLocation
958
- ) {
959
- return this.callApi('editMessageLiveLocation', {
960
- latitude,
961
- longitude,
962
- chat_id: chatId,
963
- message_id: messageId,
964
- inline_message_id: inlineMessageId,
965
- ...extra,
966
- })
967
- }
968
-
969
- stopMessageLiveLocation(
970
- chatId: number | string | undefined,
971
- messageId: number | undefined,
972
- inlineMessageId: string | undefined,
973
- markup?: tg.InlineKeyboardMarkup
974
- ) {
975
- return this.callApi('stopMessageLiveLocation', {
976
- chat_id: chatId,
977
- message_id: messageId,
978
- inline_message_id: inlineMessageId,
979
- reply_markup: markup,
980
- })
981
- }
982
-
983
- /**
984
- * Delete a message, including service messages, with the following limitations:
985
- * - A message can only be deleted if it was sent less than 48 hours ago.
986
- * - Bots can delete outgoing messages in groups and supergroups.
987
- * - Bots granted can_post_messages permissions can delete outgoing messages in channels.
988
- * - If the bot is an administrator of a group, it can delete any message there.
989
- * - If the bot has can_delete_messages permission in a supergroup or a channel, it can delete any message there.
990
- * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
991
- * @param messageId Identifier of the message to delete
992
- */
993
- deleteMessage(chatId: number | string, messageId: number) {
994
- return this.callApi('deleteMessage', {
995
- chat_id: chatId,
996
- message_id: messageId,
997
- })
998
- }
999
-
1000
- /**
1001
- * Use this method to delete multiple messages simultaneously. If some of the specified messages can't be found, they are skipped.
1002
- * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
1003
- * @param messageIds Identifiers of 1-100 messages to delete. See deleteMessage for limitations on which messages can be deleted
1004
- */
1005
- deleteMessages(chatId: number | string, messageIds: number[]) {
1006
- return this.callApi('deleteMessages', {
1007
- chat_id: chatId,
1008
- message_ids: messageIds,
1009
- })
1010
- }
1011
-
1012
- setChatStickerSet(chatId: number | string, setName: string) {
1013
- return this.callApi('setChatStickerSet', {
1014
- chat_id: chatId,
1015
- sticker_set_name: setName,
1016
- })
1017
- }
1018
-
1019
- deleteChatStickerSet(chatId: number | string) {
1020
- return this.callApi('deleteChatStickerSet', { chat_id: chatId })
1021
- }
1022
-
1023
- /**
1024
- * Use this method to get custom emoji stickers, which can be used as a forum topic icon by any user.
1025
- * Requires no parameters. Returns an Array of Sticker objects.
1026
- *
1027
- * @see https://core.telegram.org/bots/api#getforumtopiciconstickers
1028
- */
1029
- getForumTopicIconStickers() {
1030
- return this.callApi('getForumTopicIconStickers', {})
1031
- }
1032
-
1033
- /**
1034
- * Use this method to create a topic in a forum supergroup chat. The bot must be an administrator in the chat for this
1035
- * to work and must have the can_manage_topics administrator rights. Returns information about the created topic as a
1036
- * ForumTopic object.
1037
- *
1038
- * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
1039
- * @param name Topic name, 1-128 characters
1040
- *
1041
- * @see https://core.telegram.org/bots/api#createforumtopic
1042
- */
1043
- createForumTopic(
1044
- chat_id: number | string,
1045
- name: string,
1046
- extra?: tt.ExtraCreateForumTopic
1047
- ) {
1048
- return this.callApi('createForumTopic', {
1049
- chat_id,
1050
- name,
1051
- ...extra,
1052
- })
1053
- }
1054
-
1055
- /**
1056
- * Use this method to edit name and icon of a topic in a forum supergroup chat. The bot must be an administrator in
1057
- * the chat for this to work and must have can_manage_topics administrator rights, unless it is the creator of the
1058
- * topic. Returns True on success.
1059
- *
1060
- * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
1061
- * @param message_thread_id Unique identifier for the target message thread of the forum topic
1062
- *
1063
- * @see https://core.telegram.org/bots/api#editforumtopic
1064
- */
1065
- editForumTopic(
1066
- chat_id: number | string,
1067
- message_thread_id: number,
1068
- extra: tt.ExtraEditForumTopic
1069
- ) {
1070
- return this.callApi('editForumTopic', {
1071
- chat_id,
1072
- message_thread_id,
1073
- ...extra,
1074
- })
1075
- }
1076
-
1077
- /**
1078
- * Use this method to close an open topic in a forum supergroup chat. The bot must be an administrator in the chat
1079
- * for this to work and must have the can_manage_topics administrator rights, unless it is the creator of the topic.
1080
- * Returns True on success.
1081
- *
1082
- * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
1083
- * @param message_thread_id Unique identifier for the target message thread of the forum topic
1084
- *
1085
- * @see https://core.telegram.org/bots/api#closeforumtopic
1086
- */
1087
- closeForumTopic(chat_id: number | string, message_thread_id: number) {
1088
- return this.callApi('closeForumTopic', {
1089
- chat_id,
1090
- message_thread_id,
1091
- })
1092
- }
1093
-
1094
- /**
1095
- * Use this method to reopen a closed topic in a forum supergroup chat. The bot must be an administrator in the chat
1096
- * for this to work and must have the can_manage_topics administrator rights, unless it is the creator of the topic.
1097
- * Returns True on success.
1098
- *
1099
- * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
1100
- * @param message_thread_id Unique identifier for the target message thread of the forum topic
1101
- *
1102
- * @see https://core.telegram.org/bots/api#reopenforumtopic
1103
- */
1104
- reopenForumTopic(chat_id: number | string, message_thread_id: number) {
1105
- return this.callApi('reopenForumTopic', {
1106
- chat_id,
1107
- message_thread_id,
1108
- })
1109
- }
1110
-
1111
- /**
1112
- * Use this method to delete a forum topic along with all its messages in a forum supergroup chat. The bot must be an
1113
- * administrator in the chat for this to work and must have the can_delete_messages administrator rights.
1114
- * Returns True on success.
1115
- *
1116
- * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
1117
- * @param message_thread_id Unique identifier for the target message thread of the forum topic
1118
- *
1119
- * @see https://core.telegram.org/bots/api#deleteforumtopic
1120
- */
1121
- deleteForumTopic(chat_id: number | string, message_thread_id: number) {
1122
- return this.callApi('deleteForumTopic', {
1123
- chat_id,
1124
- message_thread_id,
1125
- })
1126
- }
1127
-
1128
- /**
1129
- * Use this method to clear the list of pinned messages in a forum topic. The bot must be an administrator in the chat
1130
- * for this to work and must have the can_pin_messages administrator right in the supergroup. Returns True on success.
1131
- *
1132
- * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
1133
- * @param message_thread_id Unique identifier for the target message thread of the forum topic
1134
- *
1135
- * @see https://core.telegram.org/bots/api#unpinallforumtopicmessages
1136
- */
1137
- unpinAllForumTopicMessages(
1138
- chat_id: number | string,
1139
- message_thread_id: number
1140
- ) {
1141
- return this.callApi('unpinAllForumTopicMessages', {
1142
- chat_id,
1143
- message_thread_id,
1144
- })
1145
- }
1146
-
1147
- /**
1148
- * Use this method to edit the name of the 'General' topic in a forum supergroup chat. The bot must be an administrator
1149
- * in the chat for this to work and must have can_manage_topics administrator rights. Returns True on success.
1150
- *
1151
- * @param chat_id Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername)
1152
- * @param name New topic name, 1-128 characters
1153
- *
1154
- * @see https://core.telegram.org/bots/api#editgeneralforumtopic
1155
- */
1156
- editGeneralForumTopic(chat_id: number | string, name: string) {
1157
- return this.callApi('editGeneralForumTopic', { chat_id, name })
1158
- }
1159
-
1160
- /**
1161
- * Use this method to close an open 'General' topic in a forum supergroup chat. The bot must be an administrator in the
1162
- * chat for this to work and must have the can_manage_topics administrator rights. Returns True on success.
1163
- *
1164
- * @param chat_id Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername)
1165
- *
1166
- * @see https://core.telegram.org/bots/api#closegeneralforumtopic
1167
- */
1168
- closeGeneralForumTopic(chat_id: number | string) {
1169
- return this.callApi('closeGeneralForumTopic', { chat_id })
1170
- }
1171
-
1172
- /**
1173
- * Use this method to reopen a closed 'General' topic in a forum supergroup chat. The bot must be an administrator in
1174
- * the chat for this to work and must have the can_manage_topics administrator rights. The topic will be automatically
1175
- * unhidden if it was hidden. Returns True on success.
1176
- *
1177
- * @param chat_id Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername)
1178
- *
1179
- * @see https://core.telegram.org/bots/api#reopengeneralforumtopic
1180
- */
1181
- reopenGeneralForumTopic(chat_id: number | string) {
1182
- return this.callApi('reopenGeneralForumTopic', { chat_id })
1183
- }
1184
-
1185
- /**
1186
- * Use this method to hide the 'General' topic in a forum supergroup chat. The bot must be an administrator in the chat
1187
- * for this to work and must have the can_manage_topics administrator rights. The topic will be automatically closed
1188
- * if it was open. Returns True on success.
1189
- *
1190
- * @param chat_id Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername)
1191
- *
1192
- * @see https://core.telegram.org/bots/api#hidegeneralforumtopic
1193
- */
1194
- hideGeneralForumTopic(chat_id: number | string) {
1195
- return this.callApi('hideGeneralForumTopic', { chat_id })
1196
- }
1197
-
1198
- /**
1199
- * Use this method to unhide the 'General' topic in a forum supergroup chat. The bot must be an administrator in the
1200
- * chat for this to work and must have the can_manage_topics administrator rights. Returns True on success.
1201
- *
1202
- * @param chat_id Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername)
1203
- *
1204
- * @see https://core.telegram.org/bots/api#unhidegeneralforumtopic
1205
- */
1206
- unhideGeneralForumTopic(chat_id: number | string) {
1207
- return this.callApi('unhideGeneralForumTopic', { chat_id })
1208
- }
1209
-
1210
- /**
1211
- * Use this method to clear the list of pinned messages in a General forum topic.
1212
- * The bot must be an administrator in the chat for this to work and must have the can_pin_messages administrator
1213
- * right in the supergroup.
1214
- *
1215
- * @param chat_id Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername)
1216
- */
1217
- unpinAllGeneralForumTopicMessages(chat_id: number | string) {
1218
- return this.callApi('unpinAllGeneralForumTopicMessages', { chat_id })
1219
- }
1220
-
1221
- getStickerSet(name: string) {
1222
- return this.callApi('getStickerSet', { name })
1223
- }
1224
-
1225
- /**
1226
- * Upload a .png file with a sticker for later use in createNewStickerSet and addStickerToSet methods (can be used multiple times).
1227
- * https://core.telegram.org/bots/api#sending-files
1228
- * @param ownerId User identifier of sticker file owner
1229
- * @param stickerFile Png image with the sticker, must be up to 512 kilobytes in size, dimensions must not exceed 512px, and either width or height must be exactly 512px.
1230
- */
1231
- uploadStickerFile(
1232
- ownerId: number,
1233
- sticker: tg.Opts<'uploadStickerFile'>['sticker'],
1234
- sticker_format: tg.Opts<'uploadStickerFile'>['sticker_format']
1235
- ) {
1236
- return this.callApi('uploadStickerFile', {
1237
- user_id: ownerId,
1238
- sticker_format,
1239
- sticker,
1240
- })
1241
- }
1242
-
1243
- /**
1244
- * Create new sticker set owned by a user. The bot will be able to edit the created sticker set.
1245
- * @param ownerId User identifier of created sticker set owner
1246
- * @param name Short name of sticker set, to be used in t.me/addstickers/ URLs (e.g., animals). Can contain only english letters, digits and underscores. Must begin with a letter, can't contain consecutive underscores and must end in “_by_<bot username>”. <bot_username> is case insensitive. 1-64 characters.
1247
- * @param title Sticker set title, 1-64 characters
1248
- */
1249
- createNewStickerSet(
1250
- ownerId: number,
1251
- name: string,
1252
- title: string,
1253
- stickerData: tt.ExtraCreateNewStickerSet
1254
- ) {
1255
- return this.callApi('createNewStickerSet', {
1256
- name,
1257
- title,
1258
- user_id: ownerId,
1259
- ...stickerData,
1260
- })
1261
- }
1262
-
1263
- /**
1264
- * Add a new sticker to a set created by the bot.
1265
- * @param ownerId User identifier of sticker set owner
1266
- * @param name Sticker set name
1267
- */
1268
- addStickerToSet(
1269
- ownerId: number,
1270
- name: string,
1271
- stickerData: tt.ExtraAddStickerToSet
1272
- ) {
1273
- return this.callApi('addStickerToSet', {
1274
- name,
1275
- user_id: ownerId,
1276
- ...stickerData,
1277
- })
1278
- }
1279
-
1280
- /**
1281
- * Move a sticker in a set created by the bot to a specific position.
1282
- * @param sticker File identifier of the sticker
1283
- * @param position New sticker position in the set, zero-based
1284
- */
1285
- setStickerPositionInSet(sticker: string, position: number) {
1286
- return this.callApi('setStickerPositionInSet', {
1287
- sticker,
1288
- position,
1289
- })
1290
- }
1291
-
1292
- /**
1293
- * @deprecated since API 6.8. Use {@link Telegram.setStickerSetThumbnail}
1294
- */
1295
- get setStickerSetThumb() {
1296
- return this.setStickerSetThumbnail
1297
- }
1298
-
1299
- /**
1300
- * Use this method to set the thumbnail of a regular or mask sticker set.
1301
- * The format of the thumbnail file must match the format of the stickers in the set.
1302
- * @param name Sticker set name
1303
- * @param userId User identifier of the sticker set owner
1304
- * @param thumbnail A .WEBP or .PNG image with the thumbnail, must be up to 128 kilobytes in size
1305
- * and have a width and height of exactly 100px, or a .TGS animation with a thumbnail up to
1306
- * 32 kilobytes in size (see
1307
- * [animated sticker technical requirements](https://core.telegram.org/stickers#animated-sticker-requirements)),
1308
- * or a WEBM video with the thumbnail up to 32 kilobytes in size; see
1309
- * [video sticker technical requirements](https://core.telegram.org/stickers#video-sticker-requirements).
1310
- * Pass a file_id as a String to send a file that already exists on the Telegram servers, pass a
1311
- * HTTP URL as a String for Telegram to get a file from the Internet, or upload a new one using
1312
- * Input helpers. Animated and video sticker set thumbnails can't be uploaded via HTTP URL.
1313
- * If omitted, then the thumbnail is dropped and the first sticker is used as the thumbnail.
1314
- */
1315
- setStickerSetThumbnail(
1316
- name: string,
1317
- userId: number,
1318
- thumbnail?: tg.Opts<'setStickerSetThumbnail'>['thumbnail']
1319
- ) {
1320
- return this.callApi('setStickerSetThumbnail', {
1321
- name,
1322
- user_id: userId,
1323
- thumbnail,
1324
- })
1325
- }
1326
-
1327
- setStickerMaskPosition(sticker: string, mask_position?: tg.MaskPosition) {
1328
- return this.callApi('setStickerMaskPosition', { sticker, mask_position })
1329
- }
1330
-
1331
- setStickerKeywords(sticker: string, keywords?: string[]) {
1332
- return this.callApi('setStickerKeywords', { sticker, keywords })
1333
- }
1334
-
1335
- setStickerEmojiList(sticker: string, emoji_list: string[]) {
1336
- return this.callApi('setStickerEmojiList', { sticker, emoji_list })
1337
- }
1338
-
1339
- deleteStickerSet(name: string) {
1340
- return this.callApi('deleteStickerSet', { name })
1341
- }
1342
-
1343
- setStickerSetTitle(name: string, title: string) {
1344
- return this.callApi('setStickerSetTitle', { name, title })
1345
- }
1346
-
1347
- setCustomEmojiStickerSetThumbnail(name: string, custom_emoji_id: string) {
1348
- return this.callApi('setCustomEmojiStickerSetThumbnail', {
1349
- name,
1350
- custom_emoji_id,
1351
- })
1352
- }
1353
-
1354
- /**
1355
- * Delete a sticker from a set created by the bot.
1356
- * @param sticker File identifier of the sticker
1357
- */
1358
- deleteStickerFromSet(sticker: string) {
1359
- return this.callApi('deleteStickerFromSet', { sticker })
1360
- }
1361
-
1362
- getCustomEmojiStickers(custom_emoji_ids: string[]) {
1363
- return this.callApi('getCustomEmojiStickers', { custom_emoji_ids })
1364
- }
1365
-
1366
- /**
1367
- * Change the list of the bot's commands.
1368
- * @param commands A list of bot commands to be set as the list of the bot's commands. At most 100 commands can be specified.
1369
- */
1370
- setMyCommands(
1371
- commands: readonly tg.BotCommand[],
1372
- extra?: tt.ExtraSetMyCommands
1373
- ) {
1374
- return this.callApi('setMyCommands', { commands, ...extra })
1375
- }
1376
-
1377
- deleteMyCommands(extra: tg.Opts<'deleteMyCommands'> = {}) {
1378
- return this.callApi('deleteMyCommands', extra)
1379
- }
1380
-
1381
- /**
1382
- * Get the current list of the bot's commands.
1383
- */
1384
- getMyCommands(extra: tg.Opts<'getMyCommands'> = {}) {
1385
- return this.callApi('getMyCommands', extra)
1386
- }
1387
-
1388
- /**
1389
- * Use this method to change the bot's description, which is shown in the chat with the bot if the chat is empty.
1390
- * @param description New bot description; 0-512 characters. Pass an empty string to remove the dedicated description for the given language.
1391
- * @param language_code A two-letter ISO 639-1 language code. If empty, the description will be applied to all users for whose language there is no dedicated description.
1392
- */
1393
- setMyDescription(description: string, language_code?: string) {
1394
- return this.callApi('setMyDescription', { description, language_code })
1395
- }
1396
-
1397
- /**
1398
- * Use this method to change the bot's name.
1399
- * @param name New bot name; 0-64 characters. Pass an empty string to remove the dedicated name for the given language.
1400
- * @param language_code A two-letter ISO 639-1 language code. If empty, the name will be shown to all users for whose language there is no dedicated name.
1401
- */
1402
- setMyName(name: string, language_code?: string) {
1403
- return this.callApi('setMyName', { name, language_code })
1404
- }
1405
-
1406
- /**
1407
- * Use this method to get the current bot name for the given user language.
1408
- * @param language_code A two-letter ISO 639-1 language code or an empty string
1409
- */
1410
- getMyName(language_code?: string) {
1411
- return this.callApi('getMyName', { language_code })
1412
- }
1413
-
1414
- /**
1415
- * Use this method to get the current bot description for the given user language.
1416
- * @param language_code A two-letter ISO 639-1 language code.
1417
- */
1418
- getMyDescription(language_code?: string) {
1419
- return this.callApi('getMyDescription', { language_code })
1420
- }
1421
-
1422
- /**
1423
- * Use this method to change the bot's short description, which is shown on the bot's profile page and is sent together with the link when users share the bot.
1424
- * @param description New short description for the bot; 0-120 characters. Pass an empty string to remove the dedicated short description for the given language.
1425
- * @param language_code A two-letter ISO 639-1 language code. If empty, the short description will be applied to all users for whose language there is no dedicated short description.
1426
- */
1427
- setMyShortDescription(short_description: string, language_code?: string) {
1428
- return this.callApi('setMyShortDescription', {
1429
- short_description,
1430
- language_code,
1431
- })
1432
- }
1433
-
1434
- /**
1435
- * Use this method to get the current bot short description for the given user language.
1436
- * @param language_code A two-letter ISO 639-1 language code or an empty string
1437
- */
1438
- getMyShortDescription(language_code?: string) {
1439
- return this.callApi('getMyShortDescription', { language_code })
1440
- }
1441
-
1442
- setPassportDataErrors(
1443
- userId: number,
1444
- errors: readonly tg.PassportElementError[]
1445
- ) {
1446
- return this.callApi('setPassportDataErrors', {
1447
- user_id: userId,
1448
- errors: errors,
1449
- })
1450
- }
1451
-
1452
- /**
1453
- * Send copy of existing message.
1454
- * @deprecated use `copyMessage` instead
1455
- * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
1456
- * @param message Received message object
1457
- */
1458
- sendCopy(
1459
- chatId: number | string,
1460
- message: tg.Message,
1461
- extra?: tt.ExtraCopyMessage
1462
- ): Promise<tg.MessageId> {
1463
- return this.copyMessage(chatId, message.chat.id, message.message_id, extra)
1464
- }
1465
-
1466
- /**
1467
- * Send copy of existing message.
1468
- * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
1469
- * @param fromChatId Unique identifier for the chat where the original message was sent (or channel username in the format @channelusername)
1470
- * @param messageId Message identifier in the chat specified in from_chat_id
1471
- */
1472
- copyMessage(
1473
- chatId: number | string,
1474
- fromChatId: number | string,
1475
- messageId: number,
1476
- extra?: tt.ExtraCopyMessage
1477
- ) {
1478
- return this.callApi('copyMessage', {
1479
- chat_id: chatId,
1480
- from_chat_id: fromChatId,
1481
- message_id: messageId,
1482
- ...fmtCaption(extra),
1483
- })
1484
- }
1485
-
1486
- /**
1487
- * 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, 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.
1488
- * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
1489
- * @param fromChatId Unique identifier for the chat where the original messages were sent (or channel username in the format @channelusername)
1490
- * @param messageIds Identifiers of 1-100 messages in the chat from_chat_id to copy. The identifiers must be specified in a strictly increasing order.
1491
- */
1492
- copyMessages(
1493
- chatId: number | string,
1494
- fromChatId: number | string,
1495
- messageIds: number[],
1496
- extra?: tt.ExtraCopyMessages
1497
- ) {
1498
- return this.callApi('copyMessages', {
1499
- chat_id: chatId,
1500
- from_chat_id: fromChatId,
1501
- message_ids: messageIds,
1502
- ...extra,
1503
- })
1504
- }
1505
-
1506
- /**
1507
- * Approve a chat join request.
1508
- * The bot must be an administrator in the chat for this to work and must have the can_invite_users administrator right.
1509
- * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
1510
- * @param userId Unique identifier of the target user
1511
- */
1512
- approveChatJoinRequest(chatId: number | string, userId: number) {
1513
- return this.callApi('approveChatJoinRequest', {
1514
- chat_id: chatId,
1515
- user_id: userId,
1516
- })
1517
- }
1518
-
1519
- /**
1520
- * Decline a chat join request.
1521
- * The bot must be an administrator in the chat for this to work and must have the can_invite_users administrator right.
1522
- * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
1523
- * @param userId Unique identifier of the target user
1524
- */
1525
- declineChatJoinRequest(chatId: number | string, userId: number) {
1526
- return this.callApi('declineChatJoinRequest', {
1527
- chat_id: chatId,
1528
- user_id: userId,
1529
- })
1530
- }
1531
-
1532
- /**
1533
- * Ban a channel chat in a supergroup or a channel. The owner of the chat will not be able to send messages and join live streams on behalf of the chat, unless it is unbanned first.
1534
- * The bot must be an administrator in the supergroup or channel for this to work and must have the appropriate administrator rights.
1535
- * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
1536
- * @param senderChatId Unique identifier of the target sender chat
1537
- */
1538
- banChatSenderChat(
1539
- chatId: number | string,
1540
- senderChatId: number,
1541
- extra?: tt.ExtraBanChatSenderChat
1542
- ) {
1543
- return this.callApi('banChatSenderChat', {
1544
- chat_id: chatId,
1545
- sender_chat_id: senderChatId,
1546
- ...extra,
1547
- })
1548
- }
1549
-
1550
- /**
1551
- * Unban a previously banned channel chat in a supergroup or channel.
1552
- * The bot must be an administrator for this to work and must have the appropriate administrator rights.
1553
- * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
1554
- * @param senderChatId Unique identifier of the target sender chat
1555
- */
1556
- unbanChatSenderChat(chatId: number | string, senderChatId: number) {
1557
- return this.callApi('unbanChatSenderChat', {
1558
- chat_id: chatId,
1559
- sender_chat_id: senderChatId,
1560
- })
1561
- }
1562
-
1563
- /**
1564
- * Use this method to change the bot's menu button in a private chat, or the default menu button. Returns true on success.
1565
- * @param chatId Unique identifier for the target private chat. If not specified, default bot's menu button will be changed.
1566
- * @param menuButton An object for the bot's new menu button.
1567
- */
1568
- setChatMenuButton({
1569
- chatId,
1570
- menuButton,
1571
- }: {
1572
- chatId?: number | undefined
1573
- menuButton?: tg.MenuButton | undefined
1574
- } = {}) {
1575
- return this.callApi('setChatMenuButton', {
1576
- chat_id: chatId,
1577
- menu_button: menuButton,
1578
- })
1579
- }
1580
-
1581
- /**
1582
- * 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.
1583
- * @param chatId Unique identifier for the target private chat. If not specified, default bot's menu button will be returned.
1584
- */
1585
- getChatMenuButton({ chatId }: { chatId?: number } = {}) {
1586
- return this.callApi('getChatMenuButton', {
1587
- chat_id: chatId,
1588
- })
1589
- }
1590
-
1591
- /**
1592
- * Use this method to change the default administrator rights requested by the bot when it's added as an administrator to groups or channels.
1593
- * These rights will be suggested to users, but they are are free to modify the list before adding the bot.
1594
- */
1595
- setMyDefaultAdministratorRights({
1596
- rights,
1597
- forChannels,
1598
- }: {
1599
- rights?: tg.ChatAdministratorRights
1600
- forChannels?: boolean
1601
- } = {}) {
1602
- return this.callApi('setMyDefaultAdministratorRights', {
1603
- rights,
1604
- for_channels: forChannels,
1605
- })
1606
- }
1607
-
1608
- /**
1609
- * Use this method to get the current default administrator rights of the bot. Returns ChatAdministratorRights on success.
1610
- * @param forChannels Pass true to get default administrator rights of the bot in channels. Otherwise, default administrator rights of the bot for groups and supergroups will be returned.
1611
- */
1612
- getMyDefaultAdministratorRights({
1613
- forChannels,
1614
- }: { forChannels?: boolean } = {}) {
1615
- return this.callApi('getMyDefaultAdministratorRights', {
1616
- for_channels: forChannels,
1617
- })
1618
- }
1619
-
1620
- /**
1621
- * Log out from the cloud Bot API server before launching the bot locally.
1622
- */
1623
- logOut() {
1624
- return this.callApi('logOut', {})
1625
- }
1626
-
1627
- /**
1628
- * Close the bot instance before moving it from one local server to another.
1629
- */
1630
- close() {
1631
- return this.callApi('close', {})
1632
- }
1633
- }
1634
-
1635
- export default Telegram
1
+ import * as tg from './core/types/typegram'
2
+ import * as tt from './telegram-types'
3
+ import ApiClient from './core/network/client'
4
+ import { isAbsolute } from 'path'
5
+ import { URL } from 'url'
6
+ import { FmtString } from './format'
7
+ import { fmtCaption } from './core/helpers/util'
8
+
9
+ export class Telegram extends ApiClient {
10
+ /**
11
+ * Get basic information about the bot
12
+ */
13
+ getMe() {
14
+ return this.callApi('getMe', {})
15
+ }
16
+
17
+ /**
18
+ * Get basic info about a file and prepare it for downloading.
19
+ * @param fileId Id of file to get link to
20
+ */
21
+ getFile(fileId: string) {
22
+ return this.callApi('getFile', { file_id: fileId })
23
+ }
24
+
25
+ /**
26
+ * Get download link to a file.
27
+ */
28
+ async getFileLink(fileId: string | tg.File) {
29
+ if (typeof fileId === 'string') {
30
+ fileId = await this.getFile(fileId)
31
+ } else if (fileId.file_path === undefined) {
32
+ fileId = await this.getFile(fileId.file_id)
33
+ }
34
+
35
+ // Local bot API instances return the absolute path to the file
36
+ if (fileId.file_path !== undefined && isAbsolute(fileId.file_path)) {
37
+ const url = new URL(this.options.apiRoot)
38
+ url.port = ''
39
+ url.pathname = fileId.file_path
40
+ url.protocol = 'file:'
41
+ return url
42
+ }
43
+
44
+ return new URL(
45
+ `./file/${this.options.apiMode}${this.token}${
46
+ this.options.testEnv ? '/test' : ''
47
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
48
+ }/${fileId.file_path!}`,
49
+ this.options.apiRoot
50
+ )
51
+ }
52
+
53
+ /**
54
+ * Directly request incoming updates.
55
+ * You should probably use `Telegraf::launch` instead.
56
+ */
57
+ getUpdates(
58
+ timeout: number,
59
+ limit: number,
60
+ offset: number,
61
+ allowedUpdates: readonly tt.UpdateType[] | undefined
62
+ ) {
63
+ return this.callApi('getUpdates', {
64
+ allowed_updates: allowedUpdates,
65
+ limit,
66
+ offset,
67
+ timeout,
68
+ })
69
+ }
70
+
71
+ getWebhookInfo() {
72
+ return this.callApi('getWebhookInfo', {})
73
+ }
74
+
75
+ getGameHighScores(
76
+ userId: number,
77
+ inlineMessageId: string | undefined,
78
+ chatId: number | undefined,
79
+ messageId: number | undefined
80
+ ) {
81
+ return this.callApi('getGameHighScores', {
82
+ user_id: userId,
83
+ inline_message_id: inlineMessageId,
84
+ chat_id: chatId,
85
+ message_id: messageId,
86
+ })
87
+ }
88
+
89
+ setGameScore(
90
+ userId: number,
91
+ score: number,
92
+ inlineMessageId: string | undefined,
93
+ chatId: number | undefined,
94
+ messageId: number | undefined,
95
+ editMessage = true,
96
+ force = false
97
+ ) {
98
+ return this.callApi('setGameScore', {
99
+ force,
100
+ score,
101
+ user_id: userId,
102
+ inline_message_id: inlineMessageId,
103
+ chat_id: chatId,
104
+ message_id: messageId,
105
+ disable_edit_message: !editMessage,
106
+ })
107
+ }
108
+
109
+ /**
110
+ * Specify a url to receive incoming updates via an outgoing webhook.
111
+ * @param url HTTPS url to send updates to. Use an empty string to remove webhook integration
112
+ */
113
+ setWebhook(url: string, extra?: tt.ExtraSetWebhook) {
114
+ return this.callApi('setWebhook', {
115
+ url,
116
+ ...extra,
117
+ })
118
+ }
119
+
120
+ /**
121
+ * Remove webhook integration.
122
+ */
123
+ deleteWebhook(extra?: { drop_pending_updates?: boolean }) {
124
+ return this.callApi('deleteWebhook', {
125
+ ...extra,
126
+ })
127
+ }
128
+
129
+ /**
130
+ * Send a text message.
131
+ * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
132
+ * @param text Text of the message to be sent
133
+ */
134
+ sendMessage(
135
+ chatId: number | string,
136
+ text: string | FmtString,
137
+ extra?: tt.ExtraReplyMessage
138
+ ) {
139
+ const t = FmtString.normalise(text)
140
+ return this.callApi('sendMessage', { chat_id: chatId, ...extra, ...t })
141
+ }
142
+
143
+ /**
144
+ * Forward existing message.
145
+ * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
146
+ * @param fromChatId Unique identifier for the chat where the original message was sent (or channel username in the format @channelusername)
147
+ * @param messageId Message identifier in the chat specified in from_chat_id
148
+ */
149
+ forwardMessage(
150
+ chatId: number | string,
151
+ fromChatId: number | string,
152
+ messageId: number,
153
+ extra?: tt.ExtraForwardMessage
154
+ ) {
155
+ return this.callApi('forwardMessage', {
156
+ chat_id: chatId,
157
+ from_chat_id: fromChatId,
158
+ message_id: messageId,
159
+ ...extra,
160
+ })
161
+ }
162
+
163
+ /**
164
+ * 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.
165
+ * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
166
+ * @param fromChatId Unique identifier for the chat where the original messages were sent (or channel username in the format @channelusername)
167
+ * @param messageIds Identifiers of 1-100 messages in the chat from_chat_id to forward. The identifiers must be specified in a strictly increasing order.
168
+ */
169
+ forwardMessages(
170
+ chatId: number | string,
171
+ fromChatId: number | string,
172
+ messageIds: number[],
173
+ extra?: tt.ExtraForwardMessages
174
+ ) {
175
+ return this.callApi('forwardMessages', {
176
+ chat_id: chatId,
177
+ from_chat_id: fromChatId,
178
+ message_ids: messageIds,
179
+ ...extra,
180
+ })
181
+ }
182
+
183
+ /**
184
+ * Use this method when you need to tell the user that something is happening on the bot's side.
185
+ * The status is set for 5 seconds or less (when a message arrives from your bot, Telegram clients clear its typing status).
186
+ * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
187
+ */
188
+ sendChatAction(
189
+ chat_id: number | string,
190
+ action: tt.ChatAction,
191
+ extra?: tt.ExtraSendChatAction
192
+ ) {
193
+ return this.callApi('sendChatAction', { chat_id, action, ...extra })
194
+ }
195
+
196
+ /**
197
+ * Use this method to change the chosen reactions on a message. Service messages can't be reacted to.
198
+ * Automatically forwarded messages from a channel to its discussion group have the same available
199
+ * reactions as messages in the channel. In albums, bots must react to the first message.
200
+ * @param chat_id Unique identifier for the target chat or username of the target channel (in the format `@channelusername`)
201
+ * @param message_id Identifier of the target message
202
+ * @param reaction New list of reaction types to set on the message. Currently, as non-premium users, bots can set up
203
+ * to one reaction per message. A custom emoji reaction can be used if it is either already present on the message
204
+ * or explicitly allowed by chat administrators.
205
+ * @param is_big Pass True to set the reaction with a big animation
206
+ * @returns
207
+ */
208
+ setMessageReaction(
209
+ chat_id: number | string,
210
+ message_id: number,
211
+ reaction?: tg.ReactionType[],
212
+ is_big?: boolean
213
+ ) {
214
+ return this.callApi('setMessageReaction', {
215
+ chat_id,
216
+ message_id,
217
+ reaction,
218
+ is_big,
219
+ })
220
+ }
221
+
222
+ getUserProfilePhotos(userId: number, offset?: number, limit?: number) {
223
+ return this.callApi('getUserProfilePhotos', {
224
+ user_id: userId,
225
+ offset,
226
+ limit,
227
+ })
228
+ }
229
+
230
+ /**
231
+ * Send point on the map.
232
+ * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
233
+ */
234
+ sendLocation(
235
+ chatId: number | string,
236
+ latitude: number,
237
+ longitude: number,
238
+ extra?: tt.ExtraLocation
239
+ ) {
240
+ return this.callApi('sendLocation', {
241
+ chat_id: chatId,
242
+ latitude,
243
+ longitude,
244
+ ...extra,
245
+ })
246
+ }
247
+
248
+ sendVenue(
249
+ chatId: number | string,
250
+ latitude: number,
251
+ longitude: number,
252
+ title: string,
253
+ address: string,
254
+ extra?: tt.ExtraVenue
255
+ ) {
256
+ return this.callApi('sendVenue', {
257
+ latitude,
258
+ longitude,
259
+ title,
260
+ address,
261
+ chat_id: chatId,
262
+ ...extra,
263
+ })
264
+ }
265
+
266
+ /**
267
+ * @param chatId Unique identifier for the target private chat
268
+ */
269
+ sendInvoice(
270
+ chatId: number | string,
271
+ invoice: tt.NewInvoiceParameters,
272
+ extra?: tt.ExtraInvoice
273
+ ) {
274
+ return this.callApi('sendInvoice', {
275
+ chat_id: chatId,
276
+ ...invoice,
277
+ ...extra,
278
+ })
279
+ }
280
+
281
+ sendContact(
282
+ chatId: number | string,
283
+ phoneNumber: string,
284
+ firstName: string,
285
+ extra?: tt.ExtraContact
286
+ ) {
287
+ return this.callApi('sendContact', {
288
+ chat_id: chatId,
289
+ phone_number: phoneNumber,
290
+ first_name: firstName,
291
+ ...extra,
292
+ })
293
+ }
294
+
295
+ /**
296
+ * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
297
+ */
298
+ sendPhoto(
299
+ chatId: number | string,
300
+ photo: tg.Opts<'sendPhoto'>['photo'],
301
+ extra?: tt.ExtraPhoto
302
+ ) {
303
+ return this.callApi('sendPhoto', {
304
+ chat_id: chatId,
305
+ photo,
306
+ ...fmtCaption(extra),
307
+ })
308
+ }
309
+
310
+ /**
311
+ * Send a dice, which will have a random value from 1 to 6.
312
+ * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
313
+ */
314
+ sendDice(chatId: number | string, extra?: tt.ExtraDice) {
315
+ return this.callApi('sendDice', { chat_id: chatId, ...extra })
316
+ }
317
+
318
+ /**
319
+ * Send general files. Bots can currently send files of any type of up to 50 MB in size, this limit may be changed in the future.
320
+ * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
321
+ */
322
+ sendDocument(
323
+ chatId: number | string,
324
+ document: tg.Opts<'sendDocument'>['document'],
325
+ extra?: tt.ExtraDocument
326
+ ) {
327
+ return this.callApi('sendDocument', {
328
+ chat_id: chatId,
329
+ document,
330
+ ...fmtCaption(extra),
331
+ })
332
+ }
333
+
334
+ /**
335
+ * Send audio files, if you want Telegram clients to display them in the music player.
336
+ * Your audio must be in the .mp3 format.
337
+ * Bots can currently send audio files of up to 50 MB in size, this limit may be changed in the future.
338
+ * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
339
+ */
340
+ sendAudio(
341
+ chatId: number | string,
342
+ audio: tg.Opts<'sendAudio'>['audio'],
343
+ extra?: tt.ExtraAudio
344
+ ) {
345
+ return this.callApi('sendAudio', {
346
+ chat_id: chatId,
347
+ audio,
348
+ ...fmtCaption(extra),
349
+ })
350
+ }
351
+
352
+ /**
353
+ * Send .webp, animated .tgs, or video .webm stickers
354
+ * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
355
+ */
356
+ sendSticker(
357
+ chatId: number | string,
358
+ sticker: tg.Opts<'sendSticker'>['sticker'],
359
+ extra?: tt.ExtraSticker
360
+ ) {
361
+ return this.callApi('sendSticker', { chat_id: chatId, sticker, ...extra })
362
+ }
363
+
364
+ /**
365
+ * Send video files, Telegram clients support mp4 videos (other formats may be sent as Document).
366
+ * Bots can currently send video files of up to 50 MB in size, this limit may be changed in the future.
367
+ * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
368
+ */
369
+ sendVideo(
370
+ chatId: number | string,
371
+ video: tg.Opts<'sendVideo'>['video'],
372
+ extra?: tt.ExtraVideo
373
+ ) {
374
+ return this.callApi('sendVideo', {
375
+ chat_id: chatId,
376
+ video,
377
+ ...fmtCaption(extra),
378
+ })
379
+ }
380
+
381
+ /**
382
+ * Send .gif animations.
383
+ * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
384
+ */
385
+ sendAnimation(
386
+ chatId: number | string,
387
+ animation: tg.Opts<'sendAnimation'>['animation'],
388
+ extra?: tt.ExtraAnimation
389
+ ) {
390
+ return this.callApi('sendAnimation', {
391
+ chat_id: chatId,
392
+ animation,
393
+ ...fmtCaption(extra),
394
+ })
395
+ }
396
+
397
+ /**
398
+ * Send video messages.
399
+ * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
400
+ */
401
+ sendVideoNote(
402
+ chatId: number | string,
403
+ videoNote: string | tg.InputFileVideoNote,
404
+ extra?: tt.ExtraVideoNote
405
+ ) {
406
+ return this.callApi('sendVideoNote', {
407
+ chat_id: chatId,
408
+ video_note: videoNote,
409
+ ...extra,
410
+ })
411
+ }
412
+
413
+ /**
414
+ * 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.
415
+ * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
416
+ */
417
+ sendVoice(
418
+ chatId: number | string,
419
+ voice: tg.Opts<'sendVoice'>['voice'],
420
+ extra?: tt.ExtraVoice
421
+ ) {
422
+ return this.callApi('sendVoice', {
423
+ chat_id: chatId,
424
+ voice,
425
+ ...fmtCaption(extra),
426
+ })
427
+ }
428
+
429
+ /**
430
+ * @param chatId Unique identifier for the target chat
431
+ * @param gameShortName Short name of the game, serves as the unique identifier for the game. Set up your games via Botfather.
432
+ */
433
+ sendGame(chatId: number, gameName: string, extra?: tt.ExtraGame) {
434
+ return this.callApi('sendGame', {
435
+ chat_id: chatId,
436
+ game_short_name: gameName,
437
+ ...extra,
438
+ })
439
+ }
440
+
441
+ /**
442
+ * Send a group of photos or videos as an album.
443
+ * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
444
+ * @param media A JSON-serialized array describing photos and videos to be sent, must include 2–10 items
445
+ */
446
+ sendMediaGroup(
447
+ chatId: number | string,
448
+ media: tt.MediaGroup,
449
+ extra?: tt.ExtraMediaGroup
450
+ ) {
451
+ return this.callApi('sendMediaGroup', { chat_id: chatId, media, ...extra })
452
+ }
453
+
454
+ /**
455
+ * Send a native poll.
456
+ * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
457
+ * @param question Poll question, 1-255 characters
458
+ * @param options A JSON-serialized list of answer options, 2-10 strings 1-100 characters each
459
+ */
460
+ sendPoll(
461
+ chatId: number | string,
462
+ question: string,
463
+ options: readonly string[],
464
+ extra?: tt.ExtraPoll
465
+ ) {
466
+ return this.callApi('sendPoll', {
467
+ chat_id: chatId,
468
+ type: 'regular',
469
+ question,
470
+ options,
471
+ ...extra,
472
+ })
473
+ }
474
+
475
+ /**
476
+ * Send a native quiz.
477
+ * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
478
+ * @param question Poll question, 1-255 characters
479
+ * @param options A JSON-serialized list of answer options, 2-10 strings 1-100 characters each
480
+ */
481
+ sendQuiz(
482
+ chatId: number | string,
483
+ question: string,
484
+ options: readonly string[],
485
+ extra?: tt.ExtraPoll
486
+ ) {
487
+ return this.callApi('sendPoll', {
488
+ chat_id: chatId,
489
+ type: 'quiz',
490
+ question,
491
+ options,
492
+ ...extra,
493
+ })
494
+ }
495
+
496
+ /**
497
+ * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
498
+ * @param messageId Identifier of the original message with the poll
499
+ */
500
+ stopPoll(
501
+ chatId: number | string,
502
+ messageId: number,
503
+ extra?: tt.ExtraStopPoll
504
+ ) {
505
+ return this.callApi('stopPoll', {
506
+ chat_id: chatId,
507
+ message_id: messageId,
508
+ ...extra,
509
+ })
510
+ }
511
+
512
+ /**
513
+ * 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.).
514
+ * @param chatId Unique identifier for the target chat or username of the target supergroup or channel (in the format @channelusername)
515
+ */
516
+ getChat(chatId: number | string) {
517
+ return this.callApi('getChat', { chat_id: chatId })
518
+ }
519
+
520
+ /**
521
+ * @param chatId Unique identifier for the target chat or username of the target supergroup or channel (in the format @channelusername)
522
+ */
523
+ getChatAdministrators(chatId: number | string) {
524
+ return this.callApi('getChatAdministrators', { chat_id: chatId })
525
+ }
526
+
527
+ /**
528
+ * Get information about a member of a chat.
529
+ * @param chatId Unique identifier for the target chat or username of the target supergroup or channel (in the format @channelusername)
530
+ * @param userId Unique identifier of the target user
531
+ */
532
+ getChatMember(chatId: string | number, userId: number) {
533
+ return this.callApi('getChatMember', { chat_id: chatId, user_id: userId })
534
+ }
535
+
536
+ /**
537
+ * Get the number of members in a chat.
538
+ * @param chatId Unique identifier for the target chat or username of the target supergroup or channel (in the format @channelusername)
539
+ */
540
+ getChatMembersCount(chatId: string | number) {
541
+ return this.callApi('getChatMembersCount', { chat_id: chatId })
542
+ }
543
+
544
+ /**
545
+ * Send answers to an inline query.
546
+ * No more than 50 results per query are allowed.
547
+ */
548
+ answerInlineQuery(
549
+ inlineQueryId: string,
550
+ results: readonly tg.InlineQueryResult[],
551
+ extra?: tt.ExtraAnswerInlineQuery
552
+ ) {
553
+ return this.callApi('answerInlineQuery', {
554
+ inline_query_id: inlineQueryId,
555
+ results,
556
+ ...extra,
557
+ })
558
+ }
559
+
560
+ setChatPermissions(
561
+ chatId: number | string,
562
+ permissions: tg.ChatPermissions,
563
+ extra?: tt.ExtraSetChatPermissions
564
+ ) {
565
+ return this.callApi('setChatPermissions', {
566
+ chat_id: chatId,
567
+ permissions,
568
+ ...extra,
569
+ })
570
+ }
571
+
572
+ /**
573
+ * Kick a user from a group, a supergroup or a channel. In the case of supergroups and channels, the user will not be able to return to the group 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 admin rights.
574
+ * @param chatId Unique identifier for the target group or username of the target supergroup or channel (in the format `@channelusername`)
575
+ * @param untilDate Date when the user will be unbanned, unix time. If user is banned for more than 366 days or less than 30 seconds from the current time they are considered to be banned forever
576
+ */
577
+ banChatMember(
578
+ chatId: number | string,
579
+ userId: number,
580
+ untilDate?: number,
581
+ extra?: tt.ExtraBanChatMember
582
+ ) {
583
+ return this.callApi('banChatMember', {
584
+ chat_id: chatId,
585
+ user_id: userId,
586
+ until_date: untilDate,
587
+ ...extra,
588
+ })
589
+ }
590
+
591
+ /**
592
+ * Kick a user from a group, a supergroup or a channel. In the case of supergroups and channels, the user will not be able to return to the group 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 admin rights.
593
+ * @param chatId Unique identifier for the target group or username of the target supergroup or channel (in the format `@channelusername`)
594
+ * @param untilDate Date when the user will be unbanned, unix time. If user is banned for more than 366 days or less than 30 seconds from the current time they are considered to be banned forever
595
+ * @deprecated since API 5.3. Use {@link Telegram.banChatMember}
596
+ */
597
+ get kickChatMember() {
598
+ return this.banChatMember
599
+ }
600
+
601
+ /**
602
+ * 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 admin rights. Pass False for all boolean parameters to demote a user.
603
+ * @param chatId Unique identifier for the target chat or username of the target channel (in the format `@channelusername`)
604
+ */
605
+ promoteChatMember(
606
+ chatId: number | string,
607
+ userId: number,
608
+ extra: tt.ExtraPromoteChatMember
609
+ ) {
610
+ return this.callApi('promoteChatMember', {
611
+ chat_id: chatId,
612
+ user_id: userId,
613
+ ...extra,
614
+ })
615
+ }
616
+
617
+ /**
618
+ * Restrict a user in a supergroup. The bot must be an administrator in the supergroup for this to work and must have the appropriate admin rights. Pass True for all boolean parameters to lift restrictions from a user.
619
+ * @param chatId Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername)
620
+ */
621
+ restrictChatMember(
622
+ chatId: string | number,
623
+ userId: number,
624
+ extra: tt.ExtraRestrictChatMember
625
+ ) {
626
+ return this.callApi('restrictChatMember', {
627
+ chat_id: chatId,
628
+ user_id: userId,
629
+ ...extra,
630
+ })
631
+ }
632
+
633
+ setChatAdministratorCustomTitle(
634
+ chatId: number | string,
635
+ userId: number,
636
+ title: string
637
+ ) {
638
+ return this.callApi('setChatAdministratorCustomTitle', {
639
+ chat_id: chatId,
640
+ user_id: userId,
641
+ custom_title: title,
642
+ })
643
+ }
644
+
645
+ /**
646
+ * Export an invite link to a supergroup or a channel. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights.
647
+ * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
648
+ */
649
+ exportChatInviteLink(chatId: number | string) {
650
+ return this.callApi('exportChatInviteLink', { chat_id: chatId })
651
+ }
652
+
653
+ createChatInviteLink(
654
+ chatId: number | string,
655
+ extra?: tt.ExtraCreateChatInviteLink
656
+ ) {
657
+ return this.callApi('createChatInviteLink', {
658
+ chat_id: chatId,
659
+ ...extra,
660
+ })
661
+ }
662
+
663
+ createInvoiceLink(invoice: tt.NewInvoiceLinkParameters) {
664
+ return this.callApi('createInvoiceLink', {
665
+ ...invoice,
666
+ })
667
+ }
668
+
669
+ editChatInviteLink(
670
+ chatId: number | string,
671
+ inviteLink: string,
672
+ extra?: tt.ExtraEditChatInviteLink
673
+ ) {
674
+ return this.callApi('editChatInviteLink', {
675
+ chat_id: chatId,
676
+ invite_link: inviteLink,
677
+ ...extra,
678
+ })
679
+ }
680
+
681
+ revokeChatInviteLink(chatId: number | string, inviteLink: string) {
682
+ return this.callApi('revokeChatInviteLink', {
683
+ chat_id: chatId,
684
+ invite_link: inviteLink,
685
+ })
686
+ }
687
+
688
+ setChatPhoto(
689
+ chatId: number | string,
690
+ photo: tg.Opts<'setChatPhoto'>['photo']
691
+ ) {
692
+ return this.callApi('setChatPhoto', { chat_id: chatId, photo })
693
+ }
694
+
695
+ deleteChatPhoto(chatId: number | string) {
696
+ return this.callApi('deleteChatPhoto', { chat_id: chatId })
697
+ }
698
+
699
+ /**
700
+ * 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 admin rights.
701
+ * @param chatId Unique identifier for the target group or username of the target supergroup or channel (in the format `@channelusername`)
702
+ * @param title New chat title, 1-255 characters
703
+ */
704
+ setChatTitle(chatId: number | string, title: string) {
705
+ return this.callApi('setChatTitle', { chat_id: chatId, title })
706
+ }
707
+
708
+ setChatDescription(chatId: number | string, description?: string) {
709
+ return this.callApi('setChatDescription', { chat_id: chatId, description })
710
+ }
711
+
712
+ /**
713
+ * Pin a message in a group, a supergroup, or a channel. The bot must be an administrator in the chat for this to work and must have the 'can_pin_messages' admin right in the supergroup or 'can_edit_messages' admin right in the channel.
714
+ * @param chatId Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername)
715
+ */
716
+ pinChatMessage(
717
+ chatId: number | string,
718
+ messageId: number,
719
+ extra?: { disable_notification?: boolean }
720
+ ) {
721
+ return this.callApi('pinChatMessage', {
722
+ chat_id: chatId,
723
+ message_id: messageId,
724
+ ...extra,
725
+ })
726
+ }
727
+
728
+ /**
729
+ * Unpin a message in a group, a supergroup, or a channel. The bot must be an administrator in the chat for this to work and must have the 'can_pin_messages' admin right in the supergroup or 'can_edit_messages' admin right in the channel.
730
+ * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
731
+ */
732
+ unpinChatMessage(chatId: number | string, messageId?: number) {
733
+ return this.callApi('unpinChatMessage', {
734
+ chat_id: chatId,
735
+ message_id: messageId,
736
+ })
737
+ }
738
+
739
+ /**
740
+ * Clear the list of pinned messages in a chat.
741
+ * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
742
+ */
743
+ unpinAllChatMessages(chatId: number | string) {
744
+ return this.callApi('unpinAllChatMessages', { chat_id: chatId })
745
+ }
746
+
747
+ /**
748
+ * Use this method for your bot to leave a group, supergroup or channel.
749
+ * @param chatId Unique identifier for the target chat or username of the target supergroup or channel (in the format @channelusername)
750
+ */
751
+ leaveChat(chatId: number | string) {
752
+ return this.callApi('leaveChat', { chat_id: chatId })
753
+ }
754
+
755
+ /**
756
+ * Unban a user from a supergroup or a channel. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights.
757
+ * @param chatId Unique identifier for the target group or username of the target supergroup or channel (in the format @username)
758
+ * @param userId Unique identifier of the target user
759
+ */
760
+ unbanChatMember(
761
+ chatId: number | string,
762
+ userId: number,
763
+ extra?: { only_if_banned?: boolean }
764
+ ) {
765
+ return this.callApi('unbanChatMember', {
766
+ chat_id: chatId,
767
+ user_id: userId,
768
+ ...extra,
769
+ })
770
+ }
771
+
772
+ answerCbQuery(
773
+ callbackQueryId: string,
774
+ text?: string,
775
+ extra?: tt.ExtraAnswerCbQuery
776
+ ) {
777
+ return this.callApi('answerCallbackQuery', {
778
+ text,
779
+ callback_query_id: callbackQueryId,
780
+ ...extra,
781
+ })
782
+ }
783
+
784
+ answerGameQuery(callbackQueryId: string, url: string) {
785
+ return this.callApi('answerCallbackQuery', {
786
+ url,
787
+ callback_query_id: callbackQueryId,
788
+ })
789
+ }
790
+
791
+ /**
792
+ * 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.
793
+ * @param chat_id Unique identifier for the chat or username of the channel (in the format `@channelusername`)
794
+ * @param user_id Unique identifier of the target user
795
+ */
796
+ getUserChatBoosts(chat_id: number | string, user_id: number) {
797
+ return this.callApi('getUserChatBoosts', {
798
+ chat_id,
799
+ user_id,
800
+ })
801
+ }
802
+
803
+ /**
804
+ * If you sent an invoice requesting a shipping address and the parameter is_flexible was specified,
805
+ * the Bot API will send an Update with a shipping_query field to the bot.
806
+ * Reply to shipping queries.
807
+ * @param ok Specify 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)
808
+ * @param shippingOptions Required if ok is True. A JSON-serialized array of available shipping options.
809
+ * @param errorMessage Required if ok is False. Error message in human readable form that explains why it is impossible to complete the order (e.g. "Sorry, delivery to your desired address is unavailable'). Telegram will display this message to the user.
810
+ */
811
+ answerShippingQuery(
812
+ shippingQueryId: string,
813
+ ok: boolean,
814
+ shippingOptions: readonly tg.ShippingOption[] | undefined,
815
+ errorMessage: string | undefined
816
+ ) {
817
+ return this.callApi('answerShippingQuery', {
818
+ ok,
819
+ shipping_query_id: shippingQueryId,
820
+ shipping_options: shippingOptions,
821
+ error_message: errorMessage,
822
+ })
823
+ }
824
+
825
+ /**
826
+ * 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.
827
+ * Respond to such pre-checkout queries. On success, True is returned.
828
+ * Note: The Bot API must receive an answer within 10 seconds after the pre-checkout query was sent.
829
+ * @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.
830
+ * @param errorMessage Required if ok is False. Error message in human readable form that explains the reason for failure to proceed with the checkout (e.g. "Sorry, somebody just bought the last of our amazing black T-shirts while you were busy filling out your payment details. Please choose a different color or garment!"). Telegram will display this message to the user.
831
+ */
832
+ answerPreCheckoutQuery(
833
+ preCheckoutQueryId: string,
834
+ ok: boolean,
835
+ errorMessage?: string
836
+ ) {
837
+ return this.callApi('answerPreCheckoutQuery', {
838
+ ok,
839
+ pre_checkout_query_id: preCheckoutQueryId,
840
+ error_message: errorMessage,
841
+ })
842
+ }
843
+
844
+ answerWebAppQuery(webAppQueryId: string, result: tg.InlineQueryResult) {
845
+ return this.callApi('answerWebAppQuery', {
846
+ web_app_query_id: webAppQueryId,
847
+ result,
848
+ })
849
+ }
850
+
851
+ /**
852
+ * Edit text and game messages sent by the bot or via the bot (for inline bots).
853
+ * On success, if edited message is sent by the bot, the edited Message is returned, otherwise True is returned.
854
+ * @param chatId Required if inlineMessageId is not specified. Unique identifier for the target chat or username of the target channel (in the format @channelusername)
855
+ * @param messageId Required if inlineMessageId is not specified. Identifier of the sent message
856
+ * @param inlineMessageId Required if chatId and messageId are not specified. Identifier of the inline message
857
+ * @param text New text of the message
858
+ */
859
+ editMessageText(
860
+ chatId: number | string | undefined,
861
+ messageId: number | undefined,
862
+ inlineMessageId: string | undefined,
863
+ text: string | FmtString,
864
+ extra?: tt.ExtraEditMessageText
865
+ ) {
866
+ const t = FmtString.normalise(text)
867
+ return this.callApi('editMessageText', {
868
+ chat_id: chatId,
869
+ message_id: messageId,
870
+ inline_message_id: inlineMessageId,
871
+ ...extra,
872
+ ...t,
873
+ })
874
+ }
875
+
876
+ /**
877
+ * Edit captions of messages sent by the bot or via the bot (for inline bots).
878
+ * On success, if edited message is sent by the bot, the edited Message is returned, otherwise True is returned.
879
+ * @param chatId Required if inlineMessageId is not specified. Unique identifier for the target chat or username of the target channel (in the format @channelusername)
880
+ * @param messageId Required if inlineMessageId is not specified. Identifier of the sent message
881
+ * @param inlineMessageId Required if chatId and messageId are not specified. Identifier of the inline message
882
+ * @param caption New caption of the message
883
+ * @param markup A JSON-serialized object for an inline keyboard.
884
+ */
885
+ editMessageCaption(
886
+ chatId: number | string | undefined,
887
+ messageId: number | undefined,
888
+ inlineMessageId: string | undefined,
889
+ caption: string | FmtString | undefined,
890
+ extra?: tt.ExtraEditMessageCaption
891
+ ) {
892
+ return this.callApi('editMessageCaption', {
893
+ chat_id: chatId,
894
+ message_id: messageId,
895
+ inline_message_id: inlineMessageId,
896
+ ...extra,
897
+ ...fmtCaption({ caption }),
898
+ })
899
+ }
900
+
901
+ /**
902
+ * Edit animation, audio, document, photo, or video messages.
903
+ * If a message is a part of a message album, then it can be edited only to a photo or a video.
904
+ * Otherwise, message type can be changed arbitrarily.
905
+ * When inline message is edited, new file can't be uploaded.
906
+ * Use previously uploaded file via its file_id or specify a URL.
907
+ * @param chatId Required if inlineMessageId is not specified. Unique identifier for the target chat or username of the target channel (in the format @channelusername)
908
+ * @param messageId Required if inlineMessageId is not specified. Identifier of the sent message
909
+ * @param inlineMessageId Required if chatId and messageId are not specified. Identifier of the inline message
910
+ * @param media New media of message
911
+ * @param extra Additional parameters, such as reply_markup
912
+ */
913
+ editMessageMedia(
914
+ chatId: number | string | undefined,
915
+ messageId: number | undefined,
916
+ inlineMessageId: string | undefined,
917
+ media: tt.WrapCaption<tg.InputMedia>,
918
+ extra?: tt.ExtraEditMessageMedia
919
+ ) {
920
+ return this.callApi('editMessageMedia', {
921
+ chat_id: chatId,
922
+ message_id: messageId,
923
+ inline_message_id: inlineMessageId,
924
+ media: fmtCaption(media),
925
+ ...extra,
926
+ })
927
+ }
928
+
929
+ /**
930
+ * Edit only the reply markup of messages sent by the bot or via the bot (for inline bots).
931
+ * @param chatId Required if inlineMessageId is not specified. Unique identifier for the target chat or username of the target channel (in the format @channelusername)
932
+ * @param messageId Required if inlineMessageId is not specified. Identifier of the sent message
933
+ * @param inlineMessageId Required if chatId and messageId are not specified. Identifier of the inline message
934
+ * @param markup A JSON-serialized object for an inline keyboard.
935
+ * @returns If edited message is sent by the bot, the edited Message is returned, otherwise True is returned.
936
+ */
937
+ editMessageReplyMarkup(
938
+ chatId: number | string | undefined,
939
+ messageId: number | undefined,
940
+ inlineMessageId: string | undefined,
941
+ markup: tg.InlineKeyboardMarkup | undefined
942
+ ) {
943
+ return this.callApi('editMessageReplyMarkup', {
944
+ chat_id: chatId,
945
+ message_id: messageId,
946
+ inline_message_id: inlineMessageId,
947
+ reply_markup: markup,
948
+ })
949
+ }
950
+
951
+ editMessageLiveLocation(
952
+ chatId: number | string | undefined,
953
+ messageId: number | undefined,
954
+ inlineMessageId: string | undefined,
955
+ latitude: number,
956
+ longitude: number,
957
+ extra?: tt.ExtraEditMessageLiveLocation
958
+ ) {
959
+ return this.callApi('editMessageLiveLocation', {
960
+ latitude,
961
+ longitude,
962
+ chat_id: chatId,
963
+ message_id: messageId,
964
+ inline_message_id: inlineMessageId,
965
+ ...extra,
966
+ })
967
+ }
968
+
969
+ stopMessageLiveLocation(
970
+ chatId: number | string | undefined,
971
+ messageId: number | undefined,
972
+ inlineMessageId: string | undefined,
973
+ markup?: tg.InlineKeyboardMarkup
974
+ ) {
975
+ return this.callApi('stopMessageLiveLocation', {
976
+ chat_id: chatId,
977
+ message_id: messageId,
978
+ inline_message_id: inlineMessageId,
979
+ reply_markup: markup,
980
+ })
981
+ }
982
+
983
+ /**
984
+ * Delete a message, including service messages, with the following limitations:
985
+ * - A message can only be deleted if it was sent less than 48 hours ago.
986
+ * - Bots can delete outgoing messages in groups and supergroups.
987
+ * - Bots granted can_post_messages permissions can delete outgoing messages in channels.
988
+ * - If the bot is an administrator of a group, it can delete any message there.
989
+ * - If the bot has can_delete_messages permission in a supergroup or a channel, it can delete any message there.
990
+ * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
991
+ * @param messageId Identifier of the message to delete
992
+ */
993
+ deleteMessage(chatId: number | string, messageId: number) {
994
+ return this.callApi('deleteMessage', {
995
+ chat_id: chatId,
996
+ message_id: messageId,
997
+ })
998
+ }
999
+
1000
+ /**
1001
+ * Use this method to delete multiple messages simultaneously. If some of the specified messages can't be found, they are skipped.
1002
+ * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
1003
+ * @param messageIds Identifiers of 1-100 messages to delete. See deleteMessage for limitations on which messages can be deleted
1004
+ */
1005
+ deleteMessages(chatId: number | string, messageIds: number[]) {
1006
+ return this.callApi('deleteMessages', {
1007
+ chat_id: chatId,
1008
+ message_ids: messageIds,
1009
+ })
1010
+ }
1011
+
1012
+ setChatStickerSet(chatId: number | string, setName: string) {
1013
+ return this.callApi('setChatStickerSet', {
1014
+ chat_id: chatId,
1015
+ sticker_set_name: setName,
1016
+ })
1017
+ }
1018
+
1019
+ deleteChatStickerSet(chatId: number | string) {
1020
+ return this.callApi('deleteChatStickerSet', { chat_id: chatId })
1021
+ }
1022
+
1023
+ /**
1024
+ * Use this method to get custom emoji stickers, which can be used as a forum topic icon by any user.
1025
+ * Requires no parameters. Returns an Array of Sticker objects.
1026
+ *
1027
+ * @see https://core.telegram.org/bots/api#getforumtopiciconstickers
1028
+ */
1029
+ getForumTopicIconStickers() {
1030
+ return this.callApi('getForumTopicIconStickers', {})
1031
+ }
1032
+
1033
+ /**
1034
+ * Use this method to create a topic in a forum supergroup chat. The bot must be an administrator in the chat for this
1035
+ * to work and must have the can_manage_topics administrator rights. Returns information about the created topic as a
1036
+ * ForumTopic object.
1037
+ *
1038
+ * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
1039
+ * @param name Topic name, 1-128 characters
1040
+ *
1041
+ * @see https://core.telegram.org/bots/api#createforumtopic
1042
+ */
1043
+ createForumTopic(
1044
+ chat_id: number | string,
1045
+ name: string,
1046
+ extra?: tt.ExtraCreateForumTopic
1047
+ ) {
1048
+ return this.callApi('createForumTopic', {
1049
+ chat_id,
1050
+ name,
1051
+ ...extra,
1052
+ })
1053
+ }
1054
+
1055
+ /**
1056
+ * Use this method to edit name and icon of a topic in a forum supergroup chat. The bot must be an administrator in
1057
+ * the chat for this to work and must have can_manage_topics administrator rights, unless it is the creator of the
1058
+ * topic. Returns True on success.
1059
+ *
1060
+ * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
1061
+ * @param message_thread_id Unique identifier for the target message thread of the forum topic
1062
+ *
1063
+ * @see https://core.telegram.org/bots/api#editforumtopic
1064
+ */
1065
+ editForumTopic(
1066
+ chat_id: number | string,
1067
+ message_thread_id: number,
1068
+ extra: tt.ExtraEditForumTopic
1069
+ ) {
1070
+ return this.callApi('editForumTopic', {
1071
+ chat_id,
1072
+ message_thread_id,
1073
+ ...extra,
1074
+ })
1075
+ }
1076
+
1077
+ /**
1078
+ * Use this method to close an open topic in a forum supergroup chat. The bot must be an administrator in the chat
1079
+ * for this to work and must have the can_manage_topics administrator rights, unless it is the creator of the topic.
1080
+ * Returns True on success.
1081
+ *
1082
+ * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
1083
+ * @param message_thread_id Unique identifier for the target message thread of the forum topic
1084
+ *
1085
+ * @see https://core.telegram.org/bots/api#closeforumtopic
1086
+ */
1087
+ closeForumTopic(chat_id: number | string, message_thread_id: number) {
1088
+ return this.callApi('closeForumTopic', {
1089
+ chat_id,
1090
+ message_thread_id,
1091
+ })
1092
+ }
1093
+
1094
+ /**
1095
+ * Use this method to reopen a closed topic in a forum supergroup chat. The bot must be an administrator in the chat
1096
+ * for this to work and must have the can_manage_topics administrator rights, unless it is the creator of the topic.
1097
+ * Returns True on success.
1098
+ *
1099
+ * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
1100
+ * @param message_thread_id Unique identifier for the target message thread of the forum topic
1101
+ *
1102
+ * @see https://core.telegram.org/bots/api#reopenforumtopic
1103
+ */
1104
+ reopenForumTopic(chat_id: number | string, message_thread_id: number) {
1105
+ return this.callApi('reopenForumTopic', {
1106
+ chat_id,
1107
+ message_thread_id,
1108
+ })
1109
+ }
1110
+
1111
+ /**
1112
+ * Use this method to delete a forum topic along with all its messages in a forum supergroup chat. The bot must be an
1113
+ * administrator in the chat for this to work and must have the can_delete_messages administrator rights.
1114
+ * Returns True on success.
1115
+ *
1116
+ * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
1117
+ * @param message_thread_id Unique identifier for the target message thread of the forum topic
1118
+ *
1119
+ * @see https://core.telegram.org/bots/api#deleteforumtopic
1120
+ */
1121
+ deleteForumTopic(chat_id: number | string, message_thread_id: number) {
1122
+ return this.callApi('deleteForumTopic', {
1123
+ chat_id,
1124
+ message_thread_id,
1125
+ })
1126
+ }
1127
+
1128
+ /**
1129
+ * Use this method to clear the list of pinned messages in a forum topic. The bot must be an administrator in the chat
1130
+ * for this to work and must have the can_pin_messages administrator right in the supergroup. Returns True on success.
1131
+ *
1132
+ * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
1133
+ * @param message_thread_id Unique identifier for the target message thread of the forum topic
1134
+ *
1135
+ * @see https://core.telegram.org/bots/api#unpinallforumtopicmessages
1136
+ */
1137
+ unpinAllForumTopicMessages(
1138
+ chat_id: number | string,
1139
+ message_thread_id: number
1140
+ ) {
1141
+ return this.callApi('unpinAllForumTopicMessages', {
1142
+ chat_id,
1143
+ message_thread_id,
1144
+ })
1145
+ }
1146
+
1147
+ /**
1148
+ * Use this method to edit the name of the 'General' topic in a forum supergroup chat. The bot must be an administrator
1149
+ * in the chat for this to work and must have can_manage_topics administrator rights. Returns True on success.
1150
+ *
1151
+ * @param chat_id Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername)
1152
+ * @param name New topic name, 1-128 characters
1153
+ *
1154
+ * @see https://core.telegram.org/bots/api#editgeneralforumtopic
1155
+ */
1156
+ editGeneralForumTopic(chat_id: number | string, name: string) {
1157
+ return this.callApi('editGeneralForumTopic', { chat_id, name })
1158
+ }
1159
+
1160
+ /**
1161
+ * Use this method to close an open 'General' topic in a forum supergroup chat. The bot must be an administrator in the
1162
+ * chat for this to work and must have the can_manage_topics administrator rights. Returns True on success.
1163
+ *
1164
+ * @param chat_id Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername)
1165
+ *
1166
+ * @see https://core.telegram.org/bots/api#closegeneralforumtopic
1167
+ */
1168
+ closeGeneralForumTopic(chat_id: number | string) {
1169
+ return this.callApi('closeGeneralForumTopic', { chat_id })
1170
+ }
1171
+
1172
+ /**
1173
+ * Use this method to reopen a closed 'General' topic in a forum supergroup chat. The bot must be an administrator in
1174
+ * the chat for this to work and must have the can_manage_topics administrator rights. The topic will be automatically
1175
+ * unhidden if it was hidden. Returns True on success.
1176
+ *
1177
+ * @param chat_id Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername)
1178
+ *
1179
+ * @see https://core.telegram.org/bots/api#reopengeneralforumtopic
1180
+ */
1181
+ reopenGeneralForumTopic(chat_id: number | string) {
1182
+ return this.callApi('reopenGeneralForumTopic', { chat_id })
1183
+ }
1184
+
1185
+ /**
1186
+ * Use this method to hide the 'General' topic in a forum supergroup chat. The bot must be an administrator in the chat
1187
+ * for this to work and must have the can_manage_topics administrator rights. The topic will be automatically closed
1188
+ * if it was open. Returns True on success.
1189
+ *
1190
+ * @param chat_id Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername)
1191
+ *
1192
+ * @see https://core.telegram.org/bots/api#hidegeneralforumtopic
1193
+ */
1194
+ hideGeneralForumTopic(chat_id: number | string) {
1195
+ return this.callApi('hideGeneralForumTopic', { chat_id })
1196
+ }
1197
+
1198
+ /**
1199
+ * Use this method to unhide the 'General' topic in a forum supergroup chat. The bot must be an administrator in the
1200
+ * chat for this to work and must have the can_manage_topics administrator rights. Returns True on success.
1201
+ *
1202
+ * @param chat_id Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername)
1203
+ *
1204
+ * @see https://core.telegram.org/bots/api#unhidegeneralforumtopic
1205
+ */
1206
+ unhideGeneralForumTopic(chat_id: number | string) {
1207
+ return this.callApi('unhideGeneralForumTopic', { chat_id })
1208
+ }
1209
+
1210
+ /**
1211
+ * Use this method to clear the list of pinned messages in a General forum topic.
1212
+ * The bot must be an administrator in the chat for this to work and must have the can_pin_messages administrator
1213
+ * right in the supergroup.
1214
+ *
1215
+ * @param chat_id Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername)
1216
+ */
1217
+ unpinAllGeneralForumTopicMessages(chat_id: number | string) {
1218
+ return this.callApi('unpinAllGeneralForumTopicMessages', { chat_id })
1219
+ }
1220
+
1221
+ getStickerSet(name: string) {
1222
+ return this.callApi('getStickerSet', { name })
1223
+ }
1224
+
1225
+ /**
1226
+ * Upload a .png file with a sticker for later use in createNewStickerSet and addStickerToSet methods (can be used multiple times).
1227
+ * https://core.telegram.org/bots/api#sending-files
1228
+ * @param ownerId User identifier of sticker file owner
1229
+ * @param stickerFile Png image with the sticker, must be up to 512 kilobytes in size, dimensions must not exceed 512px, and either width or height must be exactly 512px.
1230
+ */
1231
+ uploadStickerFile(
1232
+ ownerId: number,
1233
+ sticker: tg.Opts<'uploadStickerFile'>['sticker'],
1234
+ sticker_format: tg.Opts<'uploadStickerFile'>['sticker_format']
1235
+ ) {
1236
+ return this.callApi('uploadStickerFile', {
1237
+ user_id: ownerId,
1238
+ sticker_format,
1239
+ sticker,
1240
+ })
1241
+ }
1242
+
1243
+ /**
1244
+ * Create new sticker set owned by a user. The bot will be able to edit the created sticker set.
1245
+ * @param ownerId User identifier of created sticker set owner
1246
+ * @param name Short name of sticker set, to be used in t.me/addstickers/ URLs (e.g., animals). Can contain only english letters, digits and underscores. Must begin with a letter, can't contain consecutive underscores and must end in “_by_<bot username>”. <bot_username> is case insensitive. 1-64 characters.
1247
+ * @param title Sticker set title, 1-64 characters
1248
+ */
1249
+ createNewStickerSet(
1250
+ ownerId: number,
1251
+ name: string,
1252
+ title: string,
1253
+ stickerData: tt.ExtraCreateNewStickerSet
1254
+ ) {
1255
+ return this.callApi('createNewStickerSet', {
1256
+ name,
1257
+ title,
1258
+ user_id: ownerId,
1259
+ ...stickerData,
1260
+ })
1261
+ }
1262
+
1263
+ /**
1264
+ * Add a new sticker to a set created by the bot.
1265
+ * @param ownerId User identifier of sticker set owner
1266
+ * @param name Sticker set name
1267
+ */
1268
+ addStickerToSet(
1269
+ ownerId: number,
1270
+ name: string,
1271
+ stickerData: tt.ExtraAddStickerToSet
1272
+ ) {
1273
+ return this.callApi('addStickerToSet', {
1274
+ name,
1275
+ user_id: ownerId,
1276
+ ...stickerData,
1277
+ })
1278
+ }
1279
+
1280
+ /**
1281
+ * Move a sticker in a set created by the bot to a specific position.
1282
+ * @param sticker File identifier of the sticker
1283
+ * @param position New sticker position in the set, zero-based
1284
+ */
1285
+ setStickerPositionInSet(sticker: string, position: number) {
1286
+ return this.callApi('setStickerPositionInSet', {
1287
+ sticker,
1288
+ position,
1289
+ })
1290
+ }
1291
+
1292
+ /**
1293
+ * @deprecated since API 6.8. Use {@link Telegram.setStickerSetThumbnail}
1294
+ */
1295
+ get setStickerSetThumb() {
1296
+ return this.setStickerSetThumbnail
1297
+ }
1298
+
1299
+ /**
1300
+ * Use this method to set the thumbnail of a regular or mask sticker set.
1301
+ * The format of the thumbnail file must match the format of the stickers in the set.
1302
+ * @param name Sticker set name
1303
+ * @param userId User identifier of the sticker set owner
1304
+ * @param thumbnail A .WEBP or .PNG image with the thumbnail, must be up to 128 kilobytes in size
1305
+ * and have a width and height of exactly 100px, or a .TGS animation with a thumbnail up to
1306
+ * 32 kilobytes in size (see
1307
+ * [animated sticker technical requirements](https://core.telegram.org/stickers#animated-sticker-requirements)),
1308
+ * or a WEBM video with the thumbnail up to 32 kilobytes in size; see
1309
+ * [video sticker technical requirements](https://core.telegram.org/stickers#video-sticker-requirements).
1310
+ * Pass a file_id as a String to send a file that already exists on the Telegram servers, pass a
1311
+ * HTTP URL as a String for Telegram to get a file from the Internet, or upload a new one using
1312
+ * Input helpers. Animated and video sticker set thumbnails can't be uploaded via HTTP URL.
1313
+ * If omitted, then the thumbnail is dropped and the first sticker is used as the thumbnail.
1314
+ */
1315
+ setStickerSetThumbnail(
1316
+ name: string,
1317
+ userId: number,
1318
+ thumbnail?: tg.Opts<'setStickerSetThumbnail'>['thumbnail']
1319
+ ) {
1320
+ return this.callApi('setStickerSetThumbnail', {
1321
+ name,
1322
+ user_id: userId,
1323
+ thumbnail,
1324
+ })
1325
+ }
1326
+
1327
+ setStickerMaskPosition(sticker: string, mask_position?: tg.MaskPosition) {
1328
+ return this.callApi('setStickerMaskPosition', { sticker, mask_position })
1329
+ }
1330
+
1331
+ setStickerKeywords(sticker: string, keywords?: string[]) {
1332
+ return this.callApi('setStickerKeywords', { sticker, keywords })
1333
+ }
1334
+
1335
+ setStickerEmojiList(sticker: string, emoji_list: string[]) {
1336
+ return this.callApi('setStickerEmojiList', { sticker, emoji_list })
1337
+ }
1338
+
1339
+ deleteStickerSet(name: string) {
1340
+ return this.callApi('deleteStickerSet', { name })
1341
+ }
1342
+
1343
+ setStickerSetTitle(name: string, title: string) {
1344
+ return this.callApi('setStickerSetTitle', { name, title })
1345
+ }
1346
+
1347
+ setCustomEmojiStickerSetThumbnail(name: string, custom_emoji_id: string) {
1348
+ return this.callApi('setCustomEmojiStickerSetThumbnail', {
1349
+ name,
1350
+ custom_emoji_id,
1351
+ })
1352
+ }
1353
+
1354
+ /**
1355
+ * Delete a sticker from a set created by the bot.
1356
+ * @param sticker File identifier of the sticker
1357
+ */
1358
+ deleteStickerFromSet(sticker: string) {
1359
+ return this.callApi('deleteStickerFromSet', { sticker })
1360
+ }
1361
+
1362
+ getCustomEmojiStickers(custom_emoji_ids: string[]) {
1363
+ return this.callApi('getCustomEmojiStickers', { custom_emoji_ids })
1364
+ }
1365
+
1366
+ /**
1367
+ * Change the list of the bot's commands.
1368
+ * @param commands A list of bot commands to be set as the list of the bot's commands. At most 100 commands can be specified.
1369
+ */
1370
+ setMyCommands(
1371
+ commands: readonly tg.BotCommand[],
1372
+ extra?: tt.ExtraSetMyCommands
1373
+ ) {
1374
+ return this.callApi('setMyCommands', { commands, ...extra })
1375
+ }
1376
+
1377
+ deleteMyCommands(extra: tg.Opts<'deleteMyCommands'> = {}) {
1378
+ return this.callApi('deleteMyCommands', extra)
1379
+ }
1380
+
1381
+ /**
1382
+ * Get the current list of the bot's commands.
1383
+ */
1384
+ getMyCommands(extra: tg.Opts<'getMyCommands'> = {}) {
1385
+ return this.callApi('getMyCommands', extra)
1386
+ }
1387
+
1388
+ /**
1389
+ * Use this method to change the bot's description, which is shown in the chat with the bot if the chat is empty.
1390
+ * @param description New bot description; 0-512 characters. Pass an empty string to remove the dedicated description for the given language.
1391
+ * @param language_code A two-letter ISO 639-1 language code. If empty, the description will be applied to all users for whose language there is no dedicated description.
1392
+ */
1393
+ setMyDescription(description: string, language_code?: string) {
1394
+ return this.callApi('setMyDescription', { description, language_code })
1395
+ }
1396
+
1397
+ /**
1398
+ * Use this method to change the bot's name.
1399
+ * @param name New bot name; 0-64 characters. Pass an empty string to remove the dedicated name for the given language.
1400
+ * @param language_code A two-letter ISO 639-1 language code. If empty, the name will be shown to all users for whose language there is no dedicated name.
1401
+ */
1402
+ setMyName(name: string, language_code?: string) {
1403
+ return this.callApi('setMyName', { name, language_code })
1404
+ }
1405
+
1406
+ /**
1407
+ * Use this method to get the current bot name for the given user language.
1408
+ * @param language_code A two-letter ISO 639-1 language code or an empty string
1409
+ */
1410
+ getMyName(language_code?: string) {
1411
+ return this.callApi('getMyName', { language_code })
1412
+ }
1413
+
1414
+ /**
1415
+ * Use this method to get the current bot description for the given user language.
1416
+ * @param language_code A two-letter ISO 639-1 language code.
1417
+ */
1418
+ getMyDescription(language_code?: string) {
1419
+ return this.callApi('getMyDescription', { language_code })
1420
+ }
1421
+
1422
+ /**
1423
+ * Use this method to change the bot's short description, which is shown on the bot's profile page and is sent together with the link when users share the bot.
1424
+ * @param description New short description for the bot; 0-120 characters. Pass an empty string to remove the dedicated short description for the given language.
1425
+ * @param language_code A two-letter ISO 639-1 language code. If empty, the short description will be applied to all users for whose language there is no dedicated short description.
1426
+ */
1427
+ setMyShortDescription(short_description: string, language_code?: string) {
1428
+ return this.callApi('setMyShortDescription', {
1429
+ short_description,
1430
+ language_code,
1431
+ })
1432
+ }
1433
+
1434
+ /**
1435
+ * Use this method to get the current bot short description for the given user language.
1436
+ * @param language_code A two-letter ISO 639-1 language code or an empty string
1437
+ */
1438
+ getMyShortDescription(language_code?: string) {
1439
+ return this.callApi('getMyShortDescription', { language_code })
1440
+ }
1441
+
1442
+ setPassportDataErrors(
1443
+ userId: number,
1444
+ errors: readonly tg.PassportElementError[]
1445
+ ) {
1446
+ return this.callApi('setPassportDataErrors', {
1447
+ user_id: userId,
1448
+ errors: errors,
1449
+ })
1450
+ }
1451
+
1452
+ /**
1453
+ * Send copy of existing message.
1454
+ * @deprecated use `copyMessage` instead
1455
+ * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
1456
+ * @param message Received message object
1457
+ */
1458
+ sendCopy(
1459
+ chatId: number | string,
1460
+ message: tg.Message,
1461
+ extra?: tt.ExtraCopyMessage
1462
+ ): Promise<tg.MessageId> {
1463
+ return this.copyMessage(chatId, message.chat.id, message.message_id, extra)
1464
+ }
1465
+
1466
+ /**
1467
+ * Send copy of existing message.
1468
+ * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
1469
+ * @param fromChatId Unique identifier for the chat where the original message was sent (or channel username in the format @channelusername)
1470
+ * @param messageId Message identifier in the chat specified in from_chat_id
1471
+ */
1472
+ copyMessage(
1473
+ chatId: number | string,
1474
+ fromChatId: number | string,
1475
+ messageId: number,
1476
+ extra?: tt.ExtraCopyMessage
1477
+ ) {
1478
+ return this.callApi('copyMessage', {
1479
+ chat_id: chatId,
1480
+ from_chat_id: fromChatId,
1481
+ message_id: messageId,
1482
+ ...fmtCaption(extra),
1483
+ })
1484
+ }
1485
+
1486
+ /**
1487
+ * 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, 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.
1488
+ * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
1489
+ * @param fromChatId Unique identifier for the chat where the original messages were sent (or channel username in the format @channelusername)
1490
+ * @param messageIds Identifiers of 1-100 messages in the chat from_chat_id to copy. The identifiers must be specified in a strictly increasing order.
1491
+ */
1492
+ copyMessages(
1493
+ chatId: number | string,
1494
+ fromChatId: number | string,
1495
+ messageIds: number[],
1496
+ extra?: tt.ExtraCopyMessages
1497
+ ) {
1498
+ return this.callApi('copyMessages', {
1499
+ chat_id: chatId,
1500
+ from_chat_id: fromChatId,
1501
+ message_ids: messageIds,
1502
+ ...extra,
1503
+ })
1504
+ }
1505
+
1506
+ /**
1507
+ * Approve a chat join request.
1508
+ * The bot must be an administrator in the chat for this to work and must have the can_invite_users administrator right.
1509
+ * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
1510
+ * @param userId Unique identifier of the target user
1511
+ */
1512
+ approveChatJoinRequest(chatId: number | string, userId: number) {
1513
+ return this.callApi('approveChatJoinRequest', {
1514
+ chat_id: chatId,
1515
+ user_id: userId,
1516
+ })
1517
+ }
1518
+
1519
+ /**
1520
+ * Decline a chat join request.
1521
+ * The bot must be an administrator in the chat for this to work and must have the can_invite_users administrator right.
1522
+ * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
1523
+ * @param userId Unique identifier of the target user
1524
+ */
1525
+ declineChatJoinRequest(chatId: number | string, userId: number) {
1526
+ return this.callApi('declineChatJoinRequest', {
1527
+ chat_id: chatId,
1528
+ user_id: userId,
1529
+ })
1530
+ }
1531
+
1532
+ /**
1533
+ * Ban a channel chat in a supergroup or a channel. The owner of the chat will not be able to send messages and join live streams on behalf of the chat, unless it is unbanned first.
1534
+ * The bot must be an administrator in the supergroup or channel for this to work and must have the appropriate administrator rights.
1535
+ * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
1536
+ * @param senderChatId Unique identifier of the target sender chat
1537
+ */
1538
+ banChatSenderChat(
1539
+ chatId: number | string,
1540
+ senderChatId: number,
1541
+ extra?: tt.ExtraBanChatSenderChat
1542
+ ) {
1543
+ return this.callApi('banChatSenderChat', {
1544
+ chat_id: chatId,
1545
+ sender_chat_id: senderChatId,
1546
+ ...extra,
1547
+ })
1548
+ }
1549
+
1550
+ /**
1551
+ * Unban a previously banned channel chat in a supergroup or channel.
1552
+ * The bot must be an administrator for this to work and must have the appropriate administrator rights.
1553
+ * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
1554
+ * @param senderChatId Unique identifier of the target sender chat
1555
+ */
1556
+ unbanChatSenderChat(chatId: number | string, senderChatId: number) {
1557
+ return this.callApi('unbanChatSenderChat', {
1558
+ chat_id: chatId,
1559
+ sender_chat_id: senderChatId,
1560
+ })
1561
+ }
1562
+
1563
+ /**
1564
+ * Use this method to change the bot's menu button in a private chat, or the default menu button. Returns true on success.
1565
+ * @param chatId Unique identifier for the target private chat. If not specified, default bot's menu button will be changed.
1566
+ * @param menuButton An object for the bot's new menu button.
1567
+ */
1568
+ setChatMenuButton({
1569
+ chatId,
1570
+ menuButton,
1571
+ }: {
1572
+ chatId?: number | undefined
1573
+ menuButton?: tg.MenuButton | undefined
1574
+ } = {}) {
1575
+ return this.callApi('setChatMenuButton', {
1576
+ chat_id: chatId,
1577
+ menu_button: menuButton,
1578
+ })
1579
+ }
1580
+
1581
+ /**
1582
+ * 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.
1583
+ * @param chatId Unique identifier for the target private chat. If not specified, default bot's menu button will be returned.
1584
+ */
1585
+ getChatMenuButton({ chatId }: { chatId?: number } = {}) {
1586
+ return this.callApi('getChatMenuButton', {
1587
+ chat_id: chatId,
1588
+ })
1589
+ }
1590
+
1591
+ /**
1592
+ * Use this method to change the default administrator rights requested by the bot when it's added as an administrator to groups or channels.
1593
+ * These rights will be suggested to users, but they are are free to modify the list before adding the bot.
1594
+ */
1595
+ setMyDefaultAdministratorRights({
1596
+ rights,
1597
+ forChannels,
1598
+ }: {
1599
+ rights?: tg.ChatAdministratorRights
1600
+ forChannels?: boolean
1601
+ } = {}) {
1602
+ return this.callApi('setMyDefaultAdministratorRights', {
1603
+ rights,
1604
+ for_channels: forChannels,
1605
+ })
1606
+ }
1607
+
1608
+ /**
1609
+ * Use this method to get the current default administrator rights of the bot. Returns ChatAdministratorRights on success.
1610
+ * @param forChannels Pass true to get default administrator rights of the bot in channels. Otherwise, default administrator rights of the bot for groups and supergroups will be returned.
1611
+ */
1612
+ getMyDefaultAdministratorRights({
1613
+ forChannels,
1614
+ }: { forChannels?: boolean } = {}) {
1615
+ return this.callApi('getMyDefaultAdministratorRights', {
1616
+ for_channels: forChannels,
1617
+ })
1618
+ }
1619
+
1620
+ /**
1621
+ * Log out from the cloud Bot API server before launching the bot locally.
1622
+ */
1623
+ logOut() {
1624
+ return this.callApi('logOut', {})
1625
+ }
1626
+
1627
+ /**
1628
+ * Close the bot instance before moving it from one local server to another.
1629
+ */
1630
+ close() {
1631
+ return this.callApi('close', {})
1632
+ }
1633
+ }
1634
+
1635
+ export default Telegram