@grom.js/effect-tg 0.6.0 → 0.8.0

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 (58) hide show
  1. package/dist/BotApi.d.ts +3 -15
  2. package/dist/BotApi.d.ts.map +1 -1
  3. package/dist/BotApi.js +0 -9
  4. package/dist/BotApi.js.map +1 -1
  5. package/dist/BotApiError.d.ts +91 -0
  6. package/dist/BotApiError.d.ts.map +1 -0
  7. package/dist/BotApiError.js +53 -0
  8. package/dist/BotApiError.js.map +1 -0
  9. package/dist/File.d.ts +14 -6
  10. package/dist/File.d.ts.map +1 -1
  11. package/dist/File.js +5 -15
  12. package/dist/File.js.map +1 -1
  13. package/dist/Runner.d.ts +1 -1
  14. package/dist/Runner.d.ts.map +1 -1
  15. package/dist/Send.d.ts +3 -2
  16. package/dist/Send.d.ts.map +1 -1
  17. package/dist/Send.js.map +1 -1
  18. package/dist/index.d.ts +1 -0
  19. package/dist/index.d.ts.map +1 -1
  20. package/dist/index.js +1 -0
  21. package/dist/index.js.map +1 -1
  22. package/dist/internal/botApi.d.ts +1 -1
  23. package/dist/internal/botApi.d.ts.map +1 -1
  24. package/dist/internal/botApi.js +2 -2
  25. package/dist/internal/botApi.js.map +1 -1
  26. package/dist/internal/botApiError.d.ts +3 -0
  27. package/dist/internal/botApiError.d.ts.map +1 -0
  28. package/dist/internal/botApiError.js +34 -0
  29. package/dist/internal/botApiError.js.map +1 -0
  30. package/dist/internal/botApiMethods.gen.d.ts +112 -28
  31. package/dist/internal/botApiMethods.gen.d.ts.map +1 -1
  32. package/dist/internal/botApiShape.gen.d.ts +11 -3
  33. package/dist/internal/botApiShape.gen.d.ts.map +1 -1
  34. package/dist/internal/botApiTypes.gen.d.ts +94 -11
  35. package/dist/internal/botApiTypes.gen.d.ts.map +1 -1
  36. package/dist/internal/file.d.ts +7 -0
  37. package/dist/internal/file.d.ts.map +1 -0
  38. package/dist/internal/file.js +13 -0
  39. package/dist/internal/file.js.map +1 -0
  40. package/dist/internal/runner.d.ts +1 -1
  41. package/dist/internal/runner.d.ts.map +1 -1
  42. package/dist/internal/runner.js +1 -1
  43. package/dist/internal/runner.js.map +1 -1
  44. package/dist/internal/send.d.ts +1 -1
  45. package/dist/internal/send.d.ts.map +1 -1
  46. package/package.json +5 -5
  47. package/src/BotApi.ts +3 -16
  48. package/src/BotApiError.ts +81 -0
  49. package/src/File.ts +17 -27
  50. package/src/Send.ts +3 -2
  51. package/src/index.ts +1 -0
  52. package/src/internal/botApi.ts +3 -2
  53. package/src/internal/botApiError.ts +36 -0
  54. package/src/internal/botApiMethods.gen.ts +112 -28
  55. package/src/internal/botApiShape.gen.ts +11 -3
  56. package/src/internal/botApiTypes.gen.ts +97 -11
  57. package/src/internal/file.ts +16 -0
  58. package/src/internal/runner.ts +2 -2
package/src/File.ts CHANGED
@@ -1,10 +1,15 @@
1
+ import type * as HttpClient from '@effect/platform/HttpClient'
2
+ import type * as HttpClientError from '@effect/platform/HttpClientError'
3
+ import type * as HttpClientResponse from '@effect/platform/HttpClientResponse'
4
+ import type * as Effect from 'effect/Effect'
1
5
  import type * as Stream from 'effect/Stream'
2
- import * as HttpClient from '@effect/platform/HttpClient'
6
+ import type * as BotApi from './BotApi.ts'
7
+ import type * as BotApiError from './BotApiError.ts'
8
+ import type * as BotApiTransport from './BotApiTransport.ts'
9
+ import type * as BotApiUrl from './BotApiUrl.ts'
3
10
  import * as Brand from 'effect/Brand'
4
11
  import * as Data from 'effect/Data'
5
- import * as Effect from 'effect/Effect'
6
- import * as BotApi from './BotApi.ts'
7
- import * as BotApiUrl from './BotApiUrl.ts'
12
+ import * as internal from './internal/file.ts'
8
13
 
9
14
  export type FileId = string & Brand.Brand<'FileId'>
10
15
  export const FileId = Brand.nominal<FileId>()
@@ -19,27 +24,12 @@ export class InputFile extends Data.TaggedClass('InputFile')<{
19
24
  }> {}
20
25
 
21
26
  /**
22
- * @internal
27
+ * Downloads a file from the Bot API server.
28
+ *
29
+ * @see {@link https://core.telegram.org/bots/api#getfile Bot API • getFile}
23
30
  */
24
- const downloadRequest = Effect.fnUntraced(
25
- function* (fileId: FileId) {
26
- const file = yield* BotApi.callMethod('getFile', { file_id: fileId })
27
- if (file.file_path == null) {
28
- return yield* Effect.die(new Error(`Bot API returned no file path for file "${fileId}".`))
29
- }
30
- const url = yield* BotApiUrl.BotApiUrl
31
- return yield* HttpClient.get(url.toFile(file.file_path))
32
- },
33
- )
34
-
35
- export const download = (fileId: FileId) => (
36
- downloadRequest(fileId).pipe(
37
- Effect.flatMap(request => request.arrayBuffer),
38
- )
39
- )
40
-
41
- export const downloadStream = (fileId: FileId) => (
42
- downloadRequest(fileId).pipe(
43
- Effect.andThen(request => request.stream),
44
- )
45
- )
31
+ export const get: (fileId: FileId) => Effect.Effect<
32
+ HttpClientResponse.HttpClientResponse,
33
+ BotApiError.BotApiError | BotApiTransport.BotApiTransportError | HttpClientError.HttpClientError,
34
+ BotApi.BotApi | BotApiUrl.BotApiUrl | HttpClient.HttpClient
35
+ > = internal.get
package/src/Send.ts CHANGED
@@ -3,6 +3,7 @@
3
3
  */
4
4
 
5
5
  import type * as BotApi from './BotApi.ts'
6
+ import type * as BotApiError from './BotApiError.ts'
6
7
  import type * as BotApiTransport from './BotApiTransport.ts'
7
8
  import type * as Content from './Content.ts'
8
9
  import type * as Dialog_ from './Dialog.ts'
@@ -73,7 +74,7 @@ export const sendMessage: (params: {
73
74
  markup?: Markup.Markup
74
75
  }) => Effect.Effect<
75
76
  BotApi.Types.Message,
76
- BotApi.BotApiError | BotApiTransport.BotApiTransportError,
77
+ BotApiError.BotApiError | BotApiTransport.BotApiTransportError,
77
78
  BotApi.BotApi
78
79
  > = internal.sendMessage
79
80
 
@@ -81,7 +82,7 @@ export const sendMessage: (params: {
81
82
 
82
83
  type MessageToSendEffect = Effect.Effect<
83
84
  BotApi.Types.Message,
84
- BotApi.BotApiError | BotApiTransport.BotApiTransportError,
85
+ BotApiError.BotApiError | BotApiTransport.BotApiTransportError,
85
86
  BotApi.BotApi | Dialog
86
87
  >
87
88
 
package/src/index.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  export * as Bot from './Bot.ts'
2
2
  export * as BotApi from './BotApi.ts'
3
+ export * as BotApiError from './BotApiError.ts'
3
4
  export * as BotApiTransport from './BotApiTransport.ts'
4
5
  export * as BotApiUrl from './BotApiUrl.ts'
5
6
  export * as Content from './Content.ts'
@@ -1,6 +1,7 @@
1
+ import type * as BotApi from '../BotApi.ts'
1
2
  import type * as BotApiTransport from '../BotApiTransport.ts'
2
3
  import * as Effect from 'effect/Effect'
3
- import * as BotApi from '../BotApi.ts'
4
+ import * as BotApiError from '../BotApiError.ts'
4
5
 
5
6
  export const make = (
6
7
  transport: BotApiTransport.BotApiTransport.Service,
@@ -18,7 +19,7 @@ export const make = (
18
19
  return response.result
19
20
  }
20
21
  return yield* Effect.fail(
21
- new BotApi.BotApiError({
22
+ new BotApiError.BotApiError({
22
23
  code: response.error_code,
23
24
  description: response.description,
24
25
  parameters: response.parameters,
@@ -0,0 +1,36 @@
1
+ import * as Duration from 'effect/Duration'
2
+ import * as BotApiError from '../BotApiError.ts'
3
+
4
+ export const narrow = (
5
+ error: BotApiError.BotApiError,
6
+ ): BotApiError.KnownError | BotApiError.BotApiError => {
7
+ const code = error.code
8
+ const msg = error.message.toLowerCase()
9
+ const params = error.parameters
10
+ if (code === 429 && params?.retry_after != null) {
11
+ return new BotApiError.TooManyRequests({
12
+ cause: error,
13
+ retryAfter: Duration.seconds(params.retry_after),
14
+ })
15
+ }
16
+ if (code === 403) {
17
+ if (msg.includes('bot was blocked by the user')) {
18
+ return new BotApiError.BotBlockedByUser({ cause: error })
19
+ }
20
+ }
21
+ if (code === 400) {
22
+ if (msg.includes('message is not modified')) {
23
+ return new BotApiError.MessageNotModified({ cause: error })
24
+ }
25
+ if (msg.includes('reply markup too long')) {
26
+ return new BotApiError.ReplyMarkupTooLong({ cause: error })
27
+ }
28
+ if (msg.includes('query is too old') && msg.includes('query id is invalid')) {
29
+ return new BotApiError.QueryIdInvalid({ cause: error })
30
+ }
31
+ if (msg.includes('can\'t use the media of the specified type in the album')) {
32
+ return new BotApiError.MediaGroupedInvalid({ cause: error })
33
+ }
34
+ }
35
+ return error
36
+ }
@@ -49,7 +49,7 @@ export interface MethodParams {
49
49
  business_connection_id?: string
50
50
  /** Unique identifier for the target chat or username of the target channel (in the format `@channelusername`) */
51
51
  chat_id: number | string
52
- /** Unique identifier for the target message thread (topic) of the forum; for forum supergroups only */
52
+ /** Unique identifier for the target message thread (topic) of a forum; for forum supergroups and private chats of bots with forum topic mode enabled only */
53
53
  message_thread_id?: number
54
54
  /** Identifier of the direct messages topic to which the message will be sent; required if the message is sent to a direct messages chat */
55
55
  direct_messages_topic_id?: number
@@ -79,7 +79,7 @@ export interface MethodParams {
79
79
  forwardMessage: {
80
80
  /** Unique identifier for the target chat or username of the target channel (in the format `@channelusername`) */
81
81
  chat_id: number | string
82
- /** Unique identifier for the target message thread (topic) of the forum; for forum supergroups only */
82
+ /** Unique identifier for the target message thread (topic) of a forum; for forum supergroups and private chats of bots with forum topic mode enabled only */
83
83
  message_thread_id?: number
84
84
  /** Identifier of the direct messages topic to which the message will be forwarded; required if the message is forwarded to a direct messages chat */
85
85
  direct_messages_topic_id?: number
@@ -91,6 +91,8 @@ export interface MethodParams {
91
91
  disable_notification?: boolean
92
92
  /** Protects the contents of the forwarded message from forwarding and saving */
93
93
  protect_content?: boolean
94
+ /** Unique identifier of the message effect to be added to the message; only available when forwarding to private chats */
95
+ message_effect_id?: string
94
96
  /** An object containing the parameters of the suggested post to send; for direct messages chats only */
95
97
  suggested_post_parameters?: Types.SuggestedPostParameters
96
98
  /** Message identifier in the chat specified in _from\_chat\_id_ */
@@ -99,7 +101,7 @@ export interface MethodParams {
99
101
  forwardMessages: {
100
102
  /** Unique identifier for the target chat or username of the target channel (in the format `@channelusername`) */
101
103
  chat_id: number | string
102
- /** Unique identifier for the target message thread (topic) of the forum; for forum supergroups only */
104
+ /** Unique identifier for the target message thread (topic) of a forum; for forum supergroups and private chats of bots with forum topic mode enabled only */
103
105
  message_thread_id?: number
104
106
  /** Identifier of the direct messages topic to which the messages will be forwarded; required if the messages are forwarded to a direct messages chat */
105
107
  direct_messages_topic_id?: number
@@ -115,7 +117,7 @@ export interface MethodParams {
115
117
  copyMessage: {
116
118
  /** Unique identifier for the target chat or username of the target channel (in the format `@channelusername`) */
117
119
  chat_id: number | string
118
- /** Unique identifier for the target message thread (topic) of the forum; for forum supergroups only */
120
+ /** Unique identifier for the target message thread (topic) of a forum; for forum supergroups and private chats of bots with forum topic mode enabled only */
119
121
  message_thread_id?: number
120
122
  /** Identifier of the direct messages topic to which the message will be sent; required if the message is sent to a direct messages chat */
121
123
  direct_messages_topic_id?: number
@@ -139,6 +141,8 @@ export interface MethodParams {
139
141
  protect_content?: boolean
140
142
  /** Pass _True_ to allow up to 1000 messages per second, ignoring [broadcasting limits](https://core.telegram.org/bots/faq#how-can-i-message-all-of-my-bot-39s-subscribers-at-once) for a fee of 0.1 Telegram Stars per message. The relevant Stars will be withdrawn from the bot's balance */
141
143
  allow_paid_broadcast?: boolean
144
+ /** Unique identifier of the message effect to be added to the message; only available when copying to private chats */
145
+ message_effect_id?: string
142
146
  /** An object containing the parameters of the suggested post to send; for direct messages chats only. If the message is sent as a reply to another suggested post, then that suggested post is automatically declined. */
143
147
  suggested_post_parameters?: Types.SuggestedPostParameters
144
148
  /** Description of the message to reply to */
@@ -149,7 +153,7 @@ export interface MethodParams {
149
153
  copyMessages: {
150
154
  /** Unique identifier for the target chat or username of the target channel (in the format `@channelusername`) */
151
155
  chat_id: number | string
152
- /** Unique identifier for the target message thread (topic) of the forum; for forum supergroups only */
156
+ /** Unique identifier for the target message thread (topic) of a forum; for forum supergroups and private chats of bots with forum topic mode enabled only */
153
157
  message_thread_id?: number
154
158
  /** Identifier of the direct messages topic to which the messages will be sent; required if the messages are sent to a direct messages chat */
155
159
  direct_messages_topic_id?: number
@@ -169,7 +173,7 @@ export interface MethodParams {
169
173
  business_connection_id?: string
170
174
  /** Unique identifier for the target chat or username of the target channel (in the format `@channelusername`) */
171
175
  chat_id: number | string
172
- /** Unique identifier for the target message thread (topic) of the forum; for forum supergroups only */
176
+ /** Unique identifier for the target message thread (topic) of a forum; for forum supergroups and private chats of bots with forum topic mode enabled only */
173
177
  message_thread_id?: number
174
178
  /** Identifier of the direct messages topic to which the message will be sent; required if the message is sent to a direct messages chat */
175
179
  direct_messages_topic_id?: number
@@ -205,7 +209,7 @@ export interface MethodParams {
205
209
  business_connection_id?: string
206
210
  /** Unique identifier for the target chat or username of the target channel (in the format `@channelusername`) */
207
211
  chat_id: number | string
208
- /** Unique identifier for the target message thread (topic) of the forum; for forum supergroups only */
212
+ /** Unique identifier for the target message thread (topic) of a forum; for forum supergroups and private chats of bots with forum topic mode enabled only */
209
213
  message_thread_id?: number
210
214
  /** Identifier of the direct messages topic to which the message will be sent; required if the message is sent to a direct messages chat */
211
215
  direct_messages_topic_id?: number
@@ -245,7 +249,7 @@ export interface MethodParams {
245
249
  business_connection_id?: string
246
250
  /** Unique identifier for the target chat or username of the target channel (in the format `@channelusername`) */
247
251
  chat_id: number | string
248
- /** Unique identifier for the target message thread (topic) of the forum; for forum supergroups only */
252
+ /** Unique identifier for the target message thread (topic) of a forum; for forum supergroups and private chats of bots with forum topic mode enabled only */
249
253
  message_thread_id?: number
250
254
  /** Identifier of the direct messages topic to which the message will be sent; required if the message is sent to a direct messages chat */
251
255
  direct_messages_topic_id?: number
@@ -281,7 +285,7 @@ export interface MethodParams {
281
285
  business_connection_id?: string
282
286
  /** Unique identifier for the target chat or username of the target channel (in the format `@channelusername`) */
283
287
  chat_id: number | string
284
- /** Unique identifier for the target message thread (topic) of the forum; for forum supergroups only */
288
+ /** Unique identifier for the target message thread (topic) of a forum; for forum supergroups and private chats of bots with forum topic mode enabled only */
285
289
  message_thread_id?: number
286
290
  /** Identifier of the direct messages topic to which the message will be sent; required if the message is sent to a direct messages chat */
287
291
  direct_messages_topic_id?: number
@@ -331,7 +335,7 @@ export interface MethodParams {
331
335
  business_connection_id?: string
332
336
  /** Unique identifier for the target chat or username of the target channel (in the format `@channelusername`) */
333
337
  chat_id: number | string
334
- /** Unique identifier for the target message thread (topic) of the forum; for forum supergroups only */
338
+ /** Unique identifier for the target message thread (topic) of a forum; for forum supergroups and private chats of bots with forum topic mode enabled only */
335
339
  message_thread_id?: number
336
340
  /** Identifier of the direct messages topic to which the message will be sent; required if the message is sent to a direct messages chat */
337
341
  direct_messages_topic_id?: number
@@ -375,7 +379,7 @@ export interface MethodParams {
375
379
  business_connection_id?: string
376
380
  /** Unique identifier for the target chat or username of the target channel (in the format `@channelusername`) */
377
381
  chat_id: number | string
378
- /** Unique identifier for the target message thread (topic) of the forum; for forum supergroups only */
382
+ /** Unique identifier for the target message thread (topic) of a forum; for forum supergroups and private chats of bots with forum topic mode enabled only */
379
383
  message_thread_id?: number
380
384
  /** Identifier of the direct messages topic to which the message will be sent; required if the message is sent to a direct messages chat */
381
385
  direct_messages_topic_id?: number
@@ -409,7 +413,7 @@ export interface MethodParams {
409
413
  business_connection_id?: string
410
414
  /** Unique identifier for the target chat or username of the target channel (in the format `@channelusername`) */
411
415
  chat_id: number | string
412
- /** Unique identifier for the target message thread (topic) of the forum; for forum supergroups only */
416
+ /** Unique identifier for the target message thread (topic) of a forum; for forum supergroups and private chats of bots with forum topic mode enabled only */
413
417
  message_thread_id?: number
414
418
  /** Identifier of the direct messages topic to which the message will be sent; required if the message is sent to a direct messages chat */
415
419
  direct_messages_topic_id?: number
@@ -441,11 +445,11 @@ export interface MethodParams {
441
445
  business_connection_id?: string
442
446
  /** Unique identifier for the target chat or username of the target channel (in the format `@channelusername`). If the chat is a channel, all Telegram Star proceeds from this media will be credited to the chat's balance. Otherwise, they will be credited to the bot's balance. */
443
447
  chat_id: number | string
444
- /** Unique identifier for the target message thread (topic) of the forum; for forum supergroups only */
448
+ /** Unique identifier for the target message thread (topic) of a forum; for forum supergroups and private chats of bots with forum topic mode enabled only */
445
449
  message_thread_id?: number
446
450
  /** Identifier of the direct messages topic to which the message will be sent; required if the message is sent to a direct messages chat */
447
451
  direct_messages_topic_id?: number
448
- /** The number of Telegram Stars that must be paid to buy access to the media; 1-10000 */
452
+ /** The number of Telegram Stars that must be paid to buy access to the media; 1-25000 */
449
453
  star_count: number
450
454
  /** An array describing the media to be sent; up to 10 items */
451
455
  media: Array<Types.InputPaidMedia>
@@ -477,7 +481,7 @@ export interface MethodParams {
477
481
  business_connection_id?: string
478
482
  /** Unique identifier for the target chat or username of the target channel (in the format `@channelusername`) */
479
483
  chat_id: number | string
480
- /** Unique identifier for the target message thread (topic) of the forum; for forum supergroups only */
484
+ /** Unique identifier for the target message thread (topic) of a forum; for forum supergroups and private chats of bots with forum topic mode enabled only */
481
485
  message_thread_id?: number
482
486
  /** Identifier of the direct messages topic to which the messages will be sent; required if the messages are sent to a direct messages chat */
483
487
  direct_messages_topic_id?: number
@@ -499,7 +503,7 @@ export interface MethodParams {
499
503
  business_connection_id?: string
500
504
  /** Unique identifier for the target chat or username of the target channel (in the format `@channelusername`) */
501
505
  chat_id: number | string
502
- /** Unique identifier for the target message thread (topic) of the forum; for forum supergroups only */
506
+ /** Unique identifier for the target message thread (topic) of a forum; for forum supergroups and private chats of bots with forum topic mode enabled only */
503
507
  message_thread_id?: number
504
508
  /** Identifier of the direct messages topic to which the message will be sent; required if the message is sent to a direct messages chat */
505
509
  direct_messages_topic_id?: number
@@ -535,7 +539,7 @@ export interface MethodParams {
535
539
  business_connection_id?: string
536
540
  /** Unique identifier for the target chat or username of the target channel (in the format `@channelusername`) */
537
541
  chat_id: number | string
538
- /** Unique identifier for the target message thread (topic) of the forum; for forum supergroups only */
542
+ /** Unique identifier for the target message thread (topic) of a forum; for forum supergroups and private chats of bots with forum topic mode enabled only */
539
543
  message_thread_id?: number
540
544
  /** Identifier of the direct messages topic to which the message will be sent; required if the message is sent to a direct messages chat */
541
545
  direct_messages_topic_id?: number
@@ -575,7 +579,7 @@ export interface MethodParams {
575
579
  business_connection_id?: string
576
580
  /** Unique identifier for the target chat or username of the target channel (in the format `@channelusername`) */
577
581
  chat_id: number | string
578
- /** Unique identifier for the target message thread (topic) of the forum; for forum supergroups only */
582
+ /** Unique identifier for the target message thread (topic) of a forum; for forum supergroups and private chats of bots with forum topic mode enabled only */
579
583
  message_thread_id?: number
580
584
  /** Identifier of the direct messages topic to which the message will be sent; required if the message is sent to a direct messages chat */
581
585
  direct_messages_topic_id?: number
@@ -607,7 +611,7 @@ export interface MethodParams {
607
611
  business_connection_id?: string
608
612
  /** Unique identifier for the target chat or username of the target channel (in the format `@channelusername`). Polls can't be sent to channel direct messages chats. */
609
613
  chat_id: number | string
610
- /** Unique identifier for the target message thread (topic) of the forum; for forum supergroups only */
614
+ /** Unique identifier for the target message thread (topic) of a forum; for forum supergroups and private chats of bots with forum topic mode enabled only */
611
615
  message_thread_id?: number
612
616
  /** Poll question, 1-300 characters */
613
617
  question: string
@@ -673,7 +677,7 @@ export interface MethodParams {
673
677
  business_connection_id?: string
674
678
  /** Unique identifier for the target chat or username of the target channel (in the format `@channelusername`) */
675
679
  chat_id: number | string
676
- /** Unique identifier for the target message thread (topic) of the forum; for forum supergroups only */
680
+ /** Unique identifier for the target message thread (topic) of a forum; for forum supergroups and private chats of bots with forum topic mode enabled only */
677
681
  message_thread_id?: number
678
682
  /** Identifier of the direct messages topic to which the message will be sent; required if the message is sent to a direct messages chat */
679
683
  direct_messages_topic_id?: number
@@ -694,12 +698,26 @@ export interface MethodParams {
694
698
  /** Additional interface options. An object for an [inline keyboard](https://core.telegram.org/bots/features#inline-keyboards), [custom reply keyboard](https://core.telegram.org/bots/features#keyboards), instructions to remove a reply keyboard or to force a reply from the user */
695
699
  reply_markup?: Types.InlineKeyboardMarkup | Types.ReplyKeyboardMarkup | Types.ReplyKeyboardRemove | Types.ForceReply
696
700
  }
701
+ sendMessageDraft: {
702
+ /** Unique identifier for the target private chat */
703
+ chat_id: number
704
+ /** Unique identifier for the target message thread */
705
+ message_thread_id?: number
706
+ /** Unique identifier of the message draft; must be non-zero. Changes of drafts with the same identifier are animated */
707
+ draft_id: number
708
+ /** Text of the message to be sent, 1-4096 characters after entities parsing */
709
+ text: string
710
+ /** Mode for parsing entities in the message text. See [formatting options](https://core.telegram.org/bots/api#formatting-options) for more details. */
711
+ parse_mode?: string
712
+ /** An array of special entities that appear in message text, which can be specified instead of _parse\_mode_ */
713
+ entities?: Array<Types.MessageEntity>
714
+ }
697
715
  sendChatAction: {
698
716
  /** Unique identifier of the business connection on behalf of which the action will be sent */
699
717
  business_connection_id?: string
700
718
  /** Unique identifier for the target chat or username of the target supergroup (in the format `@supergroupusername`). Channel chats and channel direct messages chats aren't supported. */
701
719
  chat_id: number | string
702
- /** Unique identifier for the target message thread; for supergroups only */
720
+ /** Unique identifier for the target message thread or topic of a forum; for supergroups and private chats of bots with forum topic mode enabled only */
703
721
  message_thread_id?: number
704
722
  /** Type of action to broadcast. Choose one, depending on what the user is about to receive: _typing_ for [text messages](https://core.telegram.org/bots/api#sendmessage), _upload\_photo_ for [photos](https://core.telegram.org/bots/api#sendphoto), _record\_video_ or _upload\_video_ for [videos](https://core.telegram.org/bots/api#sendvideo), _record\_voice_ or _upload\_voice_ for [voice notes](https://core.telegram.org/bots/api#sendvoice), _upload\_document_ for [general files](https://core.telegram.org/bots/api#senddocument), _choose\_sticker_ for [stickers](https://core.telegram.org/bots/api#sendsticker), _find\_location_ for [location data](https://core.telegram.org/bots/api#sendlocation), _record\_video\_note_ or _upload\_video\_note_ for [video notes](https://core.telegram.org/bots/api#sendvideonote). */
705
723
  action: string
@@ -777,7 +795,7 @@ export interface MethodParams {
777
795
  can_delete_messages?: boolean
778
796
  /** Pass _True_ if the administrator can manage video chats */
779
797
  can_manage_video_chats?: boolean
780
- /** Pass _True_ if the administrator can restrict, ban or unban chat members, or access supergroup statistics */
798
+ /** Pass _True_ if the administrator can restrict, ban or unban chat members, or access supergroup statistics. For backward compatibility, defaults to _True_ for promotions of channel administrators */
781
799
  can_restrict_members?: boolean
782
800
  /** Pass _True_ if the administrator can add new administrators with a subset of their own privileges or demote administrators that they have promoted, directly or indirectly (promoted by administrators that were appointed by him) */
783
801
  can_promote_members?: boolean
@@ -1145,7 +1163,7 @@ export interface MethodParams {
1145
1163
  user_id?: number
1146
1164
  /** Required if _user\_id_ is not specified. Unique identifier for the chat or username of the channel (in the format `@channelusername`) that will receive the gift. */
1147
1165
  chat_id?: number | string
1148
- /** Identifier of the gift */
1166
+ /** Identifier of the gift; limited gifts can't be sent to channel chats */
1149
1167
  gift_id: string
1150
1168
  /** Pass _True_ to pay for the gift upgrade from the bot's balance, thereby making the upgrade free for the receiver */
1151
1169
  pay_for_upgrade?: boolean
@@ -1265,10 +1283,14 @@ export interface MethodParams {
1265
1283
  exclude_saved?: boolean
1266
1284
  /** Pass _True_ to exclude gifts that can be purchased an unlimited number of times */
1267
1285
  exclude_unlimited?: boolean
1268
- /** Pass _True_ to exclude gifts that can be purchased a limited number of times */
1269
- exclude_limited?: boolean
1286
+ /** Pass _True_ to exclude gifts that can be purchased a limited number of times and can be upgraded to unique */
1287
+ exclude_limited_upgradable?: boolean
1288
+ /** Pass _True_ to exclude gifts that can be purchased a limited number of times and can't be upgraded to unique */
1289
+ exclude_limited_non_upgradable?: boolean
1270
1290
  /** Pass _True_ to exclude unique gifts */
1271
1291
  exclude_unique?: boolean
1292
+ /** Pass _True_ to exclude gifts that were assigned from the TON blockchain and can't be resold or transferred in Telegram */
1293
+ exclude_from_blockchain?: boolean
1272
1294
  /** Pass _True_ to sort results by gift price instead of send date. Sorting is applied before pagination. */
1273
1295
  sort_by_price?: boolean
1274
1296
  /** Offset of the first entry to return as received from the previous request; use empty string to get the first chunk of results */
@@ -1276,6 +1298,50 @@ export interface MethodParams {
1276
1298
  /** The maximum number of gifts to be returned; 1-100. Defaults to 100 */
1277
1299
  limit?: number
1278
1300
  }
1301
+ getUserGifts: {
1302
+ /** Unique identifier of the user */
1303
+ user_id: number
1304
+ /** Pass _True_ to exclude gifts that can be purchased an unlimited number of times */
1305
+ exclude_unlimited?: boolean
1306
+ /** Pass _True_ to exclude gifts that can be purchased a limited number of times and can be upgraded to unique */
1307
+ exclude_limited_upgradable?: boolean
1308
+ /** Pass _True_ to exclude gifts that can be purchased a limited number of times and can't be upgraded to unique */
1309
+ exclude_limited_non_upgradable?: boolean
1310
+ /** Pass _True_ to exclude gifts that were assigned from the TON blockchain and can't be resold or transferred in Telegram */
1311
+ exclude_from_blockchain?: boolean
1312
+ /** Pass _True_ to exclude unique gifts */
1313
+ exclude_unique?: boolean
1314
+ /** Pass _True_ to sort results by gift price instead of send date. Sorting is applied before pagination. */
1315
+ sort_by_price?: boolean
1316
+ /** Offset of the first entry to return as received from the previous request; use an empty string to get the first chunk of results */
1317
+ offset?: string
1318
+ /** The maximum number of gifts to be returned; 1-100. Defaults to 100 */
1319
+ limit?: number
1320
+ }
1321
+ getChatGifts: {
1322
+ /** Unique identifier for the target chat or username of the target channel (in the format `@channelusername`) */
1323
+ chat_id: number | string
1324
+ /** Pass _True_ to exclude gifts that aren't saved to the chat's profile page. Always _True_, unless the bot has the _can\_post\_messages_ administrator right in the channel. */
1325
+ exclude_unsaved?: boolean
1326
+ /** Pass _True_ to exclude gifts that are saved to the chat's profile page. Always _False_, unless the bot has the _can\_post\_messages_ administrator right in the channel. */
1327
+ exclude_saved?: boolean
1328
+ /** Pass _True_ to exclude gifts that can be purchased an unlimited number of times */
1329
+ exclude_unlimited?: boolean
1330
+ /** Pass _True_ to exclude gifts that can be purchased a limited number of times and can be upgraded to unique */
1331
+ exclude_limited_upgradable?: boolean
1332
+ /** Pass _True_ to exclude gifts that can be purchased a limited number of times and can't be upgraded to unique */
1333
+ exclude_limited_non_upgradable?: boolean
1334
+ /** Pass _True_ to exclude gifts that were assigned from the TON blockchain and can't be resold or transferred in Telegram */
1335
+ exclude_from_blockchain?: boolean
1336
+ /** Pass _True_ to exclude unique gifts */
1337
+ exclude_unique?: boolean
1338
+ /** Pass _True_ to sort results by gift price instead of send date. Sorting is applied before pagination. */
1339
+ sort_by_price?: boolean
1340
+ /** Offset of the first entry to return as received from the previous request; use an empty string to get the first chunk of results */
1341
+ offset?: string
1342
+ /** The maximum number of gifts to be returned; 1-100. Defaults to 100 */
1343
+ limit?: number
1344
+ }
1279
1345
  convertGiftToStars: {
1280
1346
  /** Unique identifier of the business connection */
1281
1347
  business_connection_id: string
@@ -1322,6 +1388,20 @@ export interface MethodParams {
1322
1388
  /** Pass _True_ if the content of the story must be protected from forwarding and screenshotting */
1323
1389
  protect_content?: boolean
1324
1390
  }
1391
+ repostStory: {
1392
+ /** Unique identifier of the business connection */
1393
+ business_connection_id: string
1394
+ /** Unique identifier of the chat which posted the story that should be reposted */
1395
+ from_chat_id: number
1396
+ /** Unique identifier of the story that should be reposted */
1397
+ from_story_id: number
1398
+ /** Period after which the story is moved to the archive, in seconds; must be one of `6 * 3600`, `12 * 3600`, `86400`, or `2 * 86400` */
1399
+ active_period: number
1400
+ /** Pass _True_ to keep the story accessible after it expires */
1401
+ post_to_chat_page?: boolean
1402
+ /** Pass _True_ if the content of the story must be protected from forwarding and screenshotting */
1403
+ protect_content?: boolean
1404
+ }
1325
1405
  editStory: {
1326
1406
  /** Unique identifier of the business connection */
1327
1407
  business_connection_id: string
@@ -1501,7 +1581,7 @@ export interface MethodParams {
1501
1581
  business_connection_id?: string
1502
1582
  /** Unique identifier for the target chat or username of the target channel (in the format `@channelusername`) */
1503
1583
  chat_id: number | string
1504
- /** Unique identifier for the target message thread (topic) of the forum; for forum supergroups only */
1584
+ /** Unique identifier for the target message thread (topic) of a forum; for forum supergroups and private chats of bots with forum topic mode enabled only */
1505
1585
  message_thread_id?: number
1506
1586
  /** Identifier of the direct messages topic to which the message will be sent; required if the message is sent to a direct messages chat */
1507
1587
  direct_messages_topic_id?: number
@@ -1663,7 +1743,7 @@ export interface MethodParams {
1663
1743
  sendInvoice: {
1664
1744
  /** Unique identifier for the target chat or username of the target channel (in the format `@channelusername`) */
1665
1745
  chat_id: number | string
1666
- /** Unique identifier for the target message thread (topic) of the forum; for forum supergroups only */
1746
+ /** Unique identifier for the target message thread (topic) of a forum; for forum supergroups and private chats of bots with forum topic mode enabled only */
1667
1747
  message_thread_id?: number
1668
1748
  /** Identifier of the direct messages topic to which the message will be sent; required if the message is sent to a direct messages chat */
1669
1749
  direct_messages_topic_id?: number
@@ -1820,7 +1900,7 @@ export interface MethodParams {
1820
1900
  business_connection_id?: string
1821
1901
  /** Unique identifier for the target chat. Games can't be sent to channel direct messages chats and channel chats. */
1822
1902
  chat_id: number
1823
- /** Unique identifier for the target message thread (topic) of the forum; for forum supergroups only */
1903
+ /** Unique identifier for the target message thread (topic) of a forum; for forum supergroups and private chats of bots with forum topic mode enabled only */
1824
1904
  message_thread_id?: number
1825
1905
  /** Short name of the game, serves as the unique identifier for the game. Set up your games via [@BotFather](https://t.me/botfather). */
1826
1906
  game_short_name: string
@@ -1893,6 +1973,7 @@ export interface MethodResults {
1893
1973
  sendPoll: Types.Message
1894
1974
  sendChecklist: Types.Message
1895
1975
  sendDice: Types.Message
1976
+ sendMessageDraft: true
1896
1977
  sendChatAction: true
1897
1978
  setMessageReaction: true
1898
1979
  getUserProfilePhotos: Types.UserProfilePhotos
@@ -1975,10 +2056,13 @@ export interface MethodResults {
1975
2056
  getBusinessAccountStarBalance: Types.StarAmount
1976
2057
  transferBusinessAccountStars: true
1977
2058
  getBusinessAccountGifts: Types.OwnedGifts
2059
+ getUserGifts: Types.OwnedGifts
2060
+ getChatGifts: Types.OwnedGifts
1978
2061
  convertGiftToStars: true
1979
2062
  upgradeGift: true
1980
2063
  transferGift: true
1981
2064
  postStory: Types.Story
2065
+ repostStory: Types.Story
1982
2066
  editStory: Types.Story
1983
2067
  deleteStory: true
1984
2068
  editMessageText: Types.Message | true
@@ -81,6 +81,8 @@ export interface BotApiShape {
81
81
  sendChecklist: BotApi.Method<'sendChecklist'>
82
82
  /** Use this method to send an animated emoji that will display a random value. On success, the sent [Message](https://core.telegram.org/bots/api#message) is returned. */
83
83
  sendDice: BotApi.Method<'sendDice'>
84
+ /** Use this method to stream a partial message to a user while the message is being generated; supported only for bots with forum topic mode enabled. Returns _True_ on success. */
85
+ sendMessageDraft: BotApi.Method<'sendMessageDraft'>
84
86
  /**
85
87
  * Use this method when you need to tell the user that something is happening on the bot's side. The status is set for 5 seconds or less (when a message arrives from your bot, Telegram clients clear its typing status). Returns _True_ on success.
86
88
  *
@@ -169,15 +171,15 @@ export interface BotApiShape {
169
171
  getForumTopicIconStickers: BotApi.Method<'getForumTopicIconStickers'>
170
172
  /** Use this method to create a topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the _can\_manage\_topics_ administrator rights. Returns information about the created topic as a [ForumTopic](https://core.telegram.org/bots/api#forumtopic) object. */
171
173
  createForumTopic: BotApi.Method<'createForumTopic'>
172
- /** Use this method to edit name and icon of a topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the _can\_manage\_topics_ administrator rights, unless it is the creator of the topic. Returns _True_ on success. */
174
+ /** Use this method to edit name and icon of a topic in a forum supergroup chat or a private chat with a user. In the case of a supergroup chat the bot must be an administrator in the chat for this to work and must have the _can\_manage\_topics_ administrator rights, unless it is the creator of the topic. Returns _True_ on success. */
173
175
  editForumTopic: BotApi.Method<'editForumTopic'>
174
176
  /** Use this method to close an open topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the _can\_manage\_topics_ administrator rights, unless it is the creator of the topic. Returns _True_ on success. */
175
177
  closeForumTopic: BotApi.Method<'closeForumTopic'>
176
178
  /** Use this method to reopen a closed topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the _can\_manage\_topics_ administrator rights, unless it is the creator of the topic. Returns _True_ on success. */
177
179
  reopenForumTopic: BotApi.Method<'reopenForumTopic'>
178
- /** Use this method to delete a forum topic along with all its messages in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the _can\_delete\_messages_ administrator rights. Returns _True_ on success. */
180
+ /** Use this method to delete a forum topic along with all its messages in a forum supergroup chat or a private chat with a user. In the case of a supergroup chat the bot must be an administrator in the chat for this to work and must have the _can\_delete\_messages_ administrator rights. Returns _True_ on success. */
179
181
  deleteForumTopic: BotApi.Method<'deleteForumTopic'>
180
- /** Use this method to clear the list of pinned messages in a forum topic. The bot must be an administrator in the chat for this to work and must have the _can\_pin\_messages_ administrator right in the supergroup. Returns _True_ on success. */
182
+ /** Use this method to clear the list of pinned messages in a forum topic in a forum supergroup chat or a private chat with a user. In the case of a supergroup chat the bot must be an administrator in the chat for this to work and must have the _can\_pin\_messages_ administrator right in the supergroup. Returns _True_ on success. */
181
183
  unpinAllForumTopicMessages: BotApi.Method<'unpinAllForumTopicMessages'>
182
184
  /** Use this method to edit the name of the 'General' topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the _can\_manage\_topics_ administrator rights. Returns _True_ on success. */
183
185
  editGeneralForumTopic: BotApi.Method<'editGeneralForumTopic'>
@@ -263,6 +265,10 @@ export interface BotApiShape {
263
265
  transferBusinessAccountStars: BotApi.Method<'transferBusinessAccountStars'>
264
266
  /** Returns the gifts received and owned by a managed business account. Requires the _can\_view\_gifts\_and\_stars_ business bot right. Returns [OwnedGifts](https://core.telegram.org/bots/api#ownedgifts) on success. */
265
267
  getBusinessAccountGifts: BotApi.Method<'getBusinessAccountGifts'>
268
+ /** Returns the gifts owned and hosted by a user. Returns [OwnedGifts](https://core.telegram.org/bots/api#ownedgifts) on success. */
269
+ getUserGifts: BotApi.Method<'getUserGifts'>
270
+ /** Returns the gifts owned by a chat. Returns [OwnedGifts](https://core.telegram.org/bots/api#ownedgifts) on success. */
271
+ getChatGifts: BotApi.Method<'getChatGifts'>
266
272
  /** Converts a given regular gift to Telegram Stars. Requires the _can\_convert\_gifts\_to\_stars_ business bot right. Returns _True_ on success. */
267
273
  convertGiftToStars: BotApi.Method<'convertGiftToStars'>
268
274
  /** Upgrades a given regular gift to a unique gift. Requires the _can\_transfer\_and\_upgrade\_gifts_ business bot right. Additionally requires the _can\_transfer\_stars_ business bot right if the upgrade is paid. Returns _True_ on success. */
@@ -271,6 +277,8 @@ export interface BotApiShape {
271
277
  transferGift: BotApi.Method<'transferGift'>
272
278
  /** Posts a story on behalf of a managed business account. Requires the _can\_manage\_stories_ business bot right. Returns [Story](https://core.telegram.org/bots/api#story) on success. */
273
279
  postStory: BotApi.Method<'postStory'>
280
+ /** Reposts a story on behalf of a business account from another business account. Both business accounts must be managed by the same bot, and the story on the source account must have been posted (or reposted) by the bot. Requires the _can\_manage\_stories_ business bot right for both business accounts. Returns [Story](https://core.telegram.org/bots/api#story) on success. */
281
+ repostStory: BotApi.Method<'repostStory'>
274
282
  /** Edits a story previously posted by the bot on behalf of a managed business account. Requires the _can\_manage\_stories_ business bot right. Returns [Story](https://core.telegram.org/bots/api#story) on success. */
275
283
  editStory: BotApi.Method<'editStory'>
276
284
  /** Deletes a story previously posted by the bot on behalf of a managed business account. Requires the _can\_manage\_stories_ business bot right. Returns _True_ on success. */