@grom.js/effect-tg 0.4.0 → 0.5.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 (122) hide show
  1. package/dist/Bot.d.ts +5 -1
  2. package/dist/Bot.d.ts.map +1 -1
  3. package/dist/Bot.js +2 -0
  4. package/dist/Bot.js.map +1 -0
  5. package/dist/BotApi.d.ts +12 -3
  6. package/dist/BotApi.d.ts.map +1 -1
  7. package/dist/BotApi.js +7 -2
  8. package/dist/BotApi.js.map +1 -0
  9. package/dist/BotApiTransport.d.ts +11 -10
  10. package/dist/BotApiTransport.d.ts.map +1 -1
  11. package/dist/BotApiTransport.js +6 -8
  12. package/dist/BotApiTransport.js.map +1 -0
  13. package/dist/BotApiUrl.d.ts +14 -0
  14. package/dist/BotApiUrl.d.ts.map +1 -0
  15. package/dist/BotApiUrl.js +13 -0
  16. package/dist/BotApiUrl.js.map +1 -0
  17. package/dist/Content.d.ts +288 -16
  18. package/dist/Content.d.ts.map +1 -1
  19. package/dist/Content.js +189 -28
  20. package/dist/Content.js.map +1 -0
  21. package/dist/Dialog.d.ts +61 -0
  22. package/dist/Dialog.d.ts.map +1 -0
  23. package/dist/Dialog.js +35 -0
  24. package/dist/Dialog.js.map +1 -0
  25. package/dist/File.d.ts +23 -0
  26. package/dist/File.d.ts.map +1 -0
  27. package/dist/File.js +24 -0
  28. package/dist/File.js.map +1 -0
  29. package/dist/LinkPreview.d.ts +2 -2
  30. package/dist/LinkPreview.d.ts.map +1 -1
  31. package/dist/LinkPreview.js +17 -16
  32. package/dist/LinkPreview.js.map +1 -0
  33. package/dist/Markup.d.ts +41 -0
  34. package/dist/Markup.d.ts.map +1 -0
  35. package/dist/Markup.js +10 -0
  36. package/dist/Markup.js.map +1 -0
  37. package/dist/Runner.d.ts +3 -3
  38. package/dist/Runner.d.ts.map +1 -1
  39. package/dist/Runner.js +1 -0
  40. package/dist/Runner.js.map +1 -0
  41. package/dist/Send.d.ts +177 -13
  42. package/dist/Send.d.ts.map +1 -1
  43. package/dist/Send.js +187 -18
  44. package/dist/Send.js.map +1 -0
  45. package/dist/Text.d.ts +21 -11
  46. package/dist/Text.d.ts.map +1 -1
  47. package/dist/Text.js +10 -17
  48. package/dist/Text.js.map +1 -0
  49. package/dist/index.d.ts +4 -4
  50. package/dist/index.d.ts.map +1 -1
  51. package/dist/index.js +5 -4
  52. package/dist/index.js.map +1 -0
  53. package/dist/internal/botApi.d.ts +3 -4
  54. package/dist/internal/botApi.d.ts.map +1 -1
  55. package/dist/internal/botApi.js +18 -22
  56. package/dist/internal/botApi.js.map +1 -0
  57. package/dist/internal/botApiMethods.gen.d.ts +19 -19
  58. package/dist/internal/botApiMethods.gen.d.ts.map +1 -1
  59. package/dist/internal/botApiMethods.gen.js +1 -0
  60. package/dist/internal/botApiMethods.gen.js.map +1 -0
  61. package/dist/internal/botApiShape.gen.d.ts +159 -159
  62. package/dist/internal/botApiShape.gen.d.ts.map +1 -1
  63. package/dist/internal/botApiShape.gen.js +1 -0
  64. package/dist/internal/botApiShape.gen.js.map +1 -0
  65. package/dist/internal/botApiTransport.d.ts +4 -6
  66. package/dist/internal/botApiTransport.d.ts.map +1 -1
  67. package/dist/internal/botApiTransport.js +89 -17
  68. package/dist/internal/botApiTransport.js.map +1 -0
  69. package/dist/internal/botApiTypes.gen.js +1 -0
  70. package/dist/internal/botApiTypes.gen.js.map +1 -0
  71. package/dist/internal/dialog.d.ts +12 -0
  72. package/dist/internal/dialog.d.ts.map +1 -0
  73. package/dist/internal/dialog.js +19 -0
  74. package/dist/internal/dialog.js.map +1 -0
  75. package/dist/internal/runner.d.ts +1 -1
  76. package/dist/internal/runner.d.ts.map +1 -1
  77. package/dist/internal/runner.js +8 -4
  78. package/dist/internal/runner.js.map +1 -0
  79. package/dist/internal/send.d.ts +13 -0
  80. package/dist/internal/send.d.ts.map +1 -0
  81. package/dist/internal/send.js +220 -0
  82. package/dist/internal/send.js.map +1 -0
  83. package/package.json +13 -10
  84. package/src/Bot.ts +16 -0
  85. package/src/BotApi.ts +68 -0
  86. package/src/BotApiTransport.ts +55 -0
  87. package/src/BotApiUrl.ts +28 -0
  88. package/src/Content.ts +410 -0
  89. package/src/Dialog.ts +54 -0
  90. package/src/File.ts +45 -0
  91. package/src/LinkPreview.ts +26 -0
  92. package/src/Markup.ts +33 -0
  93. package/src/Runner.ts +22 -0
  94. package/src/Send.ts +330 -0
  95. package/src/Text.ts +42 -0
  96. package/src/index.ts +12 -0
  97. package/src/internal/botApi.ts +31 -0
  98. package/src/internal/botApiMethods.gen.ts +2027 -0
  99. package/src/internal/botApiShape.gen.ts +398 -0
  100. package/src/internal/botApiTransport.ts +118 -0
  101. package/src/internal/botApiTypes.gen.ts +4178 -0
  102. package/src/internal/dialog.ts +33 -0
  103. package/src/internal/runner.ts +57 -0
  104. package/src/internal/send.ts +318 -0
  105. package/dist/BotApiWebhook.d.ts +0 -41
  106. package/dist/BotApiWebhook.d.ts.map +0 -1
  107. package/dist/BotApiWebhook.js +0 -43
  108. package/dist/Chat.d.ts +0 -96
  109. package/dist/Chat.d.ts.map +0 -1
  110. package/dist/Chat.js +0 -48
  111. package/dist/InputFile.d.ts +0 -4
  112. package/dist/InputFile.d.ts.map +0 -1
  113. package/dist/InputFile.js +0 -3
  114. package/dist/Middleware.d.ts +0 -6
  115. package/dist/Middleware.d.ts.map +0 -1
  116. package/dist/Middleware.js +0 -1
  117. package/dist/internal/botApiMethod.d.ts +0 -8
  118. package/dist/internal/botApiMethod.d.ts.map +0 -1
  119. package/dist/internal/botApiMethod.js +0 -1
  120. package/dist/internal/chat.d.ts +0 -14
  121. package/dist/internal/chat.d.ts.map +0 -1
  122. package/dist/internal/chat.js +0 -20
@@ -0,0 +1,398 @@
1
+ import type * as BotApi from '../BotApi.ts'
2
+
3
+ export interface BotApiShape {
4
+ /**
5
+ * Use this method to receive incoming updates using long polling ([wiki](https://en.wikipedia.org/wiki/Push_technology#Long_polling)). Returns an Array of [Update](https://core.telegram.org/bots/api#update) objects.
6
+ *
7
+ * > **Notes**
8
+ * >
9
+ * > **1.** This method will not work if an outgoing webhook is set up.
10
+ * >
11
+ * > **2.** In order to avoid getting duplicate updates, recalculate _offset_ after each server response.
12
+ */
13
+ getUpdates: BotApi.Method<'getUpdates'>
14
+ /**
15
+ * Use this method to specify a URL and receive incoming updates via an outgoing webhook. Whenever there is an update for the bot, we will send an HTTPS POST request to the specified URL, containing a JSON-serialized [Update](https://core.telegram.org/bots/api#update). In case of an unsuccessful request (a request with response [HTTP status code](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes) different from `2XY`), we will repeat the request and give up after a reasonable amount of attempts. Returns _True_ on success.
16
+ *
17
+ * If you'd like to make sure that the webhook was set by you, you can specify secret data in the parameter _secret\_token_. If specified, the request will contain a header “X-Telegram-Bot-Api-Secret-Token” with the secret token as content.
18
+ *
19
+ * > **Notes**
20
+ * >
21
+ * > **1.** You will not be able to receive updates using [getUpdates](https://core.telegram.org/bots/api#getupdates) for as long as an outgoing webhook is set up.
22
+ * >
23
+ * > **2.** To use a self-signed certificate, you need to upload your [public key certificate](https://core.telegram.org/bots/self-signed) using _certificate_ parameter. Please upload as InputFile, sending a String will not work.
24
+ * >
25
+ * > **3.** Ports currently supported _for webhooks_: **443, 80, 88, 8443**.
26
+ * >
27
+ * > If you're having any trouble setting up webhooks, please check out this [amazing guide to webhooks](https://core.telegram.org/bots/webhooks).
28
+ */
29
+ setWebhook: BotApi.Method<'setWebhook'>
30
+ /** Use this method to remove webhook integration if you decide to switch back to [getUpdates](https://core.telegram.org/bots/api#getupdates). Returns _True_ on success. */
31
+ deleteWebhook: BotApi.Method<'deleteWebhook'>
32
+ /** Use this method to get current webhook status. Requires no parameters. On success, returns a [WebhookInfo](https://core.telegram.org/bots/api#webhookinfo) object. If the bot is using [getUpdates](https://core.telegram.org/bots/api#getupdates), will return an object with the _url_ field empty. */
33
+ getWebhookInfo: BotApi.Method<'getWebhookInfo'>
34
+ /** A simple method for testing your bot's authentication token. Requires no parameters. Returns basic information about the bot in form of a [User](https://core.telegram.org/bots/api#user) object. */
35
+ getMe: BotApi.Method<'getMe'>
36
+ /** Use this method to log out from the cloud Bot API server before launching the bot locally. You **must** log out the bot before running it locally, otherwise there is no guarantee that the bot will receive updates. After a successful call, you can immediately log in on a local server, but will not be able to log in back to the cloud Bot API server for 10 minutes. Returns _True_ on success. Requires no parameters. */
37
+ logOut: BotApi.Method<'logOut'>
38
+ /** Use this method to close the bot instance before moving it from one local server to another. You need to delete the webhook before calling this method to ensure that the bot isn't launched again after server restart. The method will return error 429 in the first 10 minutes after the bot is launched. Returns _True_ on success. Requires no parameters. */
39
+ close: BotApi.Method<'close'>
40
+ /** Use this method to send text messages. On success, the sent [Message](https://core.telegram.org/bots/api#message) is returned. */
41
+ sendMessage: BotApi.Method<'sendMessage'>
42
+ /** Use this method to forward messages of any kind. Service messages and messages with protected content can't be forwarded. On success, the sent [Message](https://core.telegram.org/bots/api#message) is returned. */
43
+ forwardMessage: BotApi.Method<'forwardMessage'>
44
+ /** Use this method to forward multiple messages of any kind. If some of the specified messages can't be found or forwarded, they are skipped. Service messages and messages with protected content can't be forwarded. Album grouping is kept for forwarded messages. On success, an array of [MessageId](https://core.telegram.org/bots/api#messageid) of the sent messages is returned. */
45
+ forwardMessages: BotApi.Method<'forwardMessages'>
46
+ /** Use this method to copy messages of any kind. Service messages, paid media messages, giveaway messages, giveaway winners messages, and invoice messages can't be copied. A quiz [poll](https://core.telegram.org/bots/api#poll) can be copied only if the value of the field _correct\_option\_id_ is known to the bot. The method is analogous to the method [forwardMessage](https://core.telegram.org/bots/api#forwardmessage), but the copied message doesn't have a link to the original message. Returns the [MessageId](https://core.telegram.org/bots/api#messageid) of the sent message on success. */
47
+ copyMessage: BotApi.Method<'copyMessage'>
48
+ /** Use this method to copy messages of any kind. If some of the specified messages can't be found or copied, they are skipped. Service messages, paid media messages, giveaway messages, giveaway winners messages, and invoice messages can't be copied. A quiz [poll](https://core.telegram.org/bots/api#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](https://core.telegram.org/bots/api#forwardmessages), but the copied messages don't have a link to the original message. Album grouping is kept for copied messages. On success, an array of [MessageId](https://core.telegram.org/bots/api#messageid) of the sent messages is returned. */
49
+ copyMessages: BotApi.Method<'copyMessages'>
50
+ /** Use this method to send photos. On success, the sent [Message](https://core.telegram.org/bots/api#message) is returned. */
51
+ sendPhoto: BotApi.Method<'sendPhoto'>
52
+ /**
53
+ * Use this method to send audio files, if you want Telegram clients to display them in the music player. Your audio must be in the .MP3 or .M4A format. On success, the sent [Message](https://core.telegram.org/bots/api#message) is returned. Bots can currently send audio files of up to 50 MB in size, this limit may be changed in the future.
54
+ *
55
+ * For sending voice messages, use the [sendVoice](https://core.telegram.org/bots/api#sendvoice) method instead.
56
+ */
57
+ sendAudio: BotApi.Method<'sendAudio'>
58
+ /** Use this method to send general files. On success, the sent [Message](https://core.telegram.org/bots/api#message) is returned. Bots can currently send files of any type of up to 50 MB in size, this limit may be changed in the future. */
59
+ sendDocument: BotApi.Method<'sendDocument'>
60
+ /** Use this method to send video files, Telegram clients support MPEG4 videos (other formats may be sent as [Document](https://core.telegram.org/bots/api#document)). On success, the sent [Message](https://core.telegram.org/bots/api#message) is returned. Bots can currently send video files of up to 50 MB in size, this limit may be changed in the future. */
61
+ sendVideo: BotApi.Method<'sendVideo'>
62
+ /** Use this method to send animation files (GIF or H.264/MPEG-4 AVC video without sound). On success, the sent [Message](https://core.telegram.org/bots/api#message) is returned. Bots can currently send animation files of up to 50 MB in size, this limit may be changed in the future. */
63
+ sendAnimation: BotApi.Method<'sendAnimation'>
64
+ /** Use this method to send audio files, if you want Telegram clients to display the file as a playable voice message. For this to work, your audio must be in an .OGG file encoded with OPUS, or in .MP3 format, or in .M4A format (other formats may be sent as [Audio](https://core.telegram.org/bots/api#audio) or [Document](https://core.telegram.org/bots/api#document)). On success, the sent [Message](https://core.telegram.org/bots/api#message) is returned. Bots can currently send voice messages of up to 50 MB in size, this limit may be changed in the future. */
65
+ sendVoice: BotApi.Method<'sendVoice'>
66
+ /** As of [v.4.0](https://telegram.org/blog/video-messages-and-telescope), Telegram clients support rounded square MPEG4 videos of up to 1 minute long. Use this method to send video messages. On success, the sent [Message](https://core.telegram.org/bots/api#message) is returned. */
67
+ sendVideoNote: BotApi.Method<'sendVideoNote'>
68
+ /** Use this method to send paid media. On success, the sent [Message](https://core.telegram.org/bots/api#message) is returned. */
69
+ sendPaidMedia: BotApi.Method<'sendPaidMedia'>
70
+ /** Use this method to send a group of photos, videos, documents or audios as an album. Documents and audio files can be only grouped in an album with messages of the same type. On success, an array of [Message](https://core.telegram.org/bots/api#message) objects that were sent is returned. */
71
+ sendMediaGroup: BotApi.Method<'sendMediaGroup'>
72
+ /** Use this method to send point on the map. On success, the sent [Message](https://core.telegram.org/bots/api#message) is returned. */
73
+ sendLocation: BotApi.Method<'sendLocation'>
74
+ /** Use this method to send information about a venue. On success, the sent [Message](https://core.telegram.org/bots/api#message) is returned. */
75
+ sendVenue: BotApi.Method<'sendVenue'>
76
+ /** Use this method to send phone contacts. On success, the sent [Message](https://core.telegram.org/bots/api#message) is returned. */
77
+ sendContact: BotApi.Method<'sendContact'>
78
+ /** Use this method to send a native poll. On success, the sent [Message](https://core.telegram.org/bots/api#message) is returned. */
79
+ sendPoll: BotApi.Method<'sendPoll'>
80
+ /** Use this method to send a checklist on behalf of a connected business account. On success, the sent [Message](https://core.telegram.org/bots/api#message) is returned. */
81
+ sendChecklist: BotApi.Method<'sendChecklist'>
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
+ sendDice: BotApi.Method<'sendDice'>
84
+ /**
85
+ * 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
+ *
87
+ * > Example: The [ImageBot](https://t.me/imagebot) needs some time to process a request and upload the image. Instead of sending a text message along the lines of “Retrieving image, please wait…”, the bot may use [sendChatAction](https://core.telegram.org/bots/api#sendchataction) with _action_ = _upload\_photo_. The user will see a “sending photo” status for the bot.
88
+ *
89
+ * We only recommend using this method when a response from the bot will take a **noticeable** amount of time to arrive.
90
+ */
91
+ sendChatAction: BotApi.Method<'sendChatAction'>
92
+ /** Use this method to change the chosen reactions on a message. Service messages of some types can't be reacted to. Automatically forwarded messages from a channel to its discussion group have the same available reactions as messages in the channel. Bots can't use paid reactions. Returns _True_ on success. */
93
+ setMessageReaction: BotApi.Method<'setMessageReaction'>
94
+ /** Use this method to get a list of profile pictures for a user. Returns a [UserProfilePhotos](https://core.telegram.org/bots/api#userprofilephotos) object. */
95
+ getUserProfilePhotos: BotApi.Method<'getUserProfilePhotos'>
96
+ /** Changes the emoji status for a given user that previously allowed the bot to manage their emoji status via the Mini App method [requestEmojiStatusAccess](https://core.telegram.org/bots/webapps#initializing-mini-apps). Returns _True_ on success. */
97
+ setUserEmojiStatus: BotApi.Method<'setUserEmojiStatus'>
98
+ /**
99
+ * Use this method to get basic information about a file and prepare it for downloading. For the moment, bots can download files of up to 20MB in size. On success, a [File](https://core.telegram.org/bots/api#file) object is returned. The file can then be downloaded via the link `https://api.telegram.org/file/bot<token>/<file_path>`, where `<file_path>` is taken from the response. It is guaranteed that the link will be valid for at least 1 hour. When the link expires, a new one can be requested by calling [getFile](https://core.telegram.org/bots/api#getfile) again.
100
+ *
101
+ * **Note:** This function may not preserve the original file name and MIME type. You should save the file's MIME type and name (if available) when the File object is received.
102
+ */
103
+ getFile: BotApi.Method<'getFile'>
104
+ /** Use this method to ban a user in a group, a supergroup or a channel. In the case of supergroups and channels, the user will not be able to return to the chat on their own using invite links, etc., unless [unbanned](https://core.telegram.org/bots/api#unbanchatmember) first. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns _True_ on success. */
105
+ banChatMember: BotApi.Method<'banChatMember'>
106
+ /** Use this method to unban a previously banned user in a supergroup or channel. The user will **not** return to the group or channel automatically, but will be able to join via link, etc. The bot must be an administrator for this to work. By default, this method guarantees that after the call the user is not a member of the chat, but will be able to join it. So if the user is a member of the chat they will also be **removed** from the chat. If you don't want this, use the parameter _only\_if\_banned_. Returns _True_ on success. */
107
+ unbanChatMember: BotApi.Method<'unbanChatMember'>
108
+ /** Use this method to restrict a user in a supergroup. The bot must be an administrator in the supergroup for this to work and must have the appropriate administrator rights. Pass _True_ for all permissions to lift restrictions from a user. Returns _True_ on success. */
109
+ restrictChatMember: BotApi.Method<'restrictChatMember'>
110
+ /** Use this method to promote or demote a user in a supergroup or a channel. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Pass _False_ for all boolean parameters to demote a user. Returns _True_ on success. */
111
+ promoteChatMember: BotApi.Method<'promoteChatMember'>
112
+ /** Use this method to set a custom title for an administrator in a supergroup promoted by the bot. Returns _True_ on success. */
113
+ setChatAdministratorCustomTitle: BotApi.Method<'setChatAdministratorCustomTitle'>
114
+ /** Use this method to ban a channel chat in a supergroup or a channel. Until the chat is [unbanned](https://core.telegram.org/bots/api#unbanchatsenderchat), the owner of the banned chat won't be able to send messages on behalf of **any of their channels**. The bot must be an administrator in the supergroup or channel for this to work and must have the appropriate administrator rights. Returns _True_ on success. */
115
+ banChatSenderChat: BotApi.Method<'banChatSenderChat'>
116
+ /** Use this method to unban a previously banned channel chat in a supergroup or channel. The bot must be an administrator for this to work and must have the appropriate administrator rights. Returns _True_ on success. */
117
+ unbanChatSenderChat: BotApi.Method<'unbanChatSenderChat'>
118
+ /** Use this method to set default chat permissions for all members. The bot must be an administrator in the group or a supergroup for this to work and must have the _can\_restrict\_members_ administrator rights. Returns _True_ on success. */
119
+ setChatPermissions: BotApi.Method<'setChatPermissions'>
120
+ /**
121
+ * Use this method to generate a new primary invite link for a chat; any previously generated primary link is revoked. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns the new invite link as _String_ on success.
122
+ *
123
+ * > Note: Each administrator in a chat generates their own invite links. Bots can't use invite links generated by other administrators. If you want your bot to work with invite links, it will need to generate its own link using [exportChatInviteLink](https://core.telegram.org/bots/api#exportchatinvitelink) or by calling the [getChat](https://core.telegram.org/bots/api#getchat) method. If your bot needs to generate a new primary invite link replacing its previous one, use [exportChatInviteLink](https://core.telegram.org/bots/api#exportchatinvitelink) again.
124
+ */
125
+ exportChatInviteLink: BotApi.Method<'exportChatInviteLink'>
126
+ /** Use this method to create an additional invite link for a chat. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. The link can be revoked using the method [revokeChatInviteLink](https://core.telegram.org/bots/api#revokechatinvitelink). Returns the new invite link as [ChatInviteLink](https://core.telegram.org/bots/api#chatinvitelink) object. */
127
+ createChatInviteLink: BotApi.Method<'createChatInviteLink'>
128
+ /** Use this method to edit a non-primary invite link created by the bot. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns the edited invite link as a [ChatInviteLink](https://core.telegram.org/bots/api#chatinvitelink) object. */
129
+ editChatInviteLink: BotApi.Method<'editChatInviteLink'>
130
+ /** Use this method to create a [subscription invite link](https://telegram.org/blog/superchannels-star-reactions-subscriptions#star-subscriptions) for a channel chat. The bot must have the _can\_invite\_users_ administrator rights. The link can be edited using the method [editChatSubscriptionInviteLink](https://core.telegram.org/bots/api#editchatsubscriptioninvitelink) or revoked using the method [revokeChatInviteLink](https://core.telegram.org/bots/api#revokechatinvitelink). Returns the new invite link as a [ChatInviteLink](https://core.telegram.org/bots/api#chatinvitelink) object. */
131
+ createChatSubscriptionInviteLink: BotApi.Method<'createChatSubscriptionInviteLink'>
132
+ /** Use this method to edit a subscription invite link created by the bot. The bot must have the _can\_invite\_users_ administrator rights. Returns the edited invite link as a [ChatInviteLink](https://core.telegram.org/bots/api#chatinvitelink) object. */
133
+ editChatSubscriptionInviteLink: BotApi.Method<'editChatSubscriptionInviteLink'>
134
+ /** Use this method to revoke an invite link created by the bot. If the primary link is revoked, a new link is automatically generated. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns the revoked invite link as [ChatInviteLink](https://core.telegram.org/bots/api#chatinvitelink) object. */
135
+ revokeChatInviteLink: BotApi.Method<'revokeChatInviteLink'>
136
+ /** Use this method to approve a chat join request. The bot must be an administrator in the chat for this to work and must have the _can\_invite\_users_ administrator right. Returns _True_ on success. */
137
+ approveChatJoinRequest: BotApi.Method<'approveChatJoinRequest'>
138
+ /** Use this method to decline a chat join request. The bot must be an administrator in the chat for this to work and must have the _can\_invite\_users_ administrator right. Returns _True_ on success. */
139
+ declineChatJoinRequest: BotApi.Method<'declineChatJoinRequest'>
140
+ /** Use this method to set a new profile photo for the chat. Photos can't be changed for private chats. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns _True_ on success. */
141
+ setChatPhoto: BotApi.Method<'setChatPhoto'>
142
+ /** Use this method to delete a chat photo. Photos can't be changed for private chats. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns _True_ on success. */
143
+ deleteChatPhoto: BotApi.Method<'deleteChatPhoto'>
144
+ /** Use this method to change the title of a chat. Titles can't be changed for private chats. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns _True_ on success. */
145
+ setChatTitle: BotApi.Method<'setChatTitle'>
146
+ /** Use this method to change the description of a group, a supergroup or a channel. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns _True_ on success. */
147
+ setChatDescription: BotApi.Method<'setChatDescription'>
148
+ /** Use this method to add a message to the list of pinned messages in a chat. In private chats and channel direct messages chats, all non-service messages can be pinned. Conversely, the bot must be an administrator with the 'can\_pin\_messages' right or the 'can\_edit\_messages' right to pin messages in groups and channels respectively. Returns _True_ on success. */
149
+ pinChatMessage: BotApi.Method<'pinChatMessage'>
150
+ /** Use this method to remove a message from the list of pinned messages in a chat. In private chats and channel direct messages chats, all messages can be unpinned. Conversely, the bot must be an administrator with the 'can\_pin\_messages' right or the 'can\_edit\_messages' right to unpin messages in groups and channels respectively. Returns _True_ on success. */
151
+ unpinChatMessage: BotApi.Method<'unpinChatMessage'>
152
+ /** Use this method to clear the list of pinned messages in a chat. In private chats and channel direct messages chats, no additional rights are required to unpin all pinned messages. Conversely, the bot must be an administrator with the 'can\_pin\_messages' right or the 'can\_edit\_messages' right to unpin all pinned messages in groups and channels respectively. Returns _True_ on success. */
153
+ unpinAllChatMessages: BotApi.Method<'unpinAllChatMessages'>
154
+ /** Use this method for your bot to leave a group, supergroup or channel. Returns _True_ on success. */
155
+ leaveChat: BotApi.Method<'leaveChat'>
156
+ /** Use this method to get up-to-date information about the chat. Returns a [ChatFullInfo](https://core.telegram.org/bots/api#chatfullinfo) object on success. */
157
+ getChat: BotApi.Method<'getChat'>
158
+ /** Use this method to get a list of administrators in a chat, which aren't bots. Returns an Array of [ChatMember](https://core.telegram.org/bots/api#chatmember) objects. */
159
+ getChatAdministrators: BotApi.Method<'getChatAdministrators'>
160
+ /** Use this method to get the number of members in a chat. Returns _Int_ on success. */
161
+ getChatMemberCount: BotApi.Method<'getChatMemberCount'>
162
+ /** Use this method to get information about a member of a chat. The method is only guaranteed to work for other users if the bot is an administrator in the chat. Returns a [ChatMember](https://core.telegram.org/bots/api#chatmember) object on success. */
163
+ getChatMember: BotApi.Method<'getChatMember'>
164
+ /** Use this method to set a new group sticker set for a supergroup. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Use the field _can\_set\_sticker\_set_ optionally returned in [getChat](https://core.telegram.org/bots/api#getchat) requests to check if the bot can use this method. Returns _True_ on success. */
165
+ setChatStickerSet: BotApi.Method<'setChatStickerSet'>
166
+ /** Use this method to delete a group sticker set from a supergroup. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Use the field _can\_set\_sticker\_set_ optionally returned in [getChat](https://core.telegram.org/bots/api#getchat) requests to check if the bot can use this method. Returns _True_ on success. */
167
+ deleteChatStickerSet: BotApi.Method<'deleteChatStickerSet'>
168
+ /** Use this method to get custom emoji stickers, which can be used as a forum topic icon by any user. Requires no parameters. Returns an Array of [Sticker](https://core.telegram.org/bots/api#sticker) objects. */
169
+ getForumTopicIconStickers: BotApi.Method<'getForumTopicIconStickers'>
170
+ /** 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
+ 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. */
173
+ editForumTopic: BotApi.Method<'editForumTopic'>
174
+ /** 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
+ closeForumTopic: BotApi.Method<'closeForumTopic'>
176
+ /** 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
+ 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. */
179
+ 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. */
181
+ unpinAllForumTopicMessages: BotApi.Method<'unpinAllForumTopicMessages'>
182
+ /** 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
+ editGeneralForumTopic: BotApi.Method<'editGeneralForumTopic'>
184
+ /** Use this method to close an open 'General' topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the _can\_manage\_topics_ administrator rights. Returns _True_ on success. */
185
+ closeGeneralForumTopic: BotApi.Method<'closeGeneralForumTopic'>
186
+ /** Use this method to reopen a closed 'General' topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the _can\_manage\_topics_ administrator rights. The topic will be automatically unhidden if it was hidden. Returns _True_ on success. */
187
+ reopenGeneralForumTopic: BotApi.Method<'reopenGeneralForumTopic'>
188
+ /** Use this method to hide the 'General' topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the _can\_manage\_topics_ administrator rights. The topic will be automatically closed if it was open. Returns _True_ on success. */
189
+ hideGeneralForumTopic: BotApi.Method<'hideGeneralForumTopic'>
190
+ /** Use this method to unhide the 'General' topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the _can\_manage\_topics_ administrator rights. Returns _True_ on success. */
191
+ unhideGeneralForumTopic: BotApi.Method<'unhideGeneralForumTopic'>
192
+ /** Use this method to clear the list of pinned messages in a General forum topic. The bot must be an administrator in the chat for this to work and must have the _can\_pin\_messages_ administrator right in the supergroup. Returns _True_ on success. */
193
+ unpinAllGeneralForumTopicMessages: BotApi.Method<'unpinAllGeneralForumTopicMessages'>
194
+ /**
195
+ * Use this method to send answers to callback queries sent from [inline keyboards](https://core.telegram.org/bots/features#inline-keyboards). The answer will be displayed to the user as a notification at the top of the chat screen or as an alert. On success, _True_ is returned.
196
+ *
197
+ * > Alternatively, the user can be redirected to the specified Game URL. For this option to work, you must first create a game for your bot via [@BotFather](https://t.me/botfather) and accept the terms. Otherwise, you may use links like `t.me/your_bot?start=XXXX` that open your bot with a parameter.
198
+ */
199
+ answerCallbackQuery: BotApi.Method<'answerCallbackQuery'>
200
+ /** 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](https://core.telegram.org/bots/api#userchatboosts) object. */
201
+ getUserChatBoosts: BotApi.Method<'getUserChatBoosts'>
202
+ /** Use this method to get information about the connection of the bot with a business account. Returns a [BusinessConnection](https://core.telegram.org/bots/api#businessconnection) object on success. */
203
+ getBusinessConnection: BotApi.Method<'getBusinessConnection'>
204
+ /** Use this method to change the list of the bot's commands. See [this manual](https://core.telegram.org/bots/features#commands) for more details about bot commands. Returns _True_ on success. */
205
+ setMyCommands: BotApi.Method<'setMyCommands'>
206
+ /** Use this method to delete the list of the bot's commands for the given scope and user language. After deletion, [higher level commands](https://core.telegram.org/bots/api#determining-list-of-commands) will be shown to affected users. Returns _True_ on success. */
207
+ deleteMyCommands: BotApi.Method<'deleteMyCommands'>
208
+ /** Use this method to get the current list of the bot's commands for the given scope and user language. Returns an Array of [BotCommand](https://core.telegram.org/bots/api#botcommand) objects. If commands aren't set, an empty list is returned. */
209
+ getMyCommands: BotApi.Method<'getMyCommands'>
210
+ /** Use this method to change the bot's name. Returns _True_ on success. */
211
+ setMyName: BotApi.Method<'setMyName'>
212
+ /** Use this method to get the current bot name for the given user language. Returns [BotName](https://core.telegram.org/bots/api#botname) on success. */
213
+ getMyName: BotApi.Method<'getMyName'>
214
+ /** Use this method to change the bot's description, which is shown in the chat with the bot if the chat is empty. Returns _True_ on success. */
215
+ setMyDescription: BotApi.Method<'setMyDescription'>
216
+ /** Use this method to get the current bot description for the given user language. Returns [BotDescription](https://core.telegram.org/bots/api#botdescription) on success. */
217
+ getMyDescription: BotApi.Method<'getMyDescription'>
218
+ /** 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. Returns _True_ on success. */
219
+ setMyShortDescription: BotApi.Method<'setMyShortDescription'>
220
+ /** Use this method to get the current bot short description for the given user language. Returns [BotShortDescription](https://core.telegram.org/bots/api#botshortdescription) on success. */
221
+ getMyShortDescription: BotApi.Method<'getMyShortDescription'>
222
+ /** Use this method to change the bot's menu button in a private chat, or the default menu button. Returns _True_ on success. */
223
+ setChatMenuButton: BotApi.Method<'setChatMenuButton'>
224
+ /** 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](https://core.telegram.org/bots/api#menubutton) on success. */
225
+ getChatMenuButton: BotApi.Method<'getChatMenuButton'>
226
+ /** Use this method to change the default administrator rights requested by the bot when it's added as an administrator to groups or channels. These rights will be suggested to users, but they are free to modify the list before adding the bot. Returns _True_ on success. */
227
+ setMyDefaultAdministratorRights: BotApi.Method<'setMyDefaultAdministratorRights'>
228
+ /** Use this method to get the current default administrator rights of the bot. Returns [ChatAdministratorRights](https://core.telegram.org/bots/api#chatadministratorrights) on success. */
229
+ getMyDefaultAdministratorRights: BotApi.Method<'getMyDefaultAdministratorRights'>
230
+ /** Returns the list of gifts that can be sent by the bot to users and channel chats. Requires no parameters. Returns a [Gifts](https://core.telegram.org/bots/api#gifts) object. */
231
+ getAvailableGifts: BotApi.Method<'getAvailableGifts'>
232
+ /** Sends a gift to the given user or channel chat. The gift can't be converted to Telegram Stars by the receiver. Returns _True_ on success. */
233
+ sendGift: BotApi.Method<'sendGift'>
234
+ /** Gifts a Telegram Premium subscription to the given user. Returns _True_ on success. */
235
+ giftPremiumSubscription: BotApi.Method<'giftPremiumSubscription'>
236
+ /** Verifies a user [on behalf of the organization](https://telegram.org/verify#third-party-verification) which is represented by the bot. Returns _True_ on success. */
237
+ verifyUser: BotApi.Method<'verifyUser'>
238
+ /** Verifies a chat [on behalf of the organization](https://telegram.org/verify#third-party-verification) which is represented by the bot. Returns _True_ on success. */
239
+ verifyChat: BotApi.Method<'verifyChat'>
240
+ /** Removes verification from a user who is currently verified [on behalf of the organization](https://telegram.org/verify#third-party-verification) represented by the bot. Returns _True_ on success. */
241
+ removeUserVerification: BotApi.Method<'removeUserVerification'>
242
+ /** Removes verification from a chat that is currently verified [on behalf of the organization](https://telegram.org/verify#third-party-verification) represented by the bot. Returns _True_ on success. */
243
+ removeChatVerification: BotApi.Method<'removeChatVerification'>
244
+ /** Marks incoming message as read on behalf of a business account. Requires the _can\_read\_messages_ business bot right. Returns _True_ on success. */
245
+ readBusinessMessage: BotApi.Method<'readBusinessMessage'>
246
+ /** Delete messages on behalf of a business account. Requires the _can\_delete\_sent\_messages_ business bot right to delete messages sent by the bot itself, or the _can\_delete\_all\_messages_ business bot right to delete any message. Returns _True_ on success. */
247
+ deleteBusinessMessages: BotApi.Method<'deleteBusinessMessages'>
248
+ /** Changes the first and last name of a managed business account. Requires the _can\_change\_name_ business bot right. Returns _True_ on success. */
249
+ setBusinessAccountName: BotApi.Method<'setBusinessAccountName'>
250
+ /** Changes the username of a managed business account. Requires the _can\_change\_username_ business bot right. Returns _True_ on success. */
251
+ setBusinessAccountUsername: BotApi.Method<'setBusinessAccountUsername'>
252
+ /** Changes the bio of a managed business account. Requires the _can\_change\_bio_ business bot right. Returns _True_ on success. */
253
+ setBusinessAccountBio: BotApi.Method<'setBusinessAccountBio'>
254
+ /** Changes the profile photo of a managed business account. Requires the _can\_edit\_profile\_photo_ business bot right. Returns _True_ on success. */
255
+ setBusinessAccountProfilePhoto: BotApi.Method<'setBusinessAccountProfilePhoto'>
256
+ /** Removes the current profile photo of a managed business account. Requires the _can\_edit\_profile\_photo_ business bot right. Returns _True_ on success. */
257
+ removeBusinessAccountProfilePhoto: BotApi.Method<'removeBusinessAccountProfilePhoto'>
258
+ /** Changes the privacy settings pertaining to incoming gifts in a managed business account. Requires the _can\_change\_gift\_settings_ business bot right. Returns _True_ on success. */
259
+ setBusinessAccountGiftSettings: BotApi.Method<'setBusinessAccountGiftSettings'>
260
+ /** Returns the amount of Telegram Stars owned by a managed business account. Requires the _can\_view\_gifts\_and\_stars_ business bot right. Returns [StarAmount](https://core.telegram.org/bots/api#staramount) on success. */
261
+ getBusinessAccountStarBalance: BotApi.Method<'getBusinessAccountStarBalance'>
262
+ /** Transfers Telegram Stars from the business account balance to the bot's balance. Requires the _can\_transfer\_stars_ business bot right. Returns _True_ on success. */
263
+ transferBusinessAccountStars: BotApi.Method<'transferBusinessAccountStars'>
264
+ /** 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
+ getBusinessAccountGifts: BotApi.Method<'getBusinessAccountGifts'>
266
+ /** Converts a given regular gift to Telegram Stars. Requires the _can\_convert\_gifts\_to\_stars_ business bot right. Returns _True_ on success. */
267
+ convertGiftToStars: BotApi.Method<'convertGiftToStars'>
268
+ /** 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. */
269
+ upgradeGift: BotApi.Method<'upgradeGift'>
270
+ /** Transfers an owned unique gift to another user. Requires the _can\_transfer\_and\_upgrade\_gifts_ business bot right. Requires _can\_transfer\_stars_ business bot right if the transfer is paid. Returns _True_ on success. */
271
+ transferGift: BotApi.Method<'transferGift'>
272
+ /** 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
+ postStory: BotApi.Method<'postStory'>
274
+ /** 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
+ editStory: BotApi.Method<'editStory'>
276
+ /** 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. */
277
+ deleteStory: BotApi.Method<'deleteStory'>
278
+ /** Use this method to edit text and [game](https://core.telegram.org/bots/api#games) messages. On success, if the edited message is not an inline message, the edited [Message](https://core.telegram.org/bots/api#message) is returned, otherwise _True_ is returned. Note that business messages that were not sent by the bot and do not contain an inline keyboard can only be edited within **48 hours** from the time they were sent. */
279
+ editMessageText: BotApi.Method<'editMessageText'>
280
+ /** Use this method to edit captions of messages. On success, if the edited message is not an inline message, the edited [Message](https://core.telegram.org/bots/api#message) is returned, otherwise _True_ is returned. Note that business messages that were not sent by the bot and do not contain an inline keyboard can only be edited within **48 hours** from the time they were sent. */
281
+ editMessageCaption: BotApi.Method<'editMessageCaption'>
282
+ /** Use this method to edit animation, audio, document, photo, or video messages, or to add media to text messages. If a message is part of a message album, then it can be edited only to an audio for audio albums, only to a document for document albums and to a photo or a video otherwise. When an inline message is edited, a new file can't be uploaded; use a previously uploaded file via its file\_id or specify a URL. On success, if the edited message is not an inline message, the edited [Message](https://core.telegram.org/bots/api#message) is returned, otherwise _True_ is returned. Note that business messages that were not sent by the bot and do not contain an inline keyboard can only be edited within **48 hours** from the time they were sent. */
283
+ editMessageMedia: BotApi.Method<'editMessageMedia'>
284
+ /** Use this method to edit live location messages. A location can be edited until its _live\_period_ expires or editing is explicitly disabled by a call to [stopMessageLiveLocation](https://core.telegram.org/bots/api#stopmessagelivelocation). On success, if the edited message is not an inline message, the edited [Message](https://core.telegram.org/bots/api#message) is returned, otherwise _True_ is returned. */
285
+ editMessageLiveLocation: BotApi.Method<'editMessageLiveLocation'>
286
+ /** Use this method to stop updating a live location message before _live\_period_ expires. On success, if the message is not an inline message, the edited [Message](https://core.telegram.org/bots/api#message) is returned, otherwise _True_ is returned. */
287
+ stopMessageLiveLocation: BotApi.Method<'stopMessageLiveLocation'>
288
+ /** Use this method to edit a checklist on behalf of a connected business account. On success, the edited [Message](https://core.telegram.org/bots/api#message) is returned. */
289
+ editMessageChecklist: BotApi.Method<'editMessageChecklist'>
290
+ /** Use this method to edit only the reply markup of messages. On success, if the edited message is not an inline message, the edited [Message](https://core.telegram.org/bots/api#message) is returned, otherwise _True_ is returned. Note that business messages that were not sent by the bot and do not contain an inline keyboard can only be edited within **48 hours** from the time they were sent. */
291
+ editMessageReplyMarkup: BotApi.Method<'editMessageReplyMarkup'>
292
+ /** Use this method to stop a poll which was sent by the bot. On success, the stopped [Poll](https://core.telegram.org/bots/api#poll) is returned. */
293
+ stopPoll: BotApi.Method<'stopPoll'>
294
+ /** Use this method to approve a suggested post in a direct messages chat. The bot must have the 'can\_post\_messages' administrator right in the corresponding channel chat. Returns _True_ on success. */
295
+ approveSuggestedPost: BotApi.Method<'approveSuggestedPost'>
296
+ /** Use this method to decline a suggested post in a direct messages chat. The bot must have the 'can\_manage\_direct\_messages' administrator right in the corresponding channel chat. Returns _True_ on success. */
297
+ declineSuggestedPost: BotApi.Method<'declineSuggestedPost'>
298
+ /**
299
+ * Use this method to delete a message, including service messages, with the following limitations:
300
+ *
301
+ * \- A message can only be deleted if it was sent less than 48 hours ago.
302
+ *
303
+ * \- Service messages about a supergroup, channel, or forum topic creation can't be deleted.
304
+ *
305
+ * \- A dice message in a private chat can only be deleted if it was sent more than 24 hours ago.
306
+ *
307
+ * \- Bots can delete outgoing messages in private chats, groups, and supergroups.
308
+ *
309
+ * \- Bots can delete incoming messages in private chats.
310
+ *
311
+ * \- Bots granted _can\_post\_messages_ permissions can delete outgoing messages in channels.
312
+ *
313
+ * \- If the bot is an administrator of a group, it can delete any message there.
314
+ *
315
+ * \- If the bot has _can\_delete\_messages_ administrator right in a supergroup or a channel, it can delete any message there.
316
+ *
317
+ * \- If the bot has _can\_manage\_direct\_messages_ administrator right in a channel, it can delete any message in the corresponding direct messages chat.
318
+ *
319
+ * Returns _True_ on success.
320
+ */
321
+ deleteMessage: BotApi.Method<'deleteMessage'>
322
+ /** Use this method to delete multiple messages simultaneously. If some of the specified messages can't be found, they are skipped. Returns _True_ on success. */
323
+ deleteMessages: BotApi.Method<'deleteMessages'>
324
+ /** Use this method to send static .WEBP, [animated](https://telegram.org/blog/animated-stickers) .TGS, or [video](https://telegram.org/blog/video-stickers-better-reactions) .WEBM stickers. On success, the sent [Message](https://core.telegram.org/bots/api#message) is returned. */
325
+ sendSticker: BotApi.Method<'sendSticker'>
326
+ /** Use this method to get a sticker set. On success, a [StickerSet](https://core.telegram.org/bots/api#stickerset) object is returned. */
327
+ getStickerSet: BotApi.Method<'getStickerSet'>
328
+ /** Use this method to get information about custom emoji stickers by their identifiers. Returns an Array of [Sticker](https://core.telegram.org/bots/api#sticker) objects. */
329
+ getCustomEmojiStickers: BotApi.Method<'getCustomEmojiStickers'>
330
+ /** Use this method to upload a file with a sticker for later use in the [createNewStickerSet](https://core.telegram.org/bots/api#createnewstickerset), [addStickerToSet](https://core.telegram.org/bots/api#addstickertoset), or [replaceStickerInSet](https://core.telegram.org/bots/api#replacestickerinset) methods (the file can be used multiple times). Returns the uploaded [File](https://core.telegram.org/bots/api#file) on success. */
331
+ uploadStickerFile: BotApi.Method<'uploadStickerFile'>
332
+ /** Use this method to create a new sticker set owned by a user. The bot will be able to edit the sticker set thus created. Returns _True_ on success. */
333
+ createNewStickerSet: BotApi.Method<'createNewStickerSet'>
334
+ /** Use this method to add a new sticker to a set created by the bot. Emoji sticker sets can have up to 200 stickers. Other sticker sets can have up to 120 stickers. Returns _True_ on success. */
335
+ addStickerToSet: BotApi.Method<'addStickerToSet'>
336
+ /** Use this method to move a sticker in a set created by the bot to a specific position. Returns _True_ on success. */
337
+ setStickerPositionInSet: BotApi.Method<'setStickerPositionInSet'>
338
+ /** Use this method to delete a sticker from a set created by the bot. Returns _True_ on success. */
339
+ deleteStickerFromSet: BotApi.Method<'deleteStickerFromSet'>
340
+ /** Use this method to replace an existing sticker in a sticker set with a new one. The method is equivalent to calling [deleteStickerFromSet](https://core.telegram.org/bots/api#deletestickerfromset), then [addStickerToSet](https://core.telegram.org/bots/api#addstickertoset), then [setStickerPositionInSet](https://core.telegram.org/bots/api#setstickerpositioninset). Returns _True_ on success. */
341
+ replaceStickerInSet: BotApi.Method<'replaceStickerInSet'>
342
+ /** Use this method to change the list of emoji assigned to a regular or custom emoji sticker. The sticker must belong to a sticker set created by the bot. Returns _True_ on success. */
343
+ setStickerEmojiList: BotApi.Method<'setStickerEmojiList'>
344
+ /** Use this method to change search keywords assigned to a regular or custom emoji sticker. The sticker must belong to a sticker set created by the bot. Returns _True_ on success. */
345
+ setStickerKeywords: BotApi.Method<'setStickerKeywords'>
346
+ /** Use this method to change the [mask position](https://core.telegram.org/bots/api#maskposition) of a mask sticker. The sticker must belong to a sticker set that was created by the bot. Returns _True_ on success. */
347
+ setStickerMaskPosition: BotApi.Method<'setStickerMaskPosition'>
348
+ /** Use this method to set the title of a created sticker set. Returns _True_ on success. */
349
+ setStickerSetTitle: BotApi.Method<'setStickerSetTitle'>
350
+ /** Use this method to set the thumbnail of a regular or mask sticker set. The format of the thumbnail file must match the format of the stickers in the set. Returns _True_ on success. */
351
+ setStickerSetThumbnail: BotApi.Method<'setStickerSetThumbnail'>
352
+ /** Use this method to set the thumbnail of a custom emoji sticker set. Returns _True_ on success. */
353
+ setCustomEmojiStickerSetThumbnail: BotApi.Method<'setCustomEmojiStickerSetThumbnail'>
354
+ /** Use this method to delete a sticker set that was created by the bot. Returns _True_ on success. */
355
+ deleteStickerSet: BotApi.Method<'deleteStickerSet'>
356
+ /**
357
+ * Use this method to send answers to an inline query. On success, _True_ is returned.
358
+ *
359
+ * No more than **50** results per query are allowed.
360
+ */
361
+ answerInlineQuery: BotApi.Method<'answerInlineQuery'>
362
+ /** Use this method to set the result of an interaction with a [Web App](https://core.telegram.org/bots/webapps) and send a corresponding message on behalf of the user to the chat from which the query originated. On success, a [SentWebAppMessage](https://core.telegram.org/bots/api#sentwebappmessage) object is returned. */
363
+ answerWebAppQuery: BotApi.Method<'answerWebAppQuery'>
364
+ /** Stores a message that can be sent by a user of a Mini App. Returns a [PreparedInlineMessage](https://core.telegram.org/bots/api#preparedinlinemessage) object. */
365
+ savePreparedInlineMessage: BotApi.Method<'savePreparedInlineMessage'>
366
+ /** Use this method to send invoices. On success, the sent [Message](https://core.telegram.org/bots/api#message) is returned. */
367
+ sendInvoice: BotApi.Method<'sendInvoice'>
368
+ /** Use this method to create a link for an invoice. Returns the created invoice link as _String_ on success. */
369
+ createInvoiceLink: BotApi.Method<'createInvoiceLink'>
370
+ /** If you sent an invoice requesting a shipping address and the parameter _is\_flexible_ was specified, the Bot API will send an [Update](https://core.telegram.org/bots/api#update) with a _shipping\_query_ field to the bot. Use this method to reply to shipping queries. On success, _True_ is returned. */
371
+ answerShippingQuery: BotApi.Method<'answerShippingQuery'>
372
+ /** Once the user has confirmed their payment and shipping details, the Bot API sends the final confirmation in the form of an [Update](https://core.telegram.org/bots/api#update) with the field _pre\_checkout\_query_. Use this method to respond to such pre-checkout queries. On success, _True_ is returned. **Note:** The Bot API must receive an answer within 10 seconds after the pre-checkout query was sent. */
373
+ answerPreCheckoutQuery: BotApi.Method<'answerPreCheckoutQuery'>
374
+ /** A method to get the current Telegram Stars balance of the bot. Requires no parameters. On success, returns a [StarAmount](https://core.telegram.org/bots/api#staramount) object. */
375
+ getMyStarBalance: BotApi.Method<'getMyStarBalance'>
376
+ /** Returns the bot's Telegram Star transactions in chronological order. On success, returns a [StarTransactions](https://core.telegram.org/bots/api#startransactions) object. */
377
+ getStarTransactions: BotApi.Method<'getStarTransactions'>
378
+ /** Refunds a successful payment in [Telegram Stars](https://t.me/BotNews/90). Returns _True_ on success. */
379
+ refundStarPayment: BotApi.Method<'refundStarPayment'>
380
+ /** Allows the bot to cancel or re-enable extension of a subscription paid in Telegram Stars. Returns _True_ on success. */
381
+ editUserStarSubscription: BotApi.Method<'editUserStarSubscription'>
382
+ /**
383
+ * Informs a user that some of the Telegram Passport elements they provided contains errors. The user will not be able to re-submit their Passport to you until the errors are fixed (the contents of the field for which you returned the error must change). Returns _True_ on success.
384
+ *
385
+ * Use this if the data submitted by the user doesn't satisfy the standards your service requires for any reason. For example, if a birthday date seems invalid, a submitted document is blurry, a scan shows evidence of tampering, etc. Supply some details in the error message to make sure the user knows how to correct the issues.
386
+ */
387
+ setPassportDataErrors: BotApi.Method<'setPassportDataErrors'>
388
+ /** Use this method to send a game. On success, the sent [Message](https://core.telegram.org/bots/api#message) is returned. */
389
+ sendGame: BotApi.Method<'sendGame'>
390
+ /** Use this method to set the score of the specified user in a game message. On success, if the message is not an inline message, the [Message](https://core.telegram.org/bots/api#message) is returned, otherwise _True_ is returned. Returns an error, if the new score is not greater than the user's current score in the chat and _force_ is _False_. */
391
+ setGameScore: BotApi.Method<'setGameScore'>
392
+ /**
393
+ * Use this method to get data for high score tables. Will return the score of the specified user and several of their neighbors in a game. Returns an Array of [GameHighScore](https://core.telegram.org/bots/api#gamehighscore) objects.
394
+ *
395
+ * > This method will currently return scores for the target user, plus two of their closest neighbors on each side. Will also return the top three users if the user and their neighbors are not among them. Please note that this behavior is subject to change.
396
+ */
397
+ getGameHighScores: BotApi.Method<'getGameHighScores'>
398
+ }
@@ -0,0 +1,118 @@
1
+ import type * as HttpClient from '@effect/platform/HttpClient'
2
+ import type * as BotApiUrl from '../BotApiUrl.ts'
3
+ import * as HttpBody from '@effect/platform/HttpBody'
4
+ import * as Chunk from 'effect/Chunk'
5
+ import * as Effect from 'effect/Effect'
6
+ import * as Stream from 'effect/Stream'
7
+ import * as BotApiTransport from '../BotApiTransport.ts'
8
+ import * as File from '../File.ts'
9
+
10
+ interface ExtractedFile {
11
+ attachId: string
12
+ file: File.InputFile
13
+ }
14
+
15
+ /**
16
+ * Recursively checks whether a value contains {@linkcode File.InputFile} instances.
17
+ */
18
+ const hasInputFile = (value: unknown): boolean => {
19
+ if (value instanceof File.InputFile)
20
+ return true
21
+ if (Array.isArray(value))
22
+ return value.some(hasInputFile)
23
+ if (typeof value === 'object' && value !== null) {
24
+ return Object.values(value).some(hasInputFile)
25
+ }
26
+ return false
27
+ }
28
+
29
+ const cloneAndExtract = (
30
+ value: unknown,
31
+ files: ExtractedFile[],
32
+ ): unknown => {
33
+ if (value instanceof File.InputFile) {
34
+ const attachId = String(files.length + 1)
35
+ files.push({ attachId, file: value })
36
+ return `attach://${attachId}`
37
+ }
38
+ if (Array.isArray(value)) {
39
+ return value.map(item => cloneAndExtract(item, files))
40
+ }
41
+ if (typeof value === 'object' && value !== null) {
42
+ const result: Record<string, unknown> = {}
43
+ for (const [k, v] of Object.entries(value)) {
44
+ result[k] = cloneAndExtract(v, files)
45
+ }
46
+ return result
47
+ }
48
+ return value
49
+ }
50
+
51
+ /**
52
+ * Deep clones params, replacing {@linkcode InputFile} instances with
53
+ * `attach://{id}` strings and collecting them into the files array.
54
+ */
55
+ const extractFiles = (params: unknown): {
56
+ params: Record<string, unknown>
57
+ files: ExtractedFile[]
58
+ } => {
59
+ const files: ExtractedFile[] = []
60
+ const cloned = cloneAndExtract(params, files)
61
+ return { params: cloned as Record<string, unknown>, files }
62
+ }
63
+
64
+ /**
65
+ * Creates an HTTP body for a Bot API request from the given parameters.
66
+ *
67
+ * If the request contains no files to upload, body is serialized as JSON.
68
+ *
69
+ * If the request contains files to upload, body is serialized
70
+ * as `multipart/form-data`, according to the bot API docs and implementation.
71
+ * (credits to {@link https://github.com/grammyjs/grammY/blob/574019752feffae9d4dbe69c0f8f97fba1d06916/src/core/payload.ts grammY}).
72
+ *
73
+ * @see {@link https://core.telegram.org/bots/api#sending-files Bot API • Sending Files}
74
+ * @see {@link https://github.com/tdlib/telegram-bot-api/blob/3b6a0b769c4a7fbe064087a4ad9fe6b1dbda498f/telegram-bot-api/Client.cpp#L9339 telegram-bot-api • Client::get_input_file}
75
+ */
76
+ const makeHttpBody = Effect.fnUntraced(function* (params: unknown) {
77
+ // TODO: Short-circuit for methods that are known to not have files.
78
+ if (!hasInputFile(params)) {
79
+ return yield* HttpBody.json(params)
80
+ }
81
+ const { params: processedParams, files } = extractFiles(params)
82
+ const formData = new FormData()
83
+ for (const [key, value] of Object.entries(processedParams)) {
84
+ if (value == null)
85
+ continue
86
+ const serialized = typeof value === 'string' ? value : JSON.stringify(value)
87
+ formData.append(key, serialized)
88
+ }
89
+ // TODO: Support streamable multipart/form-data uploads.
90
+ // TODO: Make sure current implementation constructs blob efficiently.
91
+ for (const { attachId, file } of files) {
92
+ const chunks = yield* Stream.runCollect(file.stream)
93
+ const bytes = new Uint8Array(Chunk.toReadonlyArray(chunks).flatMap(chunk => [...chunk]))
94
+ const blob = new Blob([bytes], { type: file.mimeType ?? 'application/octet-stream' })
95
+ formData.append(attachId, blob, file.filename)
96
+ }
97
+ return HttpBody.formData(formData)
98
+ })
99
+
100
+ export const make = (
101
+ httpClient: HttpClient.HttpClient,
102
+ botApiUrl: BotApiUrl.BotApiUrl.Service,
103
+ ): BotApiTransport.BotApiTransport.Service => ({
104
+ sendRequest: (method, params) => (
105
+ Effect.gen(function* () {
106
+ const body = yield* makeHttpBody(params)
107
+ const response = yield* httpClient.post(botApiUrl.toMethod(method), { body })
108
+ const responseJson = yield* response.json
109
+ // We trust Bot API and don't want to introduce overhead with validation.
110
+ return responseJson as BotApiTransport.BotApiResponse
111
+ })
112
+ .pipe(
113
+ Effect.catchAll(cause => (
114
+ Effect.fail(new BotApiTransport.BotApiTransportError({ cause }))
115
+ )),
116
+ )
117
+ ),
118
+ })