diff --git a/CHANGELOG.md b/CHANGELOG.md index f33499b2..f421ae61 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # Changelog +# **4.15.0 - (2026-10-03)** + +## **Updates** + +- Support api `10.0`, `10.1`, `10.2`, `10.3` [cbfe29e](https://github.com/telegramsjs/TelegramsJS/commit/cbfe29e00bded859fab6519efe5b5c2ad06c2639), [000a3eb](https://github.com/telegramsjs/TelegramsJS/commit/000a3ebd1553e29aedf0fa337d7fec4beafcb77f), [2b22972](https://github.com/telegramsjs/TelegramsJS/commit/2b22972eff4c0d3bbca540753c5d0ac32ed31451), [5f107f6](https://github.com/telegramsjs/TelegramsJS/commit/5f107f6e518e52d59d026ca1e8e3868ca467c0da) + +--- + # **4.14.0 - (2026-06-06)** ## **Updates** diff --git a/README.md b/README.md index 8cb7e0ff..f1032183 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@

Telegramsjs



-[![Bot API](https://img.shields.io/badge/Bot%20API-v.9.6-00aced.svg?style=flat-square&logo=telegram)](https://core.telegram.org/bots/api) +[![Bot API](https://img.shields.io/badge/Bot%20API-v.10.3-00aced.svg?style=flat-square&logo=telegram)](https://core.telegram.org/bots/api) [![NPM Version](https://img.shields.io/npm/v/telegramsjs.svg?maxAge=3600)](https://www.npmjs.com/package/telegramsjs) [![NPM Downloads](https://img.shields.io/npm/dt/telegramsjs.svg?maxAge=3600)](https://www.npmjs.com/package/telegramsjs) diff --git a/docs/avatar.png b/docs/avatar.png index 59145d17..aad91fc3 100644 Binary files a/docs/avatar.png and b/docs/avatar.png differ diff --git a/docs/old_avatar.png b/docs/old_avatar.png new file mode 100644 index 00000000..59145d17 Binary files /dev/null and b/docs/old_avatar.png differ diff --git a/package.json b/package.json index 2a846e05..99e86dd9 100644 --- a/package.json +++ b/package.json @@ -1,12 +1,12 @@ { "name": "telegramsjs", "description": "A powerful library for interacting with the Telegram Bot API", - "version": "4.14.1", + "version": "4.15.0", "main": "./dist/src/index.js", "types": "./typings/index.d.ts", "scripts": { - "clear": "rm -rf dist/", - "prettier": "prettier --write src/ typings/", + "clear": "npx rimraf dist/", + "prettier": "npx prettier --write src/ typings/", "build:test": "npm run clear && tsc --project ./tsconfig.test.json", "build:release": "npm run prettier && npm run clear && tsc --project ./tsconfig.json" }, @@ -53,7 +53,6 @@ }, "homepage": "https://docs-telegramsjs.vercel.app/", "devDependencies": { - "@telegram.ts/types": "^1.28.1", "@types/node": "^18.19.130", "@types/node-fetch": "^2.6.11", "@types/safe-compare": "^1.1.2", @@ -65,6 +64,7 @@ "node-fetch": "^2.7.0", "safe-compare": "^1.1.4", "sandwich-stream": "^2.0.2", - "tslib": "^2.8.0" + "tslib": "^2.8.0", + "@telegram.ts/types": "^1.32.1" } } diff --git a/src/client/BaseClient.ts b/src/client/BaseClient.ts index 238d5151..9045531c 100644 --- a/src/client/BaseClient.ts +++ b/src/client/BaseClient.ts @@ -4,6 +4,7 @@ import { Collection } from "@telegram.ts/collection"; import { UserManager } from "../managers/UserManager"; import { ChatManager } from "../managers/ChatManager"; import type { LanguageCode } from "./interfaces/Language"; +import type { InlineQueryResult } from "./interfaces/Inline"; import type { MediaDataParam, InputProfilePhoto } from "./interfaces/Methods"; import type { ClientOptions, TelegramClient } from "./TelegramClient"; import { @@ -31,6 +32,7 @@ import { StarAmount, OwnedGifts, Story, + BotAccessSettings, } from "../structures/index"; import { ChatPermissions, @@ -80,6 +82,9 @@ interface EventHandlers { message: ( message: import("../structures/message/Message").Message, ) => PossiblyAsync; + guestMessage: ( + message: import("../structures/message/Message").Message, + ) => PossiblyAsync; channelPost: ( message: import("../structures/message/Message").Message, ) => PossiblyAsync; @@ -122,7 +127,9 @@ interface EventHandlers { preCheckoutQuery: ( checkoutQuery: import("../structures/PreCheckoutQuery").PreCheckoutQuery, ) => PossiblyAsync; - poll: (poll: import("../structures/media/Poll").Poll) => PossiblyAsync; + poll: ( + poll: import("../structures/media/poll/Poll").Poll, + ) => PossiblyAsync; pollAnswer: ( pollAnswer: import("../structures/PollAnswer").PollAnswer, ) => PossiblyAsync; @@ -159,6 +166,12 @@ interface EventHandlers { managedBotUpdated: ( managedBotUpdated: import("../structures/ManagedBotUpdated").ManagedBotUpdated, ) => PossiblyAsync; + subscription: ( + subscription: import("../structures/BotSubscriptionUpdated").BotSubscriptionUpdated, + ) => PossiblyAsync; + messageGenerationStopped: ( + messageGenerationStopped: import("../structures/MessageGenerationStopped").MessageGenerationStopped, + ) => PossiblyAsync; } type EventHandlerParameters = @@ -173,14 +186,16 @@ type EventHandlerParameters = | import("../structures/CallbackQuery").CallbackQuery | import("../structures/ShippingQuery").ShippingQuery | import("../structures/PreCheckoutQuery").PreCheckoutQuery - | import("../structures/media/Poll").Poll + | import("../structures/media/poll/Poll").Poll | import("../structures/PollAnswer").PollAnswer | import("../structures/ChatMemberUpdated").ChatMemberUpdated | import("../structures/ChatJoinRequest").ChatJoinRequest | import("../structures/ChatBoostUpdated").ChatBoostUpdated | import("../structures/ChatBoostRemoved").ChatBoostRemoved | import("../structures/PaidMediaPurchased").PaidMediaPurchased - | import("../structures/ManagedBotUpdated").ManagedBotUpdated; + | import("../structures/ManagedBotUpdated").ManagedBotUpdated + | import("../structures/BotSubscriptionUpdated").BotSubscriptionUpdated + | import("../structures/MessageGenerationStopped").MessageGenerationStopped; class BaseClient extends EventEmitter { public readonly rest: Rest; @@ -351,14 +366,30 @@ class BaseClient extends EventEmitter { params: MethodParameters["sendMessage"], ): Promise { return this.rest - .request< - MethodsApiReturnType["sendMessage"] - >("sendMessage", toSnakeCase(params)) + .request( + "sendMessage", + toSnakeCase(params), + ) .then( (res) => new Message(this, res) as MethodsLibReturnType["sendMessage"], ); } + /** Use this method to send rich messages. If the message contains a block with a media element, then the bot must have the right to send the media to the chat. On success, the sent Message is returned. */ + async sendRichMessage( + params: MethodParameters["sendRichMessage"], + ): Promise { + return this.rest + .request( + "sendRichMessage", + toSnakeCase(params), + ) + .then( + (res) => + new Message(this, res) as MethodsLibReturnType["sendRichMessage"], + ); + } + /** 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. */ async sendMessageDraft( params: MethodParameters["sendMessageDraft"], @@ -374,14 +405,30 @@ class BaseClient extends EventEmitter { params: MethodParameters["sendPhoto"], ): Promise { return this.rest - .request< - MethodsApiReturnType["sendPhoto"] - >("sendPhoto", toSnakeCase(params)) + .request( + "sendPhoto", + toSnakeCase(params), + ) .then( (res) => new Message(this, res) as MethodsLibReturnType["sendPhoto"], ); } + /** Use this method to send live photos. On success, the sent Message is returned. */ + async sendLivePhoto( + params: MethodParameters["sendLivePhoto"], + ): Promise { + return this.rest + .request( + "sendLivePhoto", + toSnakeCase(params), + ) + .then( + (res) => + new Message(this, res) as MethodsLibReturnType["sendLivePhoto"], + ); + } + /** Use this method to send audio files, if you want Telegram clients to display them in the music player. Your audio must be in the .MP3 or .M4A format. On success, the sent Message is returned. Bots can currently send audio files of up to 50 MB in size, this limit may be changed in the future. For sending voice messages, use the sendVoice method instead. */ @@ -389,9 +436,10 @@ class BaseClient extends EventEmitter { params: MethodParameters["sendAudio"], ): Promise { return this.rest - .request< - MethodsApiReturnType["sendAudio"] - >("sendAudio", toSnakeCase(params)) + .request( + "sendAudio", + toSnakeCase(params), + ) .then( (res) => new Message(this, res) as MethodsLibReturnType["sendAudio"], ); @@ -402,9 +450,10 @@ class BaseClient extends EventEmitter { params: MethodParameters["sendPaidMedia"], ): Promise { return this.rest - .request< - MethodsApiReturnType["sendPaidMedia"] - >("sendPaidMedia", toSnakeCase(params)) + .request( + "sendPaidMedia", + toSnakeCase(params), + ) .then( (res) => new Message(this, res) as MethodsLibReturnType["sendPaidMedia"], @@ -416,9 +465,10 @@ class BaseClient extends EventEmitter { params: MethodParameters["sendDocument"], ): Promise { return this.rest - .request< - MethodsApiReturnType["sendDocument"] - >("sendDocument", toSnakeCase(params)) + .request( + "sendDocument", + toSnakeCase(params), + ) .then( (res) => new Message(this, res) as MethodsLibReturnType["sendDocument"], ); @@ -429,9 +479,10 @@ class BaseClient extends EventEmitter { params: MethodParameters["sendVideo"], ): Promise { return this.rest - .request< - MethodsApiReturnType["sendVideo"] - >("sendVideo", toSnakeCase(params)) + .request( + "sendVideo", + toSnakeCase(params), + ) .then( (res) => new Message(this, res) as MethodsLibReturnType["sendVideo"], ); @@ -442,9 +493,10 @@ class BaseClient extends EventEmitter { params: MethodParameters["sendAnimation"], ): Promise { return this.rest - .request< - MethodsApiReturnType["sendAnimation"] - >("sendAnimation", toSnakeCase(params)) + .request( + "sendAnimation", + toSnakeCase(params), + ) .then( (res) => new Message(this, res) as MethodsLibReturnType["sendAnimation"], @@ -456,9 +508,10 @@ class BaseClient extends EventEmitter { params: MethodParameters["sendVoice"], ): Promise { return this.rest - .request< - MethodsApiReturnType["sendVoice"] - >("sendVoice", toSnakeCase(params)) + .request( + "sendVoice", + toSnakeCase(params), + ) .then( (res) => new Message(this, res) as MethodsLibReturnType["sendVoice"], ); @@ -470,9 +523,10 @@ class BaseClient extends EventEmitter { params: MethodParameters["sendVideoNote"], ): Promise { return this.rest - .request< - MethodsApiReturnType["sendVideoNote"] - >("sendVideoNote", toSnakeCase(params)) + .request( + "sendVideoNote", + toSnakeCase(params), + ) .then( (res) => new Message(this, res) as MethodsLibReturnType["sendVideoNote"], @@ -484,9 +538,10 @@ class BaseClient extends EventEmitter { params: MethodParameters["sendMediaGroup"], ): Promise { return this.rest - .request< - MethodsApiReturnType["sendMediaGroup"] - >("sendMediaGroup", toSnakeCase(params)) + .request( + "sendMediaGroup", + toSnakeCase(params), + ) .then( (res) => res.map( @@ -500,9 +555,10 @@ class BaseClient extends EventEmitter { params: MethodParameters["sendLocation"], ): Promise { return this.rest - .request< - MethodsApiReturnType["sendLocation"] - >("sendLocation", toSnakeCase(params)) + .request( + "sendLocation", + toSnakeCase(params), + ) .then( (res) => new Message(this, res) as MethodsLibReturnType["sendLocation"], ); @@ -513,9 +569,10 @@ class BaseClient extends EventEmitter { params: MethodParameters["sendVenue"], ): Promise { return this.rest - .request< - MethodsApiReturnType["sendVenue"] - >("sendVenue", toSnakeCase(params)) + .request( + "sendVenue", + toSnakeCase(params), + ) .then( (res) => new Message(this, res) as MethodsLibReturnType["sendVenue"], ); @@ -526,20 +583,22 @@ class BaseClient extends EventEmitter { params: MethodParameters["forwardMessage"], ): Promise { return this.rest - .request< - MethodsApiReturnType["forwardMessage"] - >("forwardMessage", toSnakeCase(params)) + .request( + "forwardMessage", + toSnakeCase(params), + ) .then((res) => new Message(this, res)); } - /** Use this method to forward multiple messages of any kind. If some of the specified messages can't be found or forwarded, they are skipped. Service messages and messages with protected content can't be forwarded. Album grouping is kept for forwarded messages. On success, an array of MessageId of the sent messages is returned. */ + /** Use this method to forward multiple messages of any kind. If some of the specified messages can't be found or forwarded, they are skipped. Service messages and messages with protected content can't be forwarded. Album grouping is kept for forwarded messages.On success, an Array of MessageId of the sent messages is returned.*/ async forwardMessages( params: MethodParameters["forwardMessages"], ): Promise { return this.rest - .request< - MethodsApiReturnType["forwardMessages"] - >("forwardMessages", toSnakeCase(params)) + .request( + "forwardMessages", + toSnakeCase(params), + ) .then((res) => res.map((msg) => msg.message_id)); } @@ -548,20 +607,22 @@ class BaseClient extends EventEmitter { params: MethodParameters["copyMessage"], ): Promise { return this.rest - .request< - MethodsApiReturnType["copyMessage"] - >("copyMessage", toSnakeCase(params)) + .request( + "copyMessage", + toSnakeCase(params), + ) .then((res) => res.message_id); } - /** Use this method to copy messages of any kind. If some of the specified messages can't be found or copied, they are skipped. Service messages, paid media messages, giveaway messages, giveaway winners messages, and invoice messages can't be copied. A quiz poll can be copied only if the value of the field correct_option_id is known to the bot. The method is analogous to the method forwardMessages, but the copied messages don't have a link to the original message. Album grouping is kept for copied messages. On success, an array of MessageId of the sent messages is returned. */ + /** Use this method to copy messages of any kind. If some of the specified messages can't be found or copied, they are skipped. Service messages, paid media messages, giveaway messages, giveaway winners messages, and invoice messages can't be copied. A quiz poll can be copied only if the value of the field correct_option_id is known to the bot. The method is analogous to the method forwardMessages, but the copied messages don't have a link to the original message. Album grouping is kept for copied messages.On success, an Array of MessageId of the sent messages is returned.*/ async copyMessages( params: MethodParameters["copyMessages"], ): Promise { return this.rest - .request< - MethodsApiReturnType["copyMessages"] - >("copyMessages", toSnakeCase(params)) + .request( + "copyMessages", + toSnakeCase(params), + ) .then((res) => res.map((msg) => msg.message_id)); } @@ -570,9 +631,10 @@ class BaseClient extends EventEmitter { params: MethodParameters["sendContact"], ): Promise { return this.rest - .request< - MethodsApiReturnType["sendContact"] - >("sendContact", toSnakeCase(params)) + .request( + "sendContact", + toSnakeCase(params), + ) .then( (res) => new Message(this, res) as MethodsLibReturnType["sendContact"], ); @@ -583,9 +645,10 @@ class BaseClient extends EventEmitter { params: MethodParameters["sendPoll"], ): Promise { return this.rest - .request< - MethodsApiReturnType["sendPoll"] - >("sendPoll", toSnakeCase(params)) + .request( + "sendPoll", + toSnakeCase(params), + ) .then( (res) => new Message(this, res) as MethodsLibReturnType["sendPoll"], ); @@ -596,9 +659,10 @@ class BaseClient extends EventEmitter { params: MethodParameters["sendChecklist"], ): Promise { return this.rest - .request< - MethodsApiReturnType["sendChecklist"] - >("sendChecklist", toSnakeCase(params)) + .request( + "sendChecklist", + toSnakeCase(params), + ) .then( (res) => new Message(this, res) as MethodsLibReturnType["sendChecklist"], @@ -610,9 +674,10 @@ class BaseClient extends EventEmitter { params: MethodParameters["editMessageChecklist"], ): Promise { return this.rest - .request< - MethodsApiReturnType["editMessageChecklist"] - >("editMessageChecklist", toSnakeCase(params)) + .request( + "editMessageChecklist", + toSnakeCase(params), + ) .then( (res) => new Message( @@ -627,14 +692,25 @@ class BaseClient extends EventEmitter { params: MethodParameters["sendDice"], ): Promise { return this.rest - .request< - MethodsApiReturnType["sendDice"] - >("sendDice", toSnakeCase(params)) + .request( + "sendDice", + toSnakeCase(params), + ) .then( (res) => new Message(this, res) as MethodsLibReturnType["sendDice"], ); } + /** Use this method to stream a partial rich message to a user while the message is being generated. Note that the streamed draft is ephemeral and acts as a temporary 30-second preview - once the output is finalized, you must call sendRichMessage with the complete message to persist it in the user's chat. Returns True on success. */ + async sendRichMessageDraft( + params: MethodParameters["sendRichMessageDraft"], + ): Promise { + return this.rest.request( + "sendRichMessageDraft", + toSnakeCase(params), + ); + } + /** 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. Example: The ImageBot needs some time to process a request and upload the image. Instead of sending a text message along the lines of "Retrieving image, please wait...", the bot may use sendChatAction with action = upload_photo. The user will see a "sending photo" status for the bot. @@ -674,9 +750,10 @@ class BaseClient extends EventEmitter { params: MethodParameters["getUserProfilePhotos"], ): Promise { return this.rest - .request< - MethodsApiReturnType["getUserProfilePhotos"] - >("getUserProfilePhotos", toSnakeCase(params)) + .request( + "getUserProfilePhotos", + toSnakeCase(params), + ) .then((res) => new UserProfilePhotos(this, res)); } @@ -685,9 +762,10 @@ class BaseClient extends EventEmitter { params: MethodParameters["getUserProfileAudios"], ): Promise { return this.rest - .request< - MethodsApiReturnType["getUserProfileAudios"] - >("getUserProfileAudios", toSnakeCase(params)) + .request( + "getUserProfileAudios", + toSnakeCase(params), + ) .then((res) => new UserProfileAudios(this, res)); } @@ -838,9 +916,10 @@ class BaseClient extends EventEmitter { params: MethodParameters["createChatInviteLink"], ): Promise { return this.rest - .request< - MethodsApiReturnType["createChatInviteLink"] - >("createChatInviteLink", toSnakeCase(params)) + .request( + "createChatInviteLink", + toSnakeCase(params), + ) .then((res) => new ChatInviteLink(this, res)); } @@ -849,9 +928,10 @@ class BaseClient extends EventEmitter { params: MethodParameters["editChatInviteLink"], ): Promise { return this.rest - .request< - MethodsApiReturnType["editChatInviteLink"] - >("editChatInviteLink", toSnakeCase(params)) + .request( + "editChatInviteLink", + toSnakeCase(params), + ) .then((res) => new ChatInviteLink(this, res)); } @@ -860,9 +940,10 @@ class BaseClient extends EventEmitter { params: MethodParameters["createChatSubscriptionInviteLink"], ): Promise { return this.rest - .request< - MethodsApiReturnType["createChatSubscriptionInviteLink"] - >("createChatSubscriptionInviteLink", toSnakeCase(params)) + .request( + "createChatSubscriptionInviteLink", + toSnakeCase(params), + ) .then((res) => new ChatInviteLink(this, res)); } @@ -871,9 +952,10 @@ class BaseClient extends EventEmitter { params: MethodParameters["editChatSubscriptionInviteLink"], ): Promise { return this.rest - .request< - MethodsApiReturnType["editChatSubscriptionInviteLink"] - >("editChatSubscriptionInviteLink", toSnakeCase(params)) + .request( + "editChatSubscriptionInviteLink", + toSnakeCase(params), + ) .then((res) => new ChatInviteLink(this, res)); } @@ -883,9 +965,10 @@ class BaseClient extends EventEmitter { chatId?: number | string, ): Promise { return this.rest - .request< - MethodsApiReturnType["revokeChatInviteLink"] - >("revokeChatInviteLink", { invite_link: inviteLink, ...(chatId && { chat_id: chatId }) }) + .request( + "revokeChatInviteLink", + { invite_link: inviteLink, ...(chatId && { chat_id: chatId }) }, + ) .then((res) => new ChatInviteLink(this, res)); } @@ -909,6 +992,27 @@ class BaseClient extends EventEmitter { ); } + /** Use this method to get the access settings of a managed bot. Returns a BotAccessSettings object on success. */ + async getManagedBotAccessSettings( + userId: string | number, + ): Promise { + return this.rest + .request( + "getManagedBotAccessSettings", + { user_id: userId }, + ) + .then((res) => new BotAccessSettings(this, res)); + } + + /** Use thi method to change the access settings of a managed bot. Returns True on success. */ + async setManagedBotAccessSettings( + params: MethodParameters["setManagedBotAccessSettings"], + ): Promise { + return this.rest.request< + MethodsApiReturnType["setManagedBotAccessSettings"] + >("setManagedBotAccessSettings", toSnakeCase(params)); + } + /** Use this method to approve a chat join get. 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. */ async approveChatJoinRequest( userId: number | string, @@ -923,6 +1027,33 @@ class BaseClient extends EventEmitter { ); } + /** Use this method to process a received chat join request query. Returns True on success. */ + async answerChatJoinRequestQuery( + chatJoinRequestQueryId: string, + result: "approve" | "decline" | "queue", + ): Promise { + return this.rest.request< + MethodsApiReturnType["answerChatJoinRequestQuery"] + >("answerChatJoinRequestQuery", { + chat_join_request_query_id: chatJoinRequestQueryId, + result, + }); + } + + /** Use this method to process a received chat join request query by showing a Mini App to the user before deciding the outcome. Returns True on success. */ + async sendChatJoinRequestWebApp( + chatJoinRequestQueryId: string, + webAppURL: string, + ): Promise { + return this.rest.request( + "sendChatJoinRequestWebApp", + { + chat_join_request_query_id: chatJoinRequestQueryId, + web_app_url: webAppURL, + }, + ); + } + /** Use this method to decline a chat join get. 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. */ async declineChatJoinRequest( chatId: number | string, @@ -1055,14 +1186,16 @@ class BaseClient extends EventEmitter { ); } - /** Use this method to get a list of administrators in a chat, which aren't bots. Returns an Array of ChatMember objects. */ + /** Use this method to get a list of administrators in a chat. Returns an Array of ChatMember objects.. Returns an Array of ChatMember objects. */ async getChatAdministrators( chatId: number | string, + returnBots?: boolean, ): Promise { return this.rest - .request< - MethodsApiReturnType["getChatAdministrators"] - >("getChatAdministrators", { chat_id: chatId }) + .request( + "getChatAdministrators", + { chat_id: chatId, ...(returnBots && { return_bots: returnBots }) }, + ) .then( (res) => res.map( @@ -1081,15 +1214,29 @@ class BaseClient extends EventEmitter { ); } + /** Use this method to reply to a received guest message. On success, a Identifier of the sent inline message is returned. */ + async answerGuestQuery( + guestQueryId: string, + result: InlineQueryResult, + ): Promise { + return this.rest + .request("answerGuestQuery", { + guest_query_id: guestQueryId, + result, + }) + .then((res) => res.inline_message_id); + } + /** Use this method to get the list of boosts added to a chat by a user. Requires administrator rights in the chat. Returns a UserChatBoosts object. */ async getUserChatBoosts( chatId: number | string, userId: number | string, ): Promise { return this.rest - .request< - MethodsApiReturnType["getUserChatBoosts"] - >("getUserChatBoosts", { chat_id: chatId, user_id: userId }) + .request("getUserChatBoosts", { + chat_id: chatId, + user_id: userId, + }) .then((res) => new UserChatBoosts(this, res)); } @@ -1098,9 +1245,10 @@ class BaseClient extends EventEmitter { params: MethodParameters["getUserGifts"], ): Promise { return this.rest - .request< - MethodsApiReturnType["getUserGifts"] - >("getUserGifts", toSnakeCase(params)) + .request( + "getUserGifts", + toSnakeCase(params), + ) .then((res) => new OwnedGifts(this, res)); } @@ -1109,9 +1257,10 @@ class BaseClient extends EventEmitter { params: MethodParameters["getChatGifts"], ): Promise { return this.rest - .request< - MethodsApiReturnType["getChatGifts"] - >("getChatGifts", toSnakeCase(params)) + .request( + "getChatGifts", + toSnakeCase(params), + ) .then((res) => new OwnedGifts(this, res)); } @@ -1120,9 +1269,10 @@ class BaseClient extends EventEmitter { businessConnectionId: string, ): Promise { return this.rest - .request< - MethodsApiReturnType["getBusinessConnection"] - >("getBusinessConnection", { business_connection_id: businessConnectionId }) + .request( + "getBusinessConnection", + { business_connection_id: businessConnectionId }, + ) .then((res) => new BusinessConnection(this, res)); } @@ -1132,12 +1282,34 @@ class BaseClient extends EventEmitter { userId: number | string, ): Promise { return this.rest - .request< - MethodsApiReturnType["getChatMember"] - >("getChatMember", { chat_id: chatId, user_id: userId }) + .request("getChatMember", { + chat_id: chatId, + user_id: userId, + }) .then((res) => new ChatMember(this, chatId, res)); } + /** Use this method to get the last messages from the personal chat (i.e., the chat currently added to their profile) of a given user. On success, an Array of Message objects is returned. */ + async getUserPersonalChatMessages( + userId: number | string, + limit: number, + ): Promise { + return this.rest + .request( + "getUserPersonalChatMessages", + { + user_id: userId, + limit: limit, + }, + ) + .then( + (res) => + res.map( + (msg) => new Message(this, msg), + ) as unknown as MethodsLibReturnType["getUserPersonalChatMessages"], + ); + } + /** Use this method to set a new group sticker set for a supergroup. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Use the field can_set_sticker_set ly returned in getChat requests to check if the bot can use this method. Returns True on success. */ async setChatStickerSet( stickerSetName: string, @@ -1164,9 +1336,9 @@ class BaseClient extends EventEmitter { MethodsLibReturnType["getForumTopicIconStickers"] > { return this.rest - .request< - MethodsApiReturnType["getForumTopicIconStickers"] - >("getForumTopicIconStickers") + .request( + "getForumTopicIconStickers", + ) .then( (res) => res.map( @@ -1180,9 +1352,10 @@ class BaseClient extends EventEmitter { params: MethodParameters["createForumTopic"], ): Promise { return this.rest - .request< - MethodsApiReturnType["createForumTopic"] - >("createForumTopic", toSnakeCase(params)) + .request( + "createForumTopic", + toSnakeCase(params), + ) .then( (res) => new ForumTopic(this, res.message_thread_id, params.chatId, res), @@ -1397,9 +1570,9 @@ class BaseClient extends EventEmitter { languageCode?: LanguageCode, ): Promise { return this.rest - .request< - MethodsApiReturnType["getMyDescription"] - >("getMyDescription", { ...(languageCode && { language_code: languageCode }) }) + .request("getMyDescription", { + ...(languageCode && { language_code: languageCode }), + }) .then((res) => res.description); } @@ -1422,9 +1595,10 @@ class BaseClient extends EventEmitter { languageCode?: LanguageCode, ): Promise { return this.rest - .request< - MethodsApiReturnType["getMyShortDescription"] - >("getMyShortDescription", { ...(languageCode && { language_code: languageCode }) }) + .request( + "getMyShortDescription", + { ...(languageCode && { language_code: languageCode }) }, + ) .then((res) => res.short_description); } @@ -1466,9 +1640,9 @@ class BaseClient extends EventEmitter { chatId?: number | string, ): Promise { return this.rest - .request< - MethodsApiReturnType["getChatMenuButton"] - >("getChatMenuButton", { ...(chatId && { chat_id: chatId }) }) + .request("getChatMenuButton", { + ...(chatId && { chat_id: chatId }), + }) .then((res) => new MenuButton(res)); } @@ -1493,9 +1667,14 @@ class BaseClient extends EventEmitter { forChannels?: boolean, ): Promise { return this.rest - .request< - MethodsApiReturnType["getMyDefaultAdministratorRights"] - >("getMyDefaultAdministratorRights", { ...(typeof forChannels === "boolean" && { for_channels: forChannels }) }) + .request( + "getMyDefaultAdministratorRights", + { + ...(typeof forChannels === "boolean" && { + for_channels: forChannels, + }), + }, + ) .then((res) => new ChatAdministratorRights(res)); } @@ -1572,9 +1751,10 @@ class BaseClient extends EventEmitter { businessConnectionId: string, ): Promise { return this.rest - .request< - MethodsApiReturnType["getBusinessAccountStarBalance"] - >("getBusinessAccountStarBalance", { business_connection_id: businessConnectionId }) + .request( + "getBusinessAccountStarBalance", + { business_connection_id: businessConnectionId }, + ) .then((res) => new StarAmount(res)); } @@ -1583,9 +1763,10 @@ class BaseClient extends EventEmitter { params: MethodParameters["getBusinessAccountGifts"], ): Promise { return this.rest - .request< - MethodsApiReturnType["getBusinessAccountGifts"] - >("getBusinessAccountGifts", toSnakeCase(params)) + .request( + "getBusinessAccountGifts", + toSnakeCase(params), + ) .then((res) => new OwnedGifts(this, res)); } @@ -1630,14 +1811,15 @@ class BaseClient extends EventEmitter { .then((res) => new StarAmount(res)); } - /** Use this method to edit text and game messages. On success, if the edited message is not an inline message, the edited Message is returned, otherwise True is returned. Note that business messages that were not sent by the bot and do not contain an inline keyboard can only be edited within 48 hours from the time they were sent. */ + /** Use this method to edit text, rich and game messages. On success, if the edited message is not an inline message, the edited Message is returned, otherwise True is returned. Note that business messages that were not sent by the bot and do not contain an inline keyboard can only be edited within 48 hours from the time they were sent. */ async editMessageText( params: MethodParameters["editMessageText"], ): Promise { return this.rest - .request< - MethodsApiReturnType["editMessageText"] - >("editMessageText", toSnakeCase(params)) + .request( + "editMessageText", + toSnakeCase(params), + ) .then((res) => { if (typeof res === "boolean") return res; return new Message( @@ -1652,9 +1834,10 @@ class BaseClient extends EventEmitter { params: MethodParameters["editMessageCaption"], ): Promise { return this.rest - .request< - MethodsApiReturnType["editMessageCaption"] - >("editMessageCaption", toSnakeCase(params)) + .request( + "editMessageCaption", + toSnakeCase(params), + ) .then((res) => { if (typeof res === "boolean") return res; return new Message( @@ -1664,14 +1847,15 @@ class BaseClient extends EventEmitter { }); } - /** Use this method to edit animation, audio, document, photo, video messages or to add media to text messages. If a message is part of a message album, then it can be edited only to an audio for audio albums, only to a document for document albums and to a photo or a video otherwise. When an inline message is edited, a new file can't be uploaded; use a previously uploaded file via its file_id or specify a URL. On success, if the edited message is not an inline message, the edited Message is returned, otherwise True is returned. Note that business messages that were not sent by the bot and do not contain an inline keyboard can only be edited within 48 hours from the time they were sent. */ + /** Use this method to edit animation, audio, document, live photo, photo, or video messages, or to replace a text or a rich message with a media. 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, a live photo, or a video otherwise. When an inline message is edited, a new file can't be uploaded; use a previously uploaded file via its file_id or specify a URL. On success, if the edited message is not an inline message, the edited Message is returned, otherwise True is returned. Note that business messages that were not sent by the bot and do not contain an inline keyboard can only be edited within 48 hours from the time they were sent. */ async editMessageMedia( params: MethodParameters["editMessageMedia"], ): Promise { return this.rest - .request< - MethodsApiReturnType["editMessageMedia"] - >("editMessageMedia", toSnakeCase(params)) + .request( + "editMessageMedia", + toSnakeCase(params), + ) .then((res) => { if (typeof res === "boolean") return res; return new Message( @@ -1686,9 +1870,10 @@ class BaseClient extends EventEmitter { params: MethodParameters["editMessageLiveLocation"], ): Promise { return this.rest - .request< - MethodsApiReturnType["editMessageLiveLocation"] - >("editMessageLiveLocation", toSnakeCase(params)) + .request( + "editMessageLiveLocation", + toSnakeCase(params), + ) .then( (res) => (typeof res === "boolean" @@ -1705,9 +1890,10 @@ class BaseClient extends EventEmitter { params: MethodParameters["stopMessageLiveLocation"], ): Promise { return this.rest - .request< - MethodsApiReturnType["stopMessageLiveLocation"] - >("stopMessageLiveLocation", toSnakeCase(params)) + .request( + "stopMessageLiveLocation", + toSnakeCase(params), + ) .then( (res) => (typeof res === "boolean" @@ -1724,9 +1910,10 @@ class BaseClient extends EventEmitter { params: MethodParameters["editMessageReplyMarkup"], ): Promise { return this.rest - .request< - MethodsApiReturnType["editMessageReplyMarkup"] - >("editMessageReplyMarkup", toSnakeCase(params)) + .request( + "editMessageReplyMarkup", + toSnakeCase(params), + ) .then((res) => { if (typeof res === "boolean") return res; return new Message( @@ -1741,9 +1928,10 @@ class BaseClient extends EventEmitter { params: MethodParameters["stopPoll"], ): Promise { return this.rest - .request< - MethodsApiReturnType["stopPoll"] - >("stopPoll", toSnakeCase(params)) + .request( + "stopPoll", + toSnakeCase(params), + ) .then((res) => new Poll(this, res)); } @@ -1752,9 +1940,10 @@ class BaseClient extends EventEmitter { params: MethodParameters["sendSticker"], ): Promise { return this.rest - .request< - MethodsApiReturnType["sendSticker"] - >("sendSticker", toSnakeCase(params)) + .request( + "sendSticker", + toSnakeCase(params), + ) .then( (res) => new Message(this, res) as MethodsLibReturnType["sendSticker"], ); @@ -1774,9 +1963,10 @@ class BaseClient extends EventEmitter { customEmojiIds: string[], ): Promise { return this.rest - .request< - MethodsApiReturnType["getCustomEmojiStickers"] - >("getCustomEmojiStickers", { custom_emoji_ids: customEmojiIds }) + .request( + "getCustomEmojiStickers", + { custom_emoji_ids: customEmojiIds }, + ) .then((res) => res.map((sticker) => new Sticker(this, sticker))); } @@ -1916,9 +2106,10 @@ class BaseClient extends EventEmitter { args: MethodParameters["postStory"], ): Promise { return this.rest - .request< - MethodsApiReturnType["postStory"] - >("postStory", toSnakeCase(args)) + .request( + "postStory", + toSnakeCase(args), + ) .then((res) => new Story(this, res)); } @@ -1927,9 +2118,10 @@ class BaseClient extends EventEmitter { args: MethodParameters["repostStory"], ): Promise { return this.rest - .request< - MethodsApiReturnType["repostStory"] - >("repostStory", toSnakeCase(args)) + .request( + "repostStory", + toSnakeCase(args), + ) .then((res) => new Story(this, res)); } @@ -1938,9 +2130,10 @@ class BaseClient extends EventEmitter { args: MethodParameters["editStory"], ): Promise { return this.rest - .request< - MethodsApiReturnType["editStory"] - >("editStory", toSnakeCase(args)) + .request( + "editStory", + toSnakeCase(args), + ) .then((res) => new Story(this, res)); } @@ -2028,9 +2221,10 @@ class BaseClient extends EventEmitter { result: MethodParameters["answerWebAppQuery"]["result"], ): Promise { return this.rest - .request< - MethodsApiReturnType["answerWebAppQuery"] - >("answerWebAppQuery", { web_app_query_id: webAppQueryId, result }) + .request("answerWebAppQuery", { + web_app_query_id: webAppQueryId, + result, + }) .then((res) => res.inline_message_id); } @@ -2039,9 +2233,10 @@ class BaseClient extends EventEmitter { params: MethodParameters["savePreparedInlineMessage"], ): Promise { return this.rest - .request< - MethodsApiReturnType["savePreparedInlineMessage"] - >("savePreparedInlineMessage", toSnakeCase(params)) + .request( + "savePreparedInlineMessage", + toSnakeCase(params), + ) .then((res) => new PreparedInlineMessage(res)); } @@ -2050,9 +2245,10 @@ class BaseClient extends EventEmitter { params: MethodParameters["savePreparedKeyboardButton"], ): Promise { return this.rest - .request< - MethodsApiReturnType["savePreparedKeyboardButton"] - >("savePreparedKeyboardButton", toSnakeCase(params)) + .request( + "savePreparedKeyboardButton", + toSnakeCase(params), + ) .then((res) => res.id); } @@ -2061,9 +2257,10 @@ class BaseClient extends EventEmitter { params: MethodParameters["sendInvoice"], ): Promise { return this.rest - .request< - MethodsApiReturnType["sendInvoice"] - >("sendInvoice", toSnakeCase(params)) + .request( + "sendInvoice", + toSnakeCase(params), + ) .then( (res) => new Message(this, res) as MethodsLibReturnType["sendInvoice"], ); @@ -2106,7 +2303,7 @@ class BaseClient extends EventEmitter { /** * Verifies a chat on behalf of the organization which is represented by the bot. Returns True on success. - * @param chatId - Unique identifier for the target chat or username of the target channel (in the format @channelusername). + * @param chatId - Unique identifier for the target chat or username of the target channel (bot, supergroup or channel in the format @username). * @param description - Custom description for the verification; 0-70 characters. Must be empty if the organization isn't allowed to provide a custom verification description. */ async verifyChat( @@ -2134,7 +2331,7 @@ class BaseClient extends EventEmitter { /** * Removes verification from a chat that is currently verified on behalf of the organization represented by the bot. Returns True on success. - * @param chatId - Unique identifier for the target chat or username of the target channel (in the format @channelusername) + * @param chatId - Unique identifier for the target chat or username of the target channel (bot, supergroup or channel in the format @username) */ async removeChatVerification( chatId: number | string, @@ -2213,9 +2410,10 @@ class BaseClient extends EventEmitter { params: MethodParameters["sendGame"], ): Promise { return this.rest - .request< - MethodsApiReturnType["sendGame"] - >("sendGame", toSnakeCase(params)) + .request( + "sendGame", + toSnakeCase(params), + ) .then( (res) => new Message(this, res) as MethodsLibReturnType["sendGame"], ); @@ -2226,9 +2424,10 @@ class BaseClient extends EventEmitter { params: MethodParameters["setGameScore"], ): Promise { return this.rest - .request< - MethodsApiReturnType["setGameScore"] - >("setGameScore", toSnakeCase(params)) + .request( + "setGameScore", + toSnakeCase(params), + ) .then( (res) => (typeof res === "boolean" @@ -2244,12 +2443,51 @@ class BaseClient extends EventEmitter { params: MethodParameters["getGameHighScores"], ): Promise { return this.rest - .request< - MethodsApiReturnType["getGameHighScores"] - >("getGameHighScores", toSnakeCase(params)) + .request( + "getGameHighScores", + toSnakeCase(params), + ) .then((res) => res.map((game) => new GameHighScore(this, game))); } + /** Use this method to edit an ephemeral text message. Note that it is not guaranteed that the user will receive the message edit event, especially if they are offline. On success, True is returned. */ + async editEphemeralMessageText( + params: MethodParameters["editEphemeralMessageText"], + ): Promise { + return this.rest.request( + "editEphemeralMessageText", + toSnakeCase(params), + ); + } + + /** Use this method to edit the media of an ephemeral message. Note that it is not guaranteed that the user will receive the message edit event, especially if they are offline. On success, True is returned. */ + async editEphemeralMessageMedia( + params: MethodParameters["editEphemeralMessageMedia"], + ): Promise { + return this.rest.request( + "editEphemeralMessageMedia", + toSnakeCase(params), + ); + } + + /** Use this method to edit the caption of an ephemeral message. Note that it is not guaranteed that the user will receive the message edit event, especially if they are offline. On success, True is returned. */ + async editEphemeralMessageCaption( + params: MethodParameters["editEphemeralMessageCaption"], + ): Promise { + return this.rest.request< + MethodsApiReturnType["editEphemeralMessageCaption"] + >("editEphemeralMessageCaption", toSnakeCase(params)); + } + + /** Use this method to edit only the reply markup of an ephemeral message. Note that it is not guaranteed that the user will receive the message edit event, especially if they are offline. On success, True is returned. */ + async editEphemeralMessageReplyMarkup( + params: MethodParameters["editEphemeralMessageReplyMarkup"], + ): Promise { + return this.rest.request< + MethodsApiReturnType["editEphemeralMessageReplyMarkup"] + >("editEphemeralMessageReplyMarkup", toSnakeCase(params)); + } + /** Use this method to delete a message, including service messages, with the following limitations: - A message can only be deleted if it was sent less than 48 hours ago. - Service messages about a supergroup, channel, or forum topic creation can't be deleted. @@ -2271,6 +2509,16 @@ class BaseClient extends EventEmitter { ); } + /** Use this method to delete an ephemeral message. Note that it is not guaranteed that the user will receive the message deletion event, especially if they are offline. Returns True on success. */ + deleteEphemeralMessage( + args: MethodParameters["deleteEphemeralMessage"], + ): Promise { + return this.rest.request( + "deleteEphemeralMessage", + toSnakeCase(args), + ); + } + /** Use this method to delete multiple messages simultaneously. Returns True on success. */ async deleteMessages( chatId: number | string, @@ -2282,6 +2530,26 @@ class BaseClient extends EventEmitter { ); } + /** Use this method to remove up to 10000 recent reactions in a group or a supergroup chat added by a given user or chat. The bot must have the 'can_delete_messages' administrator right in the chat. Returns True on success. */ + async deleteMessageReaction( + params: MethodParameters["deleteMessageReaction"], + ): Promise { + return this.rest.request( + "deleteMessageReaction", + toSnakeCase(params), + ); + } + + /** Use this method to remove up to 10000 recent reactions in a group or a supergroup chat added by a given user or chat. The bot must have the 'can_delete_messages' administrator right in the chat. Returns True on success. */ + async deleteAllMessageReactions( + params: MethodParameters["deleteAllMessageReactions"], + ): Promise { + return this.rest.request( + "deleteAllMessageReactions", + toSnakeCase(params), + ); + } + /** Delete messages on behalf of a business account. Requires the can_delete_outgoing_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. */ async deleteBusinessMessages( businessConnectionId: string, diff --git a/src/client/TelegramClient.ts b/src/client/TelegramClient.ts index 40467496..fd917704 100644 --- a/src/client/TelegramClient.ts +++ b/src/client/TelegramClient.ts @@ -11,8 +11,8 @@ import { WebhookClient } from "./WebhookClient"; import { WorkerClient } from "./WorkerClient"; import { TelegramError } from "../errors/TelegramError"; import { ErrorCodes } from "../errors/ErrorCodes"; -import type { ClientUser } from "../structures/misc/ClientUser"; -import type { User } from "../structures/misc/User"; +import type { ClientUser } from "../structures/misc/client/ClientUser"; +import type { User } from "../structures/misc/user/User"; import type { Chat } from "../structures/chat/Chat"; import { Events, diff --git a/src/client/WebhookClient.ts b/src/client/WebhookClient.ts index c9c3ed15..3e468fbc 100644 --- a/src/client/WebhookClient.ts +++ b/src/client/WebhookClient.ts @@ -179,6 +179,7 @@ class WebhookClient { } const res = await this.client.worker.processUpdate(update); + if (res) { this.client.updates.set(this.offset, res); } diff --git a/src/client/WorkerClient.ts b/src/client/WorkerClient.ts index 0ecda044..30a07889 100644 --- a/src/client/WorkerClient.ts +++ b/src/client/WorkerClient.ts @@ -1,7 +1,7 @@ import { Events } from "../util/Constants"; import type { Update } from "@telegram.ts/types"; import { Message } from "../structures/message/Message"; -import { Poll } from "../structures/media/Poll"; +import { Poll } from "../structures/media/poll/Poll"; import { PollAnswer } from "../structures/PollAnswer"; import { InlineQuery } from "../structures/InlineQuery"; import { ShippingQuery } from "../structures/ShippingQuery"; @@ -18,6 +18,9 @@ import { BusinessConnection } from "../structures/business/BusinessConnection"; import { BusinessMessagesDeleted } from "../structures/business/BusinessMessagesDeleted"; import { PaidMediaPurchased } from "../structures/PaidMediaPurchased"; import { ManagedBotUpdated } from "../structures/ManagedBotUpdated"; +import { BotSubscriptionUpdated } from "../structures/BotSubscriptionUpdated"; +import { MessageGenerationStopped } from "../structures/MessageGenerationStopped"; + import type { TelegramClient } from "./TelegramClient"; type UpdateResult = @@ -38,7 +41,9 @@ type UpdateResult = | ChatBoostUpdated | ChatBoostRemoved | PaidMediaPurchased - | ManagedBotUpdated; + | ManagedBotUpdated + | BotSubscriptionUpdated + | MessageGenerationStopped; /** * Handles incoming updates from the Telegram API and routes them to the appropriate event handlers. @@ -159,6 +164,17 @@ class WorkerClient { if ("managed_bot" in data && data.managed_bot) { return this.onManagedUpdatedBot(data.managed_bot); } + + if ("subscription" in data && data.subscription) { + return this.onBotSubscriptionUpdated(data.subscription); + } + + if ( + "stopped_message_generation" in data && + data.stopped_message_generation + ) { + return this.onStoppedMessageGeneration(data.stopped_message_generation); + } } /** @@ -167,7 +183,10 @@ class WorkerClient { */ onMessage( data: NonNullable< - Update["message"] | Update["channel_post"] | Update["business_message"] + | Update["message"] + | Update["channel_post"] + | Update["business_message"] + | Update["guest_message"] >, ): Message { const message = new Message(this.client, data); @@ -431,6 +450,33 @@ class WorkerClient { this.client.emit(Events.ManagedBotUpdated, managedBot); return managedBot; } + + /** + * Handles bot subscription updates. + * @param data - The subscription update data. + */ + onBotSubscriptionUpdated( + data: NonNullable, + ): BotSubscriptionUpdated { + const subscription = new BotSubscriptionUpdated(this.client, data); + this.client.emit(Events.Subscription, subscription); + return subscription; + } + + /** + * Handles bot message stopped updates. + * @param data - The message stopped data. + */ + onStoppedMessageGeneration( + data: NonNullable, + ): MessageGenerationStopped { + const messageGenerationStopped = new MessageGenerationStopped( + this.client, + data, + ); + this.client.emit(Events.MessageGenerationStopped, messageGenerationStopped); + return messageGenerationStopped; + } } export { WorkerClient }; diff --git a/src/client/interfaces/Bot.ts b/src/client/interfaces/Bot.ts index ddd10ca1..36c97d84 100644 --- a/src/client/interfaces/Bot.ts +++ b/src/client/interfaces/Bot.ts @@ -9,9 +9,7 @@ export interface BotCommand { } export type MenuButton = - | MenuButtonCommands - | MenuButtonWebApp - | MenuButtonDefault; + MenuButtonCommands | MenuButtonWebApp | MenuButtonDefault; /** * Represents a menu button that opens the bot's list of commands. diff --git a/src/client/interfaces/Inline.ts b/src/client/interfaces/Inline.ts index b41394c9..2d64ef3f 100644 --- a/src/client/interfaces/Inline.ts +++ b/src/client/interfaces/Inline.ts @@ -6,6 +6,7 @@ import type { Location, User, } from "./Message"; +import type { InputRichMessage } from "./RichMessage"; /** This object represents a portion of the price for goods or services. */ export interface LabeledPrice { @@ -327,7 +328,7 @@ export interface InlineQueryResultLocation { title: string; /** The radius of uncertainty for the location, measured in meters; 0-1500 */ horizontal_accuracy?: number; - /** Period in seconds during which the location can be updated, should be between 60 and 86400, or 0x7FFFFFFF for live locations that can be edited indefinitely. */ + /** Period in seconds during which the location can be updated, must be between 60 and 86400, or 0x7FFFFFFF for live locations that can be edited indefinitely. */ live_period?: number; /** For live locations, a direction in which the user is moving, in degrees. Must be between 1 and 360 if specified. */ heading?: number; @@ -604,12 +605,14 @@ export interface InlineQueryResultCachedAudio { - InputTextMessageContent - InputLocationMessageContent +- InputRichMessageContent - InputVenueMessageContent - InputContactMessageContent - InputInvoiceMessageContent */ export type InputMessageContent = | InputTextMessageContent | InputLocationMessageContent + | InputRichMessageContent | InputVenueMessageContent | InputContactMessageContent | InputInvoiceMessageContent; @@ -624,6 +627,13 @@ export interface InputTextMessageContent { /** Link preview generation options for the message */ link_preview_options?: LinkPreviewOptions; } + +/** Represents the content of a rich message to be sent as the result of an inline query. */ +export interface InputRichMessageContent { + /** The message to be sent. Only previously uploaded files may be used in the message. */ + rich_message: InputRichMessage; +} + /** Represents the content of a location message to be sent as the result of an inline query. */ export interface InputLocationMessageContent { /** Latitude of the location in degrees */ @@ -632,7 +642,7 @@ export interface InputLocationMessageContent { longitude: number; /** The radius of uncertainty for the location, measured in meters; 0-1500 */ horizontal_accuracy?: number; - /** Period in seconds during which the location can be updated, should be between 60 and 86400, or 0x7FFFFFFF for live locations that can be edited indefinitely. */ + /** Period in seconds during which the location can be updated, must be between 60 and 86400, or 0x7FFFFFFF for live locations that can be edited indefinitely. */ live_period?: number; /** For live locations, a direction in which the user is moving, in degrees. Must be between 1 and 360 if specified. */ heading?: number; @@ -685,7 +695,7 @@ export interface InputInvoiceMessageContent { prices: LabeledPrice[]; /** The maximum accepted amount for tips in the smallest units of the currency (integer, not float/double). For example, for a maximum tip of US$ 1.45 pass max_tip_amount = 145. See the exp parameter in currencies.json, it shows the number of digits past the decimal point for each currency (2 for the majority of currencies). Defaults to 0. Not supported for payments in Telegram Stars. */ max_tip_amount?: number; - /** An array of suggested amounts of tip in the smallest units of the currency (integer, not float/double). At most 4 suggested tip amounts can be specified. The suggested tip amounts must be positive, passed in a strictly increased order and must not exceed max_tip_amount. */ + /** An Array of suggested amounts of tip in the smallest units of the currency (integer, not float/double). At most 4 suggested tip amounts can be specified. The suggested tip amounts must be positive, passed in a strictly increased order and must not exceed max_tip_amount. */ suggested_tip_amounts?: number[]; /** Data about the invoice, which will be shared with the payment provider. A detailed description of the required fields should be provided by the payment provider. */ provider_data?: string; diff --git a/src/client/interfaces/Markup.ts b/src/client/interfaces/Markup.ts index 35c90591..eabe0b08 100644 --- a/src/client/interfaces/Markup.ts +++ b/src/client/interfaces/Markup.ts @@ -4,6 +4,8 @@ import type { ChatAdministratorRights } from "@telegram.ts/types"; export interface InlineKeyboardMarkup { /** Array of button rows, each represented by an Array of InlineKeyboardButton objects */ inline_keyboard: InlineKeyboardButton[][]; + /** Pass True if the reply interface must be shown to the user, as if they had manually selected the bot's message and tapped 'Reply'. The value of the field can't be changed when the inline keyboard is edited. */ + force_reply?: boolean; } export declare namespace InlineKeyboardButton { @@ -24,25 +26,29 @@ export declare namespace InlineKeyboardButton { callback_data: string; } export interface WebAppButton extends AbstractInlineKeyboardButton { - /** Description of the Web App that will be launched when the user presses the button. The Web App will be able to send an arbitrary message on behalf of the user using the method answerWebAppQuery. Available only in private chats between a user and the bot. Not supported for messages sent on behalf of a Telegram Business account. */ + /** Description of the Web App that will be launched when the user presses the button. The Web App will be able to send an arbitrary message on behalf of the user using the method answerWebAppQuery. Available only in private chats between a user and the bot. Not supported for messages sent on behalf of a business account. */ web_app: WebAppInfo; } export interface LoginButton extends AbstractInlineKeyboardButton { - /** An HTTPS URL used to automatically authorize the user. Can be used as a replacement for the Telegram Login Widget. */ + /** An HTTPS URL used to automatically authorize the user. Can be used as a replacement for the Telegram Login Widget. Not supported for ephemeral messages. */ login_url: LoginUrl; } + export interface DisabledButtonButton extends AbstractInlineKeyboardButton { + /** If set, then the button is disabled and does nothing */ + disabled: DisabledButton; + } export interface SwitchInlineButton extends AbstractInlineKeyboardButton { - /** If set, pressing the button will prompt the user to select one of their chats, open that chat and insert the bot's username and the specified inline query in the input field. May be empty, in which case just the bot's username will be inserted. Not supported for messages sent in channel direct messages chats and on behalf of a Telegram Business account. */ + /** If set, pressing the button will prompt the user to select one of their chats, open that chat and insert the bot's username and the specified inline query in the input field. May be empty, in which case just the bot's username will be inserted. Not supported for messages sent in channel direct messages chats and on behalf of a business account. */ switch_inline_query: string; } export interface SwitchInlineCurrentChatButton extends AbstractInlineKeyboardButton { /** If set, pressing the button will insert the bot's username and the specified inline query in the current chat's input field. May be empty, in which case only the bot's username will be inserted. - This offers a quick way for the user to open your bot in inline mode in the same chat - good for selecting something from multiple options. Not supported in channels and for messages sent in channel direct messages chats and on behalf of a Telegram Business account. */ + This offers a quick way for the user to open your bot in inline mode in the same chat - good for selecting something from multiple options. Not supported in channels and for messages sent in channel direct messages chats and on behalf of a business account. */ switch_inline_query_current_chat: string; } export interface SwitchInlineChosenChatButton extends AbstractInlineKeyboardButton { - /** If set, pressing the button will prompt the user to select one of their chats of the specified type, open that chat and insert the bot's username and the specified inline query in the input field. Not supported for messages sent in channel direct messages chats and on behalf of a Telegram Business account. */ + /** If set, pressing the button will prompt the user to select one of their chats of the specified type, open that chat and insert the bot's username and the specified inline query in the input field. Not supported for messages sent in channel direct messages chats and on behalf of a business account. */ switch_inline_query_chosen_chat: SwitchInlineQueryChosenChat; } export interface GameButton extends AbstractInlineKeyboardButton { @@ -68,6 +74,7 @@ export type InlineKeyboardButton = | InlineKeyboardButton.CallbackButton | InlineKeyboardButton.GameButton | InlineKeyboardButton.LoginButton + | InlineKeyboardButton.DisabledButtonButton | InlineKeyboardButton.PayButton | InlineKeyboardButton.SwitchInlineButton | InlineKeyboardButton.SwitchInlineCurrentChatButton @@ -88,8 +95,7 @@ export interface WebAppInfo { url: string; } -/** This object represents a parameter of the inline keyboard button used to automatically authorize a user. Serves as a great replacement for the Telegram Login Widget when the user is coming from Telegram. All the user needs to do is tap/click a button and confirm that they want to log in. -Telegram apps support these buttons as of version 5.7. */ +/** This object represents a parameter of the inline keyboard button used to automatically authorize a user. It serves as a great replacement for the Telegram Login Widget when the user is coming from Telegram. All the user needs to do is tap/click a button and confirm that they want to log in. */ export interface LoginUrl { /** An HTTPS URL to be opened with user authorization data added to the query string when the button is pressed. If the user refuses to provide authorization data, the original URL without information about the user will be opened. The data added is the same as described in Receiving authorization data. @@ -97,12 +103,15 @@ export interface LoginUrl { url: string; /** New text of the button in forwarded messages. */ forward_text?: string; - /** Username of a bot, which will be used for user authorization. See Setting up a bot for more details. If not specified, the current bot's username will be assumed. The url's domain must be the same as the domain linked with the bot. See Linking your domain to the bot for more details. */ + /** Username of a bot, which will be used for user authorization; not supported in RichMessageButton. See Setting up a bot for more details. If not specified, the current bot's username will be assumed. The url's domain must be the same as the domain linked with the bot. See Linking your domain to the bot for more details. */ bot_username?: string; /** Pass True to request the permission for your bot to send messages to the user. */ request_write_access?: boolean; } +/** This object represents a disabled button which does nothing. Currently holds no information. */ +export interface DisabledButton {} + /** This object represents an inline button that switches the current user to inline mode in a chosen chat, with an optional default inline query. */ export interface SwitchInlineQueryChosenChat { /** The default inline query to be inserted in the input field. If left empty, only the bot's username will be inserted */ @@ -135,15 +144,15 @@ export interface ForceReply { selective?: boolean; } -/** This object represents a custom keyboard with reply options (see Introduction to bots for details and examples). Not supported in channels and for messages sent on behalf of a Telegram Business account. */ +/** This object represents a custom keyboard with reply options (see Introduction to bots for details and examples). Not supported in channels and for messages sent on behalf of a business account. */ export interface ReplyKeyboardMarkup { /** Array of button rows, each represented by an Array of KeyboardButton objects */ keyboard: KeyboardButton[][]; - /** Requests clients to always show the keyboard when the regular keyboard is hidden. Defaults to false, in which case the custom keyboard can be hidden and opened with a keyboard icon. */ + /** Requests clients to always show the keyboard when the regular keyboard is hidden. Defaults to False, in which case the custom keyboard can be hidden and opened with a keyboard icon. */ is_persistent?: boolean; - /** Requests clients to resize the keyboard vertically for optimal fit (e.g., make the keyboard smaller if there are just two rows of buttons). Defaults to false, in which case the custom keyboard is always of the same height as the app's standard keyboard. */ + /** Requests clients to resize the keyboard vertically for optimal fit (e.g., make the keyboard smaller if there are just two rows of buttons). Defaults to False, in which case the custom keyboard is always of the same height as the app's standard keyboard. */ resize_keyboard?: boolean; - /** Requests clients to hide the keyboard as soon as it's been used. The keyboard will still be available, but clients will automatically display the usual letter-keyboard in the chat – the user can press a special button in the input field to see the custom keyboard again. Defaults to false. */ + /** Requests clients to hide the keyboard as soon as it's been used. The keyboard will still be available, but clients will automatically display the usual letter-keyboard in the chat – the user can press a special button in the input field to see the custom keyboard again. Defaults to False. */ one_time_keyboard?: boolean; /** The placeholder to be shown in the input field when the keyboard is active; 1-64 characters */ input_field_placeholder?: string; @@ -151,6 +160,8 @@ export interface ReplyKeyboardMarkup { Example: A user requests to change the bot's language, bot replies to the request with a keyboard to select the new language. Other users in the group don't see the keyboard. */ selective?: boolean; + /** Pass True if the reply interface must be shown to the user, as if they had manually selected the bot's message and tapped 'Reply' */ + force_reply?: boolean; } export declare namespace KeyboardButton { @@ -220,7 +231,7 @@ export interface KeyboardButtonRequestManagedBot { suggested_username?: string; } -/** Upon receiving a message with this object, Telegram clients will remove the current custom keyboard and display the default letter-keyboard. By default, custom keyboards are displayed until a new keyboard is sent by a bot. An exception is made for one-time keyboards that are hidden immediately after the user presses a button (see ReplyKeyboardMarkup). Not supported in channels and for messages sent on behalf of a Telegram Business account. */ +/** Upon receiving a message with this object, Telegram clients will remove the current custom keyboard and display the default letter-keyboard. By default, custom keyboards are displayed until a new keyboard is sent by a bot. An exception is made for one-time keyboards that are hidden immediately after the user presses a button (see ReplyKeyboardMarkup). Not supported in channels and for messages sent on behalf of a business account. */ export interface ReplyKeyboardRemove { /** Requests clients to remove the custom keyboard (user will not be able to summon this keyboard; if you want to hide the keyboard from sight but keep it accessible, use one_time_keyboard in ReplyKeyboardMarkup) */ remove_keyboard: true; diff --git a/src/client/interfaces/Message.ts b/src/client/interfaces/Message.ts index bbce0ee2..ba2757d1 100644 --- a/src/client/interfaces/Message.ts +++ b/src/client/interfaces/Message.ts @@ -112,21 +112,11 @@ export interface MaskPosition { scale: number; } -/** This object contains information about one answer option in a poll to send. */ -export interface InputPollOption { - /** Option text, 1-100 characters */ - text: string; - /** Mode for parsing entities in the text. See formatting options for more details. Currently, only custom emoji entities are allowed */ - text_parse_mode?: string; - /** A list of special entities that appear in the poll option text. It can be specified instead of text_parse_mode */ - text_entities?: MessageEntity[]; -} - /** Describes reply parameters for the message that is being sent. */ export interface ReplyParameters { /** Identifier of the message that will be replied to in the current chat, or in the chat chat_id if it is specified */ message_id: number | string; - /** If the message to be replied to is from a different chat, unique identifier for the chat or username of the channel (in the format @channelusername). Not supported for messages sent on behalf of a business account and messages from channel direct messages chats. */ + /** If the message to be replied to is from a different chat, unique identifier for the chat or username of the bot, supergroup or channel in the format `@username`. Not supported for messages sent on behalf of a business account and messages from channel direct messages chats. */ chat_id?: number | string; /** Identifier of the specific checklist task to be replied to */ checklist_task_id?: number; @@ -238,6 +228,138 @@ export interface ReactionTypeCustomEmoji { custom_emoji_id: string; } +/** This object represents one size of a photo or a file / sticker thumbnail. */ +export interface PhotoSize { + /** Identifier for this file, which can be used to download or reuse the file */ + file_id: string; + /** Unique identifier for this file, which is supposed to be the same over time and for different bots. Can't be used to download or reuse the file. */ + file_unique_id: string; + /** Photo width */ + width: number; + /** Photo height */ + height: number; + /** File size in bytes */ + file_size?: number; +} + +/** This object represents a voice note. */ +export interface Voice { + /** Identifier for this file, which can be used to download or reuse the file */ + file_id: string; + /** Unique identifier for this file, which is supposed to be the same over time and for different bots. Can't be used to download or reuse the file. */ + file_unique_id: string; + /** Duration of the audio in seconds as defined by sender */ + duration: number; + /** MIME type of the file as defined by sender */ + mime_type?: string; + /** File size in bytes */ + file_size?: number; +} + +/** This object represents an animation file (GIF or H.264/MPEG-4 AVC video without sound). */ +export interface Animation { + /** Identifier for this file, which can be used to download or reuse the file */ + file_id: string; + /** Unique identifier for this file, which is supposed to be the same over time and for different bots. Can't be used to download or reuse the file. */ + file_unique_id: string; + /** Video width as defined by sender */ + width: number; + /** Video height as defined by sender */ + height: number; + /** Duration of the video in seconds as defined by sender */ + duration: number; + /** Animation thumbnail as defined by sender */ + thumbnail?: PhotoSize; + /** Original animation filename as defined by sender */ + file_name?: string; + /** MIME type of the file as defined by sender */ + mime_type?: string; + /** File size in bytes */ + file_size?: number; +} + +/** This object represents an audio file to be treated as music by the Telegram clients. */ +export interface Audio { + /** Identifier for this file, which can be used to download or reuse the file */ + file_id: string; + /** Unique identifier for this file, which is supposed to be the same over time and for different bots. Can't be used to download or reuse the file. */ + file_unique_id: string; + /** Duration of the audio in seconds as defined by sender */ + duration: number; + /** Performer of the audio as defined by sender or by audio tags */ + performer?: string; + /** Title of the audio as defined by sender or by audio tags */ + title?: string; + /** Original filename as defined by sender */ + file_name?: string; + /** MIME type of the file as defined by sender */ + mime_type?: string; + /** File size in bytes */ + file_size?: number; + /** Thumbnail of the album cover to which the music file belongs */ + thumbnail?: PhotoSize; +} + +/** This object represents a general file (as opposed to photos, voice messages and audio files). */ +export interface Document { + /** Identifier for this file, which can be used to download or reuse the file */ + file_id: string; + /** Unique identifier for this file, which is supposed to be the same over time and for different bots. Can't be used to download or reuse the file. */ + file_unique_id: string; + /** Document thumbnail as defined by sender */ + thumbnail?: PhotoSize; + /** Original filename as defined by sender */ + file_name?: string; + /** MIME type of the file as defined by sender */ + mime_type?: string; + /** File size in bytes */ + file_size?: number; +} + +/** This object represents a video file. */ +export interface Video { + /** Identifier for this file, which can be used to download or reuse the file */ + file_id: string; + /** Unique identifier for this file, which is supposed to be the same over time and for different bots. Can't be used to download or reuse the file. */ + file_unique_id: string; + /** Video width as defined by sender */ + width: number; + /** Video height as defined by sender */ + height: number; + /** Duration of the video in seconds as defined by sender */ + duration: number; + /** Video thumbnail */ + thumbnail?: PhotoSize; + /** Available sizes of the cover of the video in the message */ + cover?: PhotoSize[]; + /** Timestamp in seconds from which the video will play in the message */ + start_timestamp?: number; + /** Original filename as defined by sender */ + file_name?: string; + /** MIME type of the file as defined by sender */ + mime_type?: string; + /** File size in bytes */ + file_size?: number; + /** List of available qualities of the video. */ + qualities?: VideoQuality[]; +} + +/** This object represents a video file of a specific quality. */ +export interface VideoQuality { + /** Identifier for this file, which can be used to download or reuse the file */ + file_id: string; + /** Unique identifier for this file, which is supposed to be the same over time and for different bots. Can't be used to download or reuse the file. */ + file_unique_id: string; + /** Video width */ + width: number; + /** Video height */ + height: number; + /** Codec that was used to encode the video, for example, “h264”, “h265”, or “av01” */ + codec: string; + /** File size in bytes. */ + file_size?: number; +} + /** This object represents a point on the map. */ export interface Location { /** Latitude as defined by sender */ @@ -253,3 +375,12 @@ export interface Location { /** The maximum distance for proximity alerts about approaching another chat member, in meters. For sent live locations only. */ proximity_alert_padius?: number; } + +export interface EphemeralMessageParameters { + /** Identifier of the user who will receive the message. It is not guaranteed that the user will receive the message, especially if they are offline. See here for more details. */ + receiver_user_id: number; + /** Identifier of the callback query which triggered the message, if any */ + callback_query_id?: string; + /** Pass True if the ephemeral message must be shown in place of the original message */ + replace_callback_query_message?: boolean; +} diff --git a/src/client/interfaces/Methods.ts b/src/client/interfaces/Methods.ts index c18302ef..421963ac 100644 --- a/src/client/interfaces/Methods.ts +++ b/src/client/interfaces/Methods.ts @@ -3,6 +3,7 @@ import type { Buffer, Blob } from "node:buffer"; import type { LanguageCode } from "./Language"; import type { PassportElementError } from "./Passport"; import type { InputChecklist } from "./Checklist"; +import type { InputRichMessage } from "./RichMessage"; import type { AcceptedGiftTypes, BotCommand, @@ -17,10 +18,10 @@ import type { SuggestedPostParameters, } from "./Inline"; import type { + EphemeralMessageParameters, MessageEntity, LinkPreviewOptions, MaskPosition, - InputPollOption, ReplyParameters, ReactionType, } from "./Message"; @@ -125,7 +126,7 @@ export type ApiMethods = { getWebhookInfo(): import("../../structures/misc/WebhookInfo").WebhookInfo; /** A simple method for testing your bot's authentication token. Requires no parameters. Returns basic information about the bot in form of a User object. */ - getMe(): import("../../structures/misc/ClientUser").ClientUser; + getMe(): import("../../structures/misc/client/ClientUser").ClientUser; /** 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. */ logOut(): true; @@ -137,12 +138,14 @@ export type ApiMethods = { sendMessage(args: { /** Unique identifier of the business connection on behalf of which the message will be sent */ businessConnectionId?: string; - /** Unique identifier for the target chat or username of the target channel (in the format @channelusername) */ + /** Unique identifier for the target chat or username of the target channel (bot, supergroup or channel in the format @username) */ chatId: number | string; /** 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 */ messageThreadId?: string | number; /** Identifier of the direct messages topic to which the message will be sent; required if the message is sent to a direct messages chat */ directMessagesTopicId?: number; + /** An object containing the parameters of the ephemeral message to send */ + ephemeralMessageParameters?: EphemeralMessageParameters; /** Text of the message to be sent, 1-4096 characters after entities parsing */ text: string; /** Mode for parsing entities in the message text. See formatting options for more details. */ @@ -177,7 +180,7 @@ export type ApiMethods = { chatId: number | string; /** Unique identifier for the target message thread */ messageThreadId?: string | number; - /** Unique identifier of the message draft; must be non-zero. Changes of drafts with the same identifier are animated */ + /** Unique identifier of the message draft; must be non-zero. Changes to drafts with the same identifier are animated. Otherwise, the draft is replaced without animation. */ draftId: number; /** Text of the message to be sent, 1-4096 characters after entities parsing */ text: string; @@ -185,11 +188,49 @@ export type ApiMethods = { parseMode?: ParseMode; /** A list of special entities that appear in message text, which can be specified instead of parse_mode */ entities?: MessageEntity[]; + /** Pass True to show the user a button to stop further drafts. The bot will receive an Update “stopped_message_generation” if the user presses the button. */ + canStop?: boolean; + /** Pass True to keep the draft in the chat when the button is pressed. The draft will still disappear after a short time or if the bot sends a message. To fully preserve the partial draft, the bot should send it as a new message. */ + keepOnStop?: boolean; }): true; + /** Use this method to send rich messages. If the message contains a block with a media element, then the bot must have the right to send the media to the chat. On success, the sent Message is returned. */ + sendRichMessage(args: { + /** Unique identifier of the business connection on behalf of which the message will be sent */ + businessConnectionId?: string; + /** Unique identifier for the target chat or username of the target bot, supergroup or channel in the format @username */ + chatId: number | string; + /** 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 */ + messageThreadId?: number | string; + /** Identifier of the direct messages topic to which the message will be sent; required if the message is sent to a direct messages chat */ + directMessagesTopicId?: number | string; + /** The message to be sent */ + richMessage: InputRichMessage; + /** Sends the message silently. Users will receive a notification with no sound. */ + disableNotification?: boolean; + /** Protects the contents of the sent message from forwarding and saving */ + protectContent?: boolean; + /** Pass True to allow up to 1000 messages per second, ignoring broadcasting limits for a fee of 0.1 Telegram Stars per message. The relevant Stars will be withdrawn from the bot's balance. */ + allowPaidBroadcast?: boolean; + /** Unique identifier of the message effect to be added to the message; for private chats only */ + messageEffectId?: string; + /** 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. */ + suggestedPostParameters?: SuggestedPostParameters; + /** Description of the message to reply to */ + replyParameters?: ReplyParameters; + /** Additional interface options. An object for an inline keyboard, custom reply keyboard, instructions to remove a reply keyboard or to force a reply from the user. */ + replyMarkup?: + | InlineKeyboardMarkup + | ReplyKeyboardMarkup + | ReplyKeyboardRemove + | ForceReply; + }): import("../../structures/message/Message").Message & { + richMessage: import("../../structures/message/RichMessage").RichMessage; + }; + /** Use this method to forward messages of any kind. Service messages and messages with protected content can't be forwarded. On success, the sent Message is returned. */ forwardMessage(args: { - /** Unique identifier for the target chat or username of the target channel (in the format @channelusername) */ + /** Unique identifier for the target chat or username of the target channel (bot, supergroup or channel in the format @username) */ chatId: number | string; /** 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 */ messageThreadId?: string | number; @@ -199,7 +240,7 @@ export type ApiMethods = { suggestedPostParameters?: SuggestedPostParameters; /** Identifier of the direct messages topic to which the message will be sent; required if the message is sent to a direct messages chat */ directMessagesTopicId?: number; - /** Unique identifier for the chat where the original message was sent (or channel username in the format @channelusername) */ + /** Unique identifier for the chat where the original message was sent (or username of the target bot, supergroup or channel in the format @username) */ fromChatId: number | string; /** New start timestamp for the copied video in the message */ videoStartTimestamp?: number; @@ -211,15 +252,15 @@ export type ApiMethods = { messageId: string | number; }): import("../../structures/message/Message").Message; - /** Use this method to forward multiple messages of any kind. If some of the specified messages can't be found or forwarded, they are skipped. Service messages and messages with protected content can't be forwarded. Album grouping is kept for forwarded messages. On success, an array of MessageId of the sent messages is returned. */ + /** Use this method to forward multiple messages of any kind. If some of the specified messages can't be found or forwarded, they are skipped. Service messages and messages with protected content can't be forwarded. Album grouping is kept for forwarded messages. On success, an Array of MessageId of the sent messages is returned. */ forwardMessages(args: { - /** Unique identifier for the target chat or username of the target channel (in the format @channelusername) */ + /** Unique identifier for the target chat or username of the target channel (bot, supergroup or channel in the format @username) */ chatId: number | string; /** 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 */ messageThreadId?: string | number; /** Identifier of the direct messages topic to which the message will be sent; required if the message is sent to a direct messages chat */ directMessagesTopicId?: number; - /** Unique identifier for the chat where the original messages were sent (or channel username in the format @channelusername) */ + /** Unique identifier for the chat where the original messages were sent (or username of the target bot, supergroup or channel in the format @username) */ fromChatId: number | string; /** A list of 1-100 identifiers of messages in the chat fromChatId to forward. The identifiers must be specified in a strictly increasing order. */ messageIds: (string | number)[]; @@ -231,13 +272,13 @@ export type ApiMethods = { /** Use this method to copy messages of any kind. Service messages, paid media messages, giveaway messages, giveaway winners messages, and invoice messages can't be copied. A quiz poll can be copied only if the value of the field correctOptionId is known to the bot. The method is analogous to the method forwardMessage, but the copied message doesn't have a link to the original message. Returns the MessageId of the sent message on success. */ copyMessage(args: { - /** Unique identifier for the target chat or username of the target channel (in the format @channelusername) */ + /** Unique identifier for the target chat or username of the target channel (bot, supergroup or channel in the format @username) */ chatId: number | string; /** 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 */ messageThreadId?: string | number; /** Identifier of the direct messages topic to which the message will be sent; required if the message is sent to a direct messages chat */ directMessagesTopicId?: number; - /** Unique identifier for the chat where the original message was sent (or channel username in the format @channelusername) */ + /** Unique identifier for the chat where the original message was sent (or username of the target bot, supergroup or channel in the format @username) */ fromChatId: number | string; /** New start timestamp for the copied video in the message */ videoStartTimestamp?: number; @@ -269,15 +310,15 @@ export type ApiMethods = { | ForceReply; }): number; - /** Use this method to copy messages of any kind. If some of the specified messages can't be found or copied, they are skipped. Service messages, paid media messages, giveaway messages, giveaway winners messages, and invoice messages can't be copied. A quiz poll can be copied only if the value of the field correctOptionId is known to the bot. The method is analogous to the method forwardMessages, but the copied messages don't have a link to the original message. Album grouping is kept for copied messages. On success, an array of MessageId of the sent messages is returned. */ + /** Use this method to copy messages of any kind. If some of the specified messages can't be found or copied, they are skipped. Service messages, paid media messages, giveaway messages, giveaway winners messages, and invoice messages can't be copied. A quiz poll can be copied only if the value of the field correctOptionId is known to the bot. The method is analogous to the method forwardMessages, but the copied messages don't have a link to the original message. Album grouping is kept for copied messages. On success, an Array of MessageId of the sent messages is returned. */ copyMessages(args: { - /** Unique identifier for the target chat or username of the target channel (in the format @channelusername) */ + /** Unique identifier for the target chat or username of the target channel (bot, supergroup or channel in the format @username) */ chatId: number | string; /** 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 */ messageThreadId?: string | number; /** Identifier of the direct messages topic to which the message will be sent; required if the message is sent to a direct messages chat */ directMessagesTopicId?: number; - /** Unique identifier for the chat where the original messages were sent (or channel username in the format @channelusername) */ + /** Unique identifier for the chat where the original messages were sent (or username of the target bot, supergroup or channel in the format @username) */ fromChatId: number | string; /** A list of 1-100 identifiers of messages in the chat fromChatId to copy. The identifiers must be specified in a strictly increasing order. */ messageIds: (string | number)[]; @@ -293,7 +334,7 @@ export type ApiMethods = { sendPhoto(args: { /** Unique identifier of the business connection on behalf of which the message will be sent */ businessConnectionId?: string; - /** Unique identifier for the target chat or username of the target channel (in the format @channelusername) */ + /** Unique identifier for the target chat or username of the target channel (bot, supergroup or channel in the format @username) */ chatId: number | string; /** 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 */ messageThreadId?: string | number; @@ -333,18 +374,64 @@ export type ApiMethods = { photo: import("../../structures/media/Photo").Photo; }; + /** Use this method to send live photos. On success, the sent Message is returned. */ + sendLivePhoto(args: { + /** Unique identifier of the business connection on behalf of which the message will be sent */ + businessConnectionId?: string; + /** Unique identifier for the target chat or username of the target channel (in the format @channelusername) */ + chatId: number | string; + /** 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 */ + messageThreadId?: number | string; + /** Identifier of the direct messages topic to which the message will be sent; required if the message is sent to a direct messages chat */ + directMessagesTopicId?: number | string; + /** Live photo video to send. Pass a file_id as String to send a video that exists on the Telegram servers (recommended) or upload a new video using multipart/form-data. Sending live photos by a URL is currently unsupported. */ + livePhoto: MediaDataParam; + /** The static photo to send. Pass a file_id as String to send a photo that exists on the Telegram servers (recommended) or upload a new video using multipart/form-data. Sending live photos by a URL is currently unsupported. */ + photo: MediaDataParam; + /** Video caption (may also be used when resending videos by file_id), 0-1024 characters after entities parsing */ + caption?: string; + /** Mode for parsing entities in the video caption. See formatting options for more details. */ + parseMode?: ParseMode; + /** A list of special entities that appear in the caption, which can be specified instead of parse_mode */ + captionEntities?: MessageEntity[]; + /** Pass True, if the caption must be shown above the message media */ + showCaptionAboveMedia?: boolean; + /** Pass True if the video needs to be covered with a spoiler animation */ + hasSpoiler?: boolean; + /** Sends the message silently. Users will receive a notification with no sound. */ + disableNotification?: boolean; + /** Protects the contents of the sent message from forwarding and saving */ + protectContent?: boolean; + /** Pass True to allow up to 1000 messages per second, ignoring broadcasting limits for a fee of 0.1 Telegram Stars per message. The relevant Stars will be withdrawn from the bot's balance. */ + allowPaidBroadcast?: boolean; + /** Unique identifier of the message effect to be added to the message; for private chats only */ + messageEffectId?: string; + /** 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. */ + suggestedPostParameters?: SuggestedPostParameters; + /** Description of the message to reply to */ + replyParameters?: ReplyParameters; + /** Additional interface options. An object for an inline keyboard, custom reply keyboard, instructions to remove a reply keyboard or to force a reply from the user. */ + replyMarkup?: + | InlineKeyboardMarkup + | ReplyKeyboardMarkup + | ReplyKeyboardRemove + | ForceReply; + }): import("../../structures/message/Message").Message & { + livePhoto: import("../../structures/media/LivePhoto").LivePhoto; + }; + /** Use this method to send audio files, if you want Telegram clients to display them in the music player. Your audio must be in the .MP3 or .M4A format. On success, the sent Message is returned. Bots can currently send audio files of up to 50 MB in size, this limit may be changed in the future. For sending voice messages, use the sendVoice method instead. */ sendAudio(args: { /** Unique identifier of the business connection on behalf of which the message will be sent */ businessConnectionId?: string; - /** Unique identifier for the target chat or username of the target channel (in the format @channelusername) */ + /** Unique identifier for the target chat or username of the target channel (bot, supergroup or channel in the format @username) */ chatId: number | string; /** 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 */ messageThreadId?: string | number; /** Identifier of the direct messages topic to which the message will be sent; required if the message is sent to a direct messages chat */ - directMessagesTopicId?: number; + directMessagesTopicId?: number | string; /** Audio file to send. Pass a fileId as String to send an audio file that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get an audio file from the Internet, or upload a new one using multipart/form-data. */ audio: MediaDataParam; /** Audio caption, 0-1024 characters after entities parsing */ @@ -395,12 +482,12 @@ export type ApiMethods = { sendDocument(args: { /** Unique identifier of the business connection on behalf of which the message will be sent */ businessConnectionId?: string; - /** Unique identifier for the target chat or username of the target channel (in the format @channelusername) */ + /** Unique identifier for the target chat or username of the target channel (bot, supergroup or channel in the format @username) */ chatId: number | string; /** 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 */ messageThreadId?: string | number; /** Identifier of the direct messages topic to which the message will be sent; required if the message is sent to a direct messages chat */ - directMessagesTopicId?: number; + directMessagesTopicId?: number | string; /** File to send. Pass a fileId as String to send a file that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get a file from the Internet, or upload a new one using multipart/form-data. */ document: MediaDataParam; /** Thumbnail of the file sent; can be ignored if thumbnail generation for the file is supported server-side. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail's width and height should not exceed 320. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can't be reused and can be only uploaded as a new file, so you can pass "attach://" if the thumbnail was uploaded using multipart/form-data under . */ @@ -447,12 +534,12 @@ export type ApiMethods = { sendVideo(args: { /** Unique identifier of the business connection on behalf of which the message will be sent */ businessConnectionId?: string; - /** Unique identifier for the target chat or username of the target channel (in the format @channelusername) */ + /** Unique identifier for the target chat or username of the target channel (bot, supergroup or channel in the format @username) */ chatId: number | string; /** 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 */ messageThreadId?: string | number; /** Identifier of the direct messages topic to which the message will be sent; required if the message is sent to a direct messages chat */ - directMessagesTopicId?: number; + directMessagesTopicId?: number | string; /** Video to send. Pass a fileId as String to send a video that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get a video from the Internet, or upload a new video using multipart/form-data. */ video: MediaDataParam; /** Duration of sent video in seconds */ @@ -514,19 +601,21 @@ export type ApiMethods = { | ReplyKeyboardRemove | ForceReply; }): import("../../structures/message/Message").Message & { - video: import("../../structures/media/Video").Video; + video: import("../../structures/media/video/Video").Video; }; /** Use this method to send animation files (GIF or H.264/MPEG-4 AVC video without sound). On success, the sent Message is returned. Bots can currently send animation files of up to 50 MB in size, this limit may be changed in the future. */ sendAnimation(args: { /** Unique identifier of the business connection on behalf of which the message will be sent */ businessConnectionId?: string; - /** Unique identifier for the target chat or username of the target channel (in the format @channelusername) */ + /** Unique identifier for the target chat or username of the target channel (bot, supergroup or channel in the format @username) */ chatId: number | string; /** 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 */ messageThreadId?: string | number; /** Identifier of the direct messages topic to which the message will be sent; required if the message is sent to a direct messages chat */ - directMessagesTopicId?: number; + directMessagesTopicId?: number | string; + /** An object containing the parameters of the ephemeral message to send */ + ephemeralMessageParameters?: EphemeralMessageParameters; /** Animation to send. Pass a fileId as String to send an animation that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get an animation from the Internet, or upload a new animation using multipart/form-data. */ animation: MediaDataParam; /** Duration of sent animation in seconds */ @@ -581,12 +670,14 @@ export type ApiMethods = { sendVoice(args: { /** Unique identifier of the business connection on behalf of which the message will be sent */ businessConnectionId?: string; - /** Unique identifier for the target chat or username of the target channel (in the format @channelusername) */ + /** Unique identifier for the target chat or username of the target channel (bot, supergroup or channel in the format @username) */ chatId: number | string; /** 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 */ messageThreadId?: string | number; /** Identifier of the direct messages topic to which the message will be sent; required if the message is sent to a direct messages chat */ - directMessagesTopicId?: number; + directMessagesTopicId?: number | string; + /** An object containing the parameters of the ephemeral message to send */ + ephemeralMessageParameters?: EphemeralMessageParameters; /** Audio file to send. Pass a fileId as String to send a file that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get a file from the Internet, or upload a new one using multipart/form-data. */ voice: MediaDataParam; /** Voice message caption, 0-1024 characters after entities parsing */ @@ -624,10 +715,12 @@ export type ApiMethods = { sendVideoNote(args: { /** Unique identifier of the business connection on behalf of which the message will be sent */ businessConnectionId?: string; - /** Unique identifier for the target chat or username of the target channel (in the format @channelusername) */ + /** Unique identifier for the target chat or username of the target channel (bot, supergroup or channel in the format @username) */ chatId: number | string; /** 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 */ messageThreadId?: string | number; + /** An object containing the parameters of the ephemeral message to send */ + ephemeralMessageParameters?: EphemeralMessageParameters; /** Video note to send. Pass a fileId as String to send a video note that exists on the Telegram servers (recommended) or upload a new video using multipart/form-data.. Sending video notes by a URL is currently unsupported */ videoNote: MediaDataParam; /** Duration of sent video in seconds */ @@ -663,23 +756,24 @@ export type ApiMethods = { | ReplyKeyboardRemove | ForceReply; }): import("../../structures/message/Message").Message & { - videoNote: import("../../structures/media/VideoNote").VideoNote; + videoNote: import("../../structures/media/video/VideoNote").VideoNote; }; - /** Use this method to send a group of photos, videos, documents or audios as an album. Documents and audio files can be only grouped in an album with messages of the same type. On success, an array of Messages that were sent is returned. */ + /** Use this method to send a group of photos, videos, documents or audios as an album. Documents and audio files can be only grouped in an album with messages of the same type. On success, an Array of Messages that were sent is returned. */ sendMediaGroup(args: { /** Unique identifier of the business connection on behalf of which the message will be sent */ businessConnectionId?: string; - /** Unique identifier for the target chat or username of the target channel (in the format @channelusername) */ + /** Unique identifier for the target chat or username of the target channel (bot, supergroup or channel in the format @username) */ chatId: number | string; /** 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 */ messageThreadId?: string | number; /** Identifier of the direct messages topic to which the message will be sent; required if the message is sent to a direct messages chat */ directMessagesTopicId?: number; /** An array describing messages to be sent, must include 2-10 items */ - media: ReadonlyArray< - InputMediaAudio | InputMediaDocument | InputMediaPhoto | InputMediaVideo - >; + media: + | ReadonlyArray + | ReadonlyArray + | ReadonlyArray; /** Sends the messages silently. Users will receive a notification with no sound. */ disableNotification?: boolean; /** Protects the contents of the sent messages from forwarding and saving */ @@ -701,7 +795,10 @@ export type ApiMethods = { photo: import("../../structures/media/Photo").Photo; }) | (import("../../structures/message/Message").Message & { - video: import("../../structures/media/Video").Video; + livePhoto: import("../../structures/media/LivePhoto").LivePhoto; + }) + | (import("../../structures/message/Message").Message & { + video: import("../../structures/media/video/Video").Video; }) >; @@ -709,19 +806,21 @@ export type ApiMethods = { sendLocation(args: { /** Unique identifier of the business connection on behalf of which the message will be sent */ businessConnectionId?: string; - /** Unique identifier for the target chat or username of the target channel (in the format @channelusername) */ + /** Unique identifier for the target chat or username of the target channel (bot, supergroup or channel in the format @username) */ chatId: number | string; /** 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 */ messageThreadId?: string | number; /** Identifier of the direct messages topic to which the message will be sent; required if the message is sent to a direct messages chat */ directMessagesTopicId?: number; + /** An object containing the parameters of the ephemeral message to send */ + ephemeralMessageParameters?: EphemeralMessageParameters; /** Latitude of the location */ latitude: number; /** Longitude of the location */ longitude: number; /** The radius of uncertainty for the location, measured in meters; 0-1500 */ horizontalAccuracy?: number; - /** Period in seconds during which the location will be updated (see Live Locations, should be between 60 and 86400, or 0x7FFFFFFF for live locations that can be edited indefinitely. */ + /** Period in seconds during which the location will be updated (see Live Locations), must be between 60 and 86400, or 0x7FFFFFFF for live locations that can be edited indefinitely. Must be 0 for ephemeral messages. */ livePeriod?: number; /** The direction in which user is moving, in degrees; 1-360. For active live locations only. */ heading?: number; @@ -753,7 +852,7 @@ export type ApiMethods = { editMessageLiveLocation(args: { /** Unique identifier of the business connection on behalf of which the message to be edited was sent */ businessConnectionId?: string; - /** Required if inlineMessageId is not specified. Unique identifier for the target chat or username of the target channel (in the format @channelusername) */ + /** Required if inlineMessageId is not specified. Unique identifier for the target chat or username of the target channel (bot, supergroup or channel in the format @username) */ chatId?: number | string; /** Required if inlineMessageId is not specified. Identifier of the message to edit */ messageId?: string | number; @@ -786,7 +885,7 @@ export type ApiMethods = { stopMessageLiveLocation(args: { /** Unique identifier of the business connection on behalf of which the message to be edited was sent */ businessConnectionId?: string; - /** Required if inlineMessageId is not specified. Unique identifier for the target chat or username of the target channel (in the format @channelusername) */ + /** Required if inlineMessageId is not specified. Unique identifier for the target chat or username of the target channel (bot, supergroup or channel in the format @username) */ chatId?: number | string; /** Required if inlineMessageId is not specified. Identifier of the message with live location to stop */ messageId?: string | number; @@ -807,13 +906,13 @@ export type ApiMethods = { sendPaidMedia(args: { /** Unique identifier of the business connection on behalf of which the message will be sent */ businessConnectionId?: string; - /** 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 */ + /** Unique identifier for the target chat or username of the target channel in the format `@username`. 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 */ chatId: number | string; /** 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 */ messageThreadId?: number; - /** The number of Telegram Stars that must be paid to buy access to the media; 1-2500 */ + /** The number of Telegram Stars that must be paid to buy access to the media; 1-25000 */ starCount: number; - /** An array describing the media to be sent; up to 10 items */ + /** An Array describing the media to be sent; up to 10 items */ media: InputPaidMedia[]; /** Bot-defined paid media payload, 0-128 bytes. This will not be displayed to the user, use it for your internal processes. */ payload?: string; @@ -849,12 +948,14 @@ export type ApiMethods = { sendVenue(args: { /** Unique identifier of the business connection on behalf of which the message will be sent */ businessConnectionId?: string; - /** Unique identifier for the target chat or username of the target channel (in the format @channelusername) */ + /** Unique identifier for the target chat or username of the target channel (bot, supergroup or channel in the format @username) */ chatId: number | string; /** 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 */ messageThreadId?: string | number; /** Identifier of the direct messages topic to which the message will be sent; required if the message is sent to a direct messages chat */ directMessagesTopicId?: number; + /** An object containing the parameters of the ephemeral message to send */ + ephemeralMessageParameters?: EphemeralMessageParameters; /** Latitude of the venue */ latitude: number; /** Longitude of the venue */ @@ -897,12 +998,14 @@ export type ApiMethods = { sendContact(args: { /** Unique identifier of the business connection on behalf of which the message will be sent */ businessConnectionId?: string; - /** Unique identifier for the target chat or username of the target channel (in the format @channelusername) */ + /** Unique identifier for the target chat or username of the target channel (bot, supergroup or channel in the format @username) */ chatId: number | string; /** 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 */ messageThreadId?: string | number; /** Identifier of the direct messages topic to which the message will be sent; required if the message is sent to a direct messages chat */ directMessagesTopicId?: number; + /** An object containing the parameters of the ephemeral message to send */ + ephemeralMessageParameters?: EphemeralMessageParameters; /** Contact's phone number */ phoneNumber: string; /** Contact's first name */ @@ -937,7 +1040,7 @@ export type ApiMethods = { sendPoll(args: { /** Unique identifier of the business connection on behalf of which the message will be sent */ businessConnectionId?: string; - /** 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. */ + /** Unique identifier for the target chat or username of the target channel (bot, supergroup or channel in the format @username). Polls can't be sent to channel direct messages chats. */ chatId: number | string; /** 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 */ messageThreadId?: string | number; @@ -963,6 +1066,10 @@ export type ApiMethods = { allowAddingOptions?: boolean; /** Pass True, if poll results must be shown only after the poll closes */ hideResultsUntilCloses?: boolean; + /** Pass True, if voting is limited to users who have been members of the chat where the poll is being sent for more than 24 hours; for channel chats only */ + membersOnly?: boolean; + /** A list of 0-12 two-letter ISO 3166-1 alpha-2 country codes indicating the countries from which users can vote in the poll; for channel chats only. Use “FT” as a country code to allow users with anonymous numbers to vote. If omitted or empty, then users from any country can participate in the poll. */ + countryCodes?: string[]; /** A list of monotonically increasing 0-based identifiers of the correct answer options, required for polls in quiz mode */ correctOptionIds?: number[]; /** Text that is shown when a user chooses an incorrect answer or taps on the lamp icon in a quiz-style poll, 0-200 characters with at most 2 line feeds after entities parsing */ @@ -971,12 +1078,16 @@ export type ApiMethods = { explanationParseMode?: ParseMode; /** A list of special entities that appear in the poll explanation. It can be specified instead of explanationParseMode */ explanationEntities?: MessageEntity[]; + /** Media added to the quiz explanation */ + explanationMedia?: InputPollMedia; /** Description of the poll to be sent, 0-1024 characters after entities parsing */ description?: string; /** Mode for parsing entities in the poll description. See formatting options for more details. */ descriptionParseMode?: ParseMode; /** A list of special entities that appear in the poll description, which can be specified instead of description_parse_mode */ descriptionEntities?: MessageEntity[]; + /** Media added to the poll description */ + media?: InputPollMedia; /** Amount of time in seconds the poll will be active after creation, 5-2628000. Can't be used together with close_date. */ openPeriod?: number; /** Point in time (Unix timestamp) when the poll will be automatically closed. Must be at least 5 and no more than 2628000 seconds in the future. Can't be used together with open_period. */ @@ -1000,7 +1111,7 @@ export type ApiMethods = { | ReplyKeyboardRemove | ForceReply; }): import("../../structures/message/Message").Message & { - poll: import("../../structures/media/Poll").Poll; + poll: import("../../structures/media/poll/Poll").Poll; }; /** Use this method to send a checklist on behalf of a connected business account. On success, the sent Message is returned. */ @@ -1045,12 +1156,12 @@ export type ApiMethods = { sendDice(args: { /** Unique identifier of the business connection on behalf of which the message will be sent */ businessConnectionId?: string; - /** Unique identifier for the target chat or username of the target channel (in the format @channelusername) */ + /** Unique identifier for the target chat or username of the target channel (bot, supergroup or channel in the format @username) */ chatId: number | string; /** 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 */ messageThreadId?: string | number; /** Identifier of the direct messages topic to which the message will be sent; required if the message is sent to a direct messages chat */ - directMessagesTopicId?: number; + directMessagesTopicId?: number | string; /** Emoji on which the dice throw animation is based. Currently, must be one of "🎲", "🎯", "🏀", "⚽", "🎳", or "🎰". Dice can have values 1-6 for "🎲", "🎯" and "🎳", values 1-5 for "🏀" and "⚽", and values 1-64 for "🎰". Defaults to "🎲" */ emoji?: string; /** Sends the message silently. Users will receive a notification with no sound. */ @@ -1075,6 +1186,22 @@ export type ApiMethods = { dice: import("../../structures/media/Dice").Dice; }; + /** Use this method to stream a partial rich message to a user while the message is being generated. Note that the streamed draft is ephemeral and acts as a temporary 30-second preview - once the output is finalized, you must call sendRichMessage with the complete message to persist it in the user's chat. Returns True on success. */ + sendRichMessageDraft(args: { + /** Unique identifier for the target private chat */ + chatId: string | number; + /** Unique identifier for the target message thread */ + messageThreadId?: string | number; + /** Unique identifier of the message draft; must be non-zero. Changes to drafts with the same identifier are animated. Otherwise, the draft is replaced without animation. */ + draftId: number; + /** The partial message to be streamed. Direct upload of new files and explicit upload of files by a URL isn't supported. */ + richMessage: InputRichMessage; + /** Pass True to show the user a button to stop further drafts. The bot will receive an Update “stopped_message_generation” if the user presses the button. */ + canStop?: boolean; + /** Pass True to keep the draft in the chat when the button is pressed. The draft will still disappear after a short time or if the bot sends a message. To fully preserve the partial draft, the bot should send it as a new message. */ + keepOnStop?: boolean; + }): true; + /** 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. Example: The ImageBot needs some time to process a request and upload the image. Instead of sending a text message along the lines of "Retrieving image, please wait...", the bot may use sendChatAction with action = upload_photo. The user will see a "sending photo" status for the bot. @@ -1114,7 +1241,7 @@ export type ApiMethods = { /** 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. In albums, bots must react to the first message. Returns True on success. */ setMessageReaction(args: { - /** Unique identifier for the target chat or username of the target channel (in the format @channelusername) */ + /** Unique identifier for the target chat or username of the target channel (bot, supergroup or channel in the format @username) */ chatId: number | string; /** Identifier of the target message */ messageId: string | number; @@ -1132,7 +1259,7 @@ export type ApiMethods = { offset?: number; /** Limits the number of photos to be retrieved. Values between 1-100 are accepted. Defaults to 100. */ limit?: number; - }): import("../../structures/misc/UserProfilePhotos").UserProfilePhotos; + }): import("../../structures/misc/user/UserProfilePhotos").UserProfilePhotos; /** Use this method to get a list of profile audios for a user. Returns a UserProfileAudios object. */ getUserProfileAudios(args: { @@ -1142,7 +1269,7 @@ export type ApiMethods = { offset?: number; /** Limits the number of audios to be retrieved. Values between 1-100 are accepted. Defaults to 100. */ limit?: number; - }): import("../../structures/misc/UserProfileAudios").UserProfileAudios; + }): import("../../structures/misc/user/UserProfileAudios").UserProfileAudios; /** Changes the emoji status for a given user that previously allowed the bot to manage their emoji status via the Mini App method requestEmojiStatusAccess. Returns True on success. */ setUserEmojiStatus(args: { @@ -1164,7 +1291,7 @@ export type ApiMethods = { /** Use this method to ban a user in a group, a supergroup or a channel. In the case of supergroups and channels, the user will not be able to return to the chat on their own using invite links, etc., unless unbanned first. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns True on success. */ banChatMember(args: { - /** Unique identifier for the target group or username of the target supergroup or channel (in the format @channelusername) */ + /** Unique identifier for the target group or username of the target supergroup or channel (bot, supergroup or channel in the format @username) */ chatId: number | string; /** Unique identifier of the target user */ userId: string | number; @@ -1176,7 +1303,7 @@ export type ApiMethods = { /** 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 onlyIfBanned. Returns True on success. */ unbanChatMember(args: { - /** Unique identifier for the target group or username of the target supergroup or channel (in the format @channelusername) */ + /** Unique identifier for the target group or username of the target supergroup or channel (bot, supergroup or channel in the format @username) */ chatId: number | string; /** Unique identifier of the target user */ userId: string | number; @@ -1200,7 +1327,7 @@ export type ApiMethods = { /** 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. */ promoteChatMember(args: { - /** Unique identifier for the target chat or username of the target channel (in the format @channelusername) */ + /** Unique identifier for the target chat or username of the target channel (bot, supergroup or channel in the format @username) */ chatId: number | string; /** Unique identifier of the target user */ userId: string | number; @@ -1232,7 +1359,7 @@ export type ApiMethods = { /** Use this method to ban a channel chat in a supergroup or a channel. Until the chat is unbanned, the owner of the banned chat won't be able to send messages on behalf of any of their channels. The bot must be an administrator in the supergroup or channel for this to work and must have the appropriate administrator rights. Returns True on success. */ banChatSenderChat(args: { - /** Unique identifier for the target chat or username of the target channel (in the format @channelusername) */ + /** Unique identifier for the target chat or username of the target channel (bot, supergroup or channel in the format @username) */ chatId: number | string; /** Unique identifier of the target sender chat */ senderChatId: string | number; @@ -1240,7 +1367,7 @@ export type ApiMethods = { /** 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. */ unbanChatSenderChat(args: { - /** Unique identifier for the target chat or username of the target channel (in the format @channelusername) */ + /** Unique identifier for the target chat or username of the target channel (bot, supergroup or channel in the format @username) */ chatId: number | string; /** Unique identifier of the target sender chat */ senderChatId: string | number; @@ -1260,13 +1387,13 @@ export type ApiMethods = { Note: Each administrator in a chat generates their own invite links. Bots can't use invite links generated by other administrators. If you want your bot to work with invite links, it will need to generate its own link using exportChatInviteLink or by calling the getChat method. If your bot needs to generate a new primary invite link replacing its previous one, use exportChatInviteLink again. */ exportChatInviteLink(args: { - /** Unique identifier for the target chat or username of the target channel (in the format @channelusername) */ + /** Unique identifier for the target chat or username of the target channel (bot, supergroup or channel in the format @username) */ chatId: number | string; }): string; /** Use this method to create an additional invite link for a chat. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. The link can be revoked using the method revokeChatInviteLink. Returns the new invite link as ChatInviteLink object. */ createChatInviteLink(args: { - /** Unique identifier for the target chat or username of the target channel (in the format @channelusername) */ + /** Unique identifier for the target chat or username of the target channel (bot, supergroup or channel in the format @username) */ chatId: number | string; /** Invite link name; 0-32 characters */ name?: string; @@ -1280,7 +1407,7 @@ export type ApiMethods = { /** Use this method to edit a non-primary invite link created by the bot. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns the edited invite link as a ChatInviteLink object. */ editChatInviteLink(args: { - /** Unique identifier for the target chat or username of the target channel (in the format @channelusername) */ + /** Unique identifier for the target chat or username of the target channel (bot, supergroup or channel in the format @username) */ chatId: number | string; /** The invite link to edit */ inviteLink: string; @@ -1296,7 +1423,7 @@ export type ApiMethods = { /** Use this method to create a subscription invite link for a channel chat. The bot must have the can_invite_users administrator rights. The link can be edited using the method editChatSubscriptionInviteLink or revoked using the method revokeChatInviteLink. Returns the new invite link as a ChatInviteLink object. */ createChatSubscriptionInviteLink(args: { - /** Unique identifier for the target channel chat or username of the target channel (in the format @channelusername) */ + /** Unique identifier for the target channel chat or username of the target channel (bot, supergroup or channel in the format @username) */ chatId: number | string; /** Invite link name; 0-32 characters */ name?: string; @@ -1308,7 +1435,7 @@ export type ApiMethods = { /** Use this method to edit a subscription invite link created by the bot. The bot must have the can_invite_users administrator rights. Returns the edited invite link as a ChatInviteLink object. */ editChatSubscriptionInviteLink(args: { - /** Unique identifier for the target channel chat or username of the target channel (in the format @channelusername) */ + /** Unique identifier for the target channel chat or username of the target channel (bot, supergroup or channel in the format @username) */ chatId: number | string; /** The invite link to edit */ inviteLink: string; @@ -1318,7 +1445,7 @@ export type ApiMethods = { /** Use this method to revoke an invite link created by the bot. If the primary link is revoked, a new link is automatically generated. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns the revoked invite link as ChatInviteLink object. */ revokeChatInviteLink(args: { - /** Unique identifier of the target chat or username of the target channel (in the format @channelusername) */ + /** Unique identifier of the target chat or username of the target channel (bot, supergroup or channel in the format @username) */ chatId: number | string; /** The invite link to revoke */ inviteLink: string; @@ -1336,9 +1463,25 @@ export type ApiMethods = { userId: number | string; }): string; + /** Use this method to get the access settings of a managed bot. Returns a BotAccessSettings object on success. */ + getManagedBotAccessSettings(args: { + /** User identifier of the managed bot whose access settings will be returned */ + userId: number | string; + }): import("../../structures/misc/client/BotAccessSettings").BotAccessSettings; + + /** Use this method to change the access settings of a managed bot. Returns True on success. */ + setManagedBotAccessSettings(args: { + /** User identifier of the managed bot whose access settings will be changed */ + userId: number | string; + /** Pass True, if only selected users can access the bot. The bot's owner can always access it. */ + isAccessRestricted: boolean; + /** A list of up to 10 identifiers of users who will have access to the bot in addition to its owner. Ignored if isAccessRestricted is false. */ + addedUserIds?: number[]; + }): true; + /** 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. */ approveChatJoinRequest(args: { - /** Unique identifier for the target chat or username of the target channel (in the format @channelusername) */ + /** Unique identifier for the target chat or username of the target channel (bot, supergroup or channel in the format @username) */ chatId: number | string; /** Unique identifier of the target user */ userId: string | number; @@ -1346,12 +1489,28 @@ export type ApiMethods = { /** 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. */ declineChatJoinRequest(args: { - /** Unique identifier for the target chat or username of the target channel (in the format @channelusername) */ + /** Unique identifier for the target chat or username of the target channel (bot, supergroup or channel in the format @username) */ chatId: number | string; /** Unique identifier of the target user */ userId: string | number; }): true; + /** Use this method to process a received chat join request query. Returns True on success. */ + answerChatJoinRequestQuery(args: { + /** Unique identifier of the join request query */ + chatJoinRequestQueryId: string; + /** Result of the query. Must be either “approve” to allow the user to join the chat, “decline” to disallow the user to join the chat, or “queue” to leave the decision to other administrators. */ + result: "approve" | "decline" | "queue"; + }): true; + + /** Use this method to process a received chat join request query by showing a Mini App to the user before deciding the outcome. Returns True on success. */ + sendChatJoinRequestWebApp(args: { + /** Unique identifier of the join request query */ + chatJoinRequestQueryId: string; + /** An HTTPS URL of a Web App to be opened with additional data as specified in Initializing Web Apps */ + webAppUrl: string; + }): true; + /** 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. */ approveSuggestedPost(args: { /** Unique identifier for the target direct messages chat */ @@ -1374,7 +1533,7 @@ export type ApiMethods = { /** 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. */ setChatPhoto(args: { - /** Unique identifier for the target chat or username of the target channel (in the format @channelusername) */ + /** Unique identifier for the target chat or username of the target channel (bot, supergroup or channel in the format @username) */ chatId: number | string; /** New chat photo, uploaded using multipart/form-data */ photo: MediaDataParam; @@ -1382,13 +1541,13 @@ export type ApiMethods = { /** 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. */ deleteChatPhoto(args: { - /** Unique identifier for the target chat or username of the target channel (in the format @channelusername) */ + /** Unique identifier for the target chat or username of the target channel (bot, supergroup or channel in the format @username) */ chatId: number | string; }): true; /** 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. */ setChatTitle(args: { - /** Unique identifier for the target chat or username of the target channel (in the format @channelusername) */ + /** Unique identifier for the target chat or username of the target channel (bot, supergroup or channel in the format @username) */ chatId: number | string; /** New chat title, 1-128 characters */ title: string; @@ -1396,7 +1555,7 @@ export type ApiMethods = { /** 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. */ setChatDescription(args: { - /** Unique identifier for the target chat or username of the target channel (in the format @channelusername) */ + /** Unique identifier for the target chat or username of the target channel (bot, supergroup or channel in the format @username) */ chatId: number | string; /** New chat description, 0-255 characters */ description?: string; @@ -1406,7 +1565,7 @@ export type ApiMethods = { pinChatMessage(args: { /** Unique identifier of the business connection on behalf of which the message will be pinned */ businessConnectionId?: string; - /** Unique identifier for the target chat or username of the target channel (in the format @channelusername) */ + /** Unique identifier for the target chat or username of the target channel (bot, supergroup or channel in the format @username) */ chatId: number | string; /** Identifier of a message to pin */ messageId: string | number; @@ -1418,7 +1577,7 @@ export type ApiMethods = { unpinChatMessage(args: { /** Unique identifier of the business connection on behalf of which the message will be unpinned */ businessConnectionId?: string; - /** Unique identifier for the target chat or username of the target channel (in the format @channelusername) */ + /** Unique identifier for the target chat or username of the target channel (bot, supergroup or channel in the format @username) */ chatId: number | string; /** Identifier of the message to unpin. Required if business_connection_id is specified. If not specified, the most recent pinned message (by sending date) will be pinned. */ messageId?: string | number; @@ -1426,44 +1585,54 @@ export type ApiMethods = { /** 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. */ unpinAllChatMessages(args: { - /** Unique identifier for the target chat or username of the target channel (in the format @channelusername) */ + /** Unique identifier for the target chat or username of the target channel (bot, supergroup or channel in the format @username) */ chatId: number | string; }): true; /** Use this method for your bot to leave a group, supergroup or channel. Returns True on success. */ leaveChat(args: { - /** Unique identifier for the target chat or username of the target supergroup or channel (in the format @channelusername). Channel direct messages chats aren't supported; leave the corresponding channel instead. */ + /** Unique identifier for the target chat or username of the target supergroup or channel (bot, supergroup or channel in the format @username). Channel direct messages chats aren't supported; leave the corresponding channel instead. */ chatId: number | string; }): true; /** Use this method to get up-to-date information about the chat. Returns a ChatFullInfo object on success. */ getChat(args: { - /** Unique identifier for the target chat or username of the target supergroup or channel (in the format @channelusername) */ + /** Unique identifier for the target chat or username of the target supergroup or channel (bot, supergroup or channel in the format @username) */ chatId: number | string; }): import("../../structures/chat/ChatFullInfo").ChatFullInfo; - /** Use this method to get a list of administrators in a chat, which aren't bots. Returns an Array of ChatMember objects. */ + /** Use this method to get a list of administrators in a chat. Returns an Array of ChatMember objects.. Returns an Array of ChatMember objects. */ getChatAdministrators(args: { - /** Unique identifier for the target chat or username of the target supergroup or channel (in the format @channelusername) */ + /** Unique identifier for the target chat or username of the target supergroup or channel (bot, supergroup or channel in the format @username) */ chatId: number | string; + /** Pass True to additionally receive all bots that are administrators of the chat. By default, bots other than the current bot are omitted. */ + return_bots?: boolean; }): Array< import("../../structures/chat/ChatAdministratorRights").ChatAdministratorRights >; /** Use this method to get the number of members in a chat. Returns Int on success. */ getChatMemberCount(args: { - /** Unique identifier for the target chat or username of the target supergroup or channel (in the format @channelusername) */ + /** Unique identifier for the target chat or username of the target supergroup or channel (bot, supergroup or channel in the format @username) */ chatId: number | string; }): number; /** 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 object on success. */ getChatMember(args: { - /** Unique identifier for the target chat or username of the target supergroup or channel (in the format @channelusername) */ + /** Unique identifier for the target chat or username of the target supergroup or channel (bot, supergroup or channel in the format @username) */ chatId: number | string; /** Unique identifier of the target user */ userId: string | number; }): import("../../structures/chat/ChatMember").ChatMember; + /** Use this method to get the last messages from the personal chat (i.e., the chat currently added to their profile) of a given user. On success, an Array of Message objects is returned. */ + getUserPersonalChatMessages(args: { + /** Unique identifier for the target user */ + user_id: number; + /** The maximum number of messages to return; 1-20 */ + limit: number; + }): Array; + /** Use this method to set a new group sticker set for a supergroup. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Use the field can_set_sticker_set ly returned in getChat requests to check if the bot can use this method. Returns True on success. */ setChatStickerSet(args: { /** Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername) */ @@ -1480,6 +1649,7 @@ export type ApiMethods = { /** 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 objects. */ getForumTopicIconStickers(): import("../../structures/media/Sticker").Sticker[]; + /** Use this method to create 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 right. Returns information about the created topic as a ForumTopic object. */ createForumTopic(args: { /** Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername) */ @@ -1592,9 +1762,17 @@ export type ApiMethods = { cacheTime?: number; }): true; + /** Use this method to reply to a received guest message. On success, a Identifier of the sent inline message is returned. */ + answerGuestQuery(args: { + /** Unique identifier for the query to be answered */ + guest_query_id: string; + /** An object describing the message to be sent */ + result: InlineQueryResult; + }): string; + /** Use this method to get the list of boosts added to a chat by a user. Requires administrator rights in the chat. Returns a UserChatBoosts object. */ getUserChatBoosts(args: { - /** Unique identifier for the chat or username of the channel (in the format @channelusername) */ + /** Unique identifier for the chat or username of the channel (bot, supergroup or channel in the format @username) */ chatId: number | string; /** Unique identifier of the target user */ userId: string | number; @@ -1624,7 +1802,7 @@ export type ApiMethods = { /** Returns the gifts owned by a chat. Returns OwnedGifts on success. */ getChatGifts(args: { - /** Unique identifier for the target chat or username of the target channel (in the format @channelusername) */ + /** Unique identifier for the target chat or username of the target channel (bot, supergroup or channel in the format @username) */ chatId: number | string; /** 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. */ excludeUnsaved?: boolean; @@ -1733,7 +1911,7 @@ export type ApiMethods = { /** Use this method to change the bot's menu button in a private chat, or the default menu button. Returns True on success. */ setChatMenuButton(args: { - /** Unique identifier for the target private chat. If not specified, default bot's menu button will be changed */ + /** Unique identifier for the target private chat. If not specified, the bot's default menu button will be changed.*/ chatId?: string | number; /** An object for the bot's new menu button. Defaults to MenuButtonDefault */ menuButton?: MenuButton; @@ -1741,7 +1919,7 @@ export type ApiMethods = { /** Use this method to get the current value of the bot's menu button in a private chat, or the default menu button. Returns MenuButton on success. */ getChatMenuButton(args: { - /** Unique identifier for the target private chat. If not specified, default bot's menu button will be returned */ + /** Unique identifier for the target private chat. If not specified, the bot's default menu button will be returned */ chatId?: string | number; }): import("../../structures/misc/MenuButton").MenuButton; @@ -1880,24 +2058,26 @@ export type ApiMethods = { /** A method to get the current Telegram Stars balance of the bot. Requires no parameters. On success, returns a StarAmount object. */ getMyStarBalance(): import("../../structures/misc/StarAmount").StarAmount; - /** Use this method to edit text and game messages. On success, if the edited message is not an inline message, the edited Message is returned, otherwise True is returned. Note that business messages that were not sent by the bot and do not contain an inline keyboard can only be edited within 48 hours from the time they were sent. */ + /** Use this method to edit text, rich and game messages. On success, if the edited message is not an inline message, the edited Message is returned, otherwise True is returned. Note that business messages that were not sent by the bot and do not contain an inline keyboard can only be edited within 48 hours from the time they were sent. */ editMessageText(args: { /** Unique identifier of the business connection on behalf of which the message to be edited was sent */ businessConnectionId?: string; - /** Required if inlineMessageId is not specified. Unique identifier for the target chat or username of the target channel (in the format @channelusername) */ + /** Required if inlineMessageId is not specified. Unique identifier for the target chat or username of the target channel (bot, supergroup or channel in the format @username) */ chatId?: number | string; /** Required if inlineMessageId is not specified. Identifier of the message to edit */ messageId?: string | number; /** Required if chatId and messageId are not specified. Identifier of the inline message */ inlineMessageId?: string | number; - /** New text of the message, 1-4096 characters after entities parsing */ - text: string; + /** New text of the message, 1-4096 characters after entity parsing; required if rich_message isn't specified */ + text?: string; /** Mode for parsing entities in the message text. See formatting options for more details. */ parseMode?: ParseMode; /** A list of special entities that appear in message text, which can be specified instead of parseMode */ entities?: MessageEntity[]; /** Link preview generation options for the message */ linkPreviewOptions?: LinkPreviewOptions; + /** New rich content of the message; required if text isn't specified. Direct upload of new files and explicit upload of files by a URL isn't supported when an inline message is edited. */ + richMessage?: InputRichMessage; /** An object for an inline keyboard. */ replyMarkup?: InlineKeyboardMarkup; }): @@ -1907,13 +2087,19 @@ export type ApiMethods = { editedTimestamp: number; editedAt: Date; }) + | (import("../../structures/message/Message").Message & { + richMessage: import("../../structures/message/RichMessage").RichMessage; + editedUnixTime: number; + editedTimestamp: number; + editedAt: Date; + }) | true; /** Use this method to edit captions of messages. On success, if the edited message is not an inline message, the edited Message is returned, otherwise True is returned. Note that business messages that were not sent by the bot and do not contain an inline keyboard can only be edited within 48 hours from the time they were sent. */ editMessageCaption(args: { /** Unique identifier of the business connection on behalf of which the message to be edited was sent */ businessConnectionId?: string; - /** Required if inlineMessageId is not specified. Unique identifier for the target chat or username of the target channel (in the format @channelusername) */ + /** Required if inlineMessageId is not specified. Unique identifier for the target chat or username of the target channel (bot, supergroup or channel in the format @username) */ chatId?: number | string; /** Required if inlineMessageId is not specified. Identifier of the message to edit */ messageId?: string | number; @@ -1938,11 +2124,11 @@ export type ApiMethods = { }) | true; - /** Use this method to edit animation, audio, document, photo, 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 fileId or specify a URL. On success, if the edited message is not an inline message, the edited Message is returned, otherwise True is returned. Note that business messages that were not sent by the bot and do not contain an inline keyboard can only be edited within 48 hours from the time they were sent. */ + /** Use this method to edit animation, audio, document, live photo, photo, or video messages, or to replace a text or a rich message with a media. 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, a live photo, or a video otherwise. When an inline message is edited, a new file can't be uploaded; use a previously uploaded file via its file_id or specify a URL. On success, if the edited message is not an inline message, the edited Message is returned, otherwise True is returned. Note that business messages that were not sent by the bot and do not contain an inline keyboard can only be edited within 48 hours from the time they were sent. */ editMessageMedia(args: { /** Unique identifier of the business connection on behalf of which the message to be edited was sent */ businessConnectionId?: string; - /** Required if inlineMessageId is not specified. Unique identifier for the target chat or username of the target channel (in the format @channelusername) */ + /** Required if inlineMessageId is not specified. Unique identifier for the target chat or username of the target channel (bot, supergroup or channel in the format @username) */ chatId?: number | string; /** Required if inlineMessageId is not specified. Identifier of the message to edit */ messageId?: string | number; @@ -1964,7 +2150,7 @@ export type ApiMethods = { editMessageReplyMarkup(args: { /** Unique identifier of the business connection on behalf of which the message to be edited was sent */ businessConnectionId?: string; - /** Required if inlineMessageId is not specified. Unique identifier for the target chat or username of the target channel (in the format @channelusername) */ + /** Required if inlineMessageId is not specified. Unique identifier for the target chat or username of the target channel (bot, supergroup or channel in the format @username) */ chatId?: number | string; /** Required if inlineMessageId is not specified. Identifier of the message to edit */ messageId?: string | number; @@ -1984,13 +2170,81 @@ export type ApiMethods = { stopPoll(args: { /** Unique identifier of the business connection on behalf of which the message to be edited was sent */ businessConnectionId?: string; - /** Unique identifier for the target chat or username of the target channel (in the format @channelusername) */ + /** Unique identifier for the target chat or username of the target channel (bot, supergroup or channel in the format @username) */ chatId: number | string; /** Identifier of the original message with the poll */ messageId: string | number; /** An object for a new message inline keyboard. */ replyMarkup?: InlineKeyboardMarkup; - }): Omit; + }): Omit; + + /** Use this method to edit an ephemeral text or rich message. Note that it is not guaranteed that the user will receive the message edit event, especially if they are offline. On success, True is returned. */ + editEphemeralMessageText(args: { + /** Unique identifier for the target chat or username of the target supergroup in the format `@username` */ + chatId: number | string; + /** Identifier of the user who received the message */ + receiverUserId: string | number; + /** Identifier of the ephemeral message to edit */ + ephemeralMessageId: string | number; + /** New text of the message, 1-4096 characters after entity parsing; required if rich_message isn't specified */ + text?: string; + /** Mode for parsing entities in the message text. See formatting options for more details. */ + parseMode?: ParseMode; + /** A list of special entities that appear in message text, which can be specified instead of parse_mode */ + entities?: MessageEntity[]; + /** Link preview generation options for the message */ + linkPreviewOptions?: LinkPreviewOptions; + /** New rich content of the message; required if text isn't specified */ + richMessage?: InputRichMessage; + /** An object for an inline keyboard */ + replyMarkup?: InlineKeyboardMarkup; + }): true; + + /** Use this method to edit the media of an ephemeral message. Note that it is not guaranteed that the user will receive the message edit event, especially if they are offline. On success, True is returned. */ + editEphemeralMessageMedia(args: { + /** Unique identifier for the target chat or username of the target supergroup in the format `@username` */ + chatId: number | string; + /** Identifier of the user who received the message */ + receiverUserId: string | number; + /** Identifier of the ephemeral message to edit */ + ephemeralMessageId: string | number; + /** An object for the new media content of the message */ + media: InputMedia; + /** An object for an inline keyboard */ + replyMarkup?: InlineKeyboardMarkup; + }): true; + + /** Use this method to edit the caption of an ephemeral message. Note that it is not guaranteed that the user will receive the message edit event, especially if they are offline. On success, True is returned. */ + editEphemeralMessageCaption(args: { + /** Unique identifier for the target chat or username of the target supergroup in the format `@username` */ + chatId: number | string; + /** Identifier of the user who received the message */ + receiverUserId: string | number; + /** Identifier of the ephemeral message to edit */ + ephemeralMessageId: string | number; + /** New caption of the message, 0-1024 characters after entities parsing */ + caption?: string; + /** Pass True if the caption must be shown above the message media. Supported only for animation, photo and video messages. */ + showCaptionAboveMedia?: boolean; + /** Mode for parsing entities in the message caption. See formatting options for more details. */ + parseMode?: ParseMode; + /** A list of special entities that appear in the caption, which can be specified instead of parse_mode */ + captionEntities?: MessageEntity[]; + /** An object for an inline keyboard */ + replyMarkup?: InlineKeyboardMarkup; + }): true; + + /** Use this method to edit only the reply markup of an ephemeral message. Note that it is not guaranteed that the user will receive the message edit event, especially if they are offline. On success, True is returned. */ + editEphemeralMessageReplyMarkup(args: { + /** Unique identifier for the target chat or username of the target supergroup in the format `@username` */ + chatId: number | string; + /** Identifier of the user who received the message */ + receiverUserId: string | number; + /** Identifier of the ephemeral message to edit */ + ephemeralMessageId: string | number; + /** An object for an inline keyboard */ + replyMarkup?: InlineKeyboardMarkup; + }): true; /** Use this method to delete a message, including service messages, with the following limitations: - A message can only be deleted if it was sent less than 48 hours ago. @@ -2004,20 +2258,52 @@ export type ApiMethods = { - If the bot has can_manage_direct_messages administrator right in a channel, it can delete any message in the corresponding direct messages chat. Returns True on success. */ deleteMessage(args: { - /** Unique identifier for the target chat or username of the target channel (in the format @channelusername) */ + /** Unique identifier for the target chat or username of the target channel (bot, supergroup or channel in the format @username) */ chatId: number | string; /** Identifier of the message to delete */ messageId: string | number; }): true; + /** Use this method to delete an ephemeral message. Note that it is not guaranteed that the user will receive the message deletion event, especially if they are offline. Returns True on success. */ + deleteEphemeralMessage(args: { + /** Unique identifier for the target chat or username of the target supergroup in the format `@username` */ + chatId: number | string; + /** Identifier of the user who received the message */ + receiverUserId: string | number; + /** Identifier of the ephemeral message to delete */ + ephemeralMessageId: string | number; + }): true; + /** Use this method to delete multiple messages simultaneously. Returns True on success. */ deleteMessages(args: { - /** Unique identifier for the target chat or username of the target channel (in the format @channelusername) */ + /** Unique identifier for the target chat or username of the target channel (bot, supergroup or channel in the format @username) */ chatId: number | string; /** A list of 1-100 identifiers of messages to delete. See deleteMessage for limitations on which messages can be deleted */ messageIds: (string | number)[]; }): true; + /** Use this method to remove a reaction from a message in a group or a supergroup chat. The bot must have the 'can_delete_messages' administrator right in the chat. Returns True on success. */ + deleteMessageReaction(args: { + /** Unique identifier for the target chat or username of the target supergroup (in the format `@username`) */ + chatId: number | string; + /** Identifier of the target message */ + messageId: number | string; + /** Identifier of the user whose reaction will be removed, if the reaction was added by a user */ + userId?: number | string; + /** Identifier of the chat whose reaction will be removed, if the reaction was added by a chat */ + actorChatId?: number | string; + }): true; + + /** Use this method to remove up to 10000 recent reactions in a group or a supergroup chat added by a given user or chat. The bot must have the 'can_delete_messages' administrator right in the chat. Returns True on success. */ + deleteAllMessageReactions(args: { + /** Unique identifier for the target chat or username of the target supergroup (in the format `@username`) */ + chatId: number | string; + /** Identifier of the user whose reactions will be removed, if the reactions were added by a user */ + userId?: number | string; + /** */ + actorChatId?: number | string; + }): true; + /** Delete messages on behalf of a business account. Requires the can_delete_outgoing_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. */ deleteBusinessMessages(args: { /** Unique identifier of the business connection on behalf of which to delete the messages */ @@ -2030,12 +2316,14 @@ export type ApiMethods = { sendSticker(args: { /** Unique identifier of the business connection on behalf of which the message will be sent */ businessConnectionId?: string; - /** Unique identifier for the target chat or username of the target channel (in the format @channelusername) */ + /** Unique identifier for the target chat or username of the target channel (bot, supergroup or channel in the format @username) */ chatId: number | string; /** 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 */ messageThreadId?: string | number; /** Identifier of the direct messages topic to which the message will be sent; required if the message is sent to a direct messages chat */ directMessagesTopicId?: number; + /** An object containing the parameters of the ephemeral message to send */ + ephemeralMessageParameters?: EphemeralMessageParameters; /** Sticker to send. Pass a fileId as String to send a file that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get a .WEBP sticker from the Internet, or upload a new .WEBP, .TGS, or .WEBM sticker using multipart/form-data. Video and animated stickers can't be sent via an HTTP URL. */ sticker: MediaDataParam; /** Emoji associated with the sticker; only for just uploaded stickers */ @@ -2180,7 +2468,7 @@ export type ApiMethods = { name: string; /** User identifier of the sticker set owner */ userId: string | number; - /** A .WEBP or .PNG image with the thumbnail, must be up to 128 kilobytes in size and have a width and height of exactly 100px, or a .TGS animation with a thumbnail up to 32 kilobytes in size (see https://core.telegram.org/stickers#animation-requirements for animated sticker technical requirements), or a .WEBM video with the thumbnail up to 32 kilobytes in size; see https://core.telegram.org/stickers#video-requirements for video sticker technical requirements. Pass a file_id as a String to send a file that already exists on the Telegram servers, pass an HTTP URL as a String for Telegram to get a file from the Internet, or upload a new one using multipart/form-data. More information on Sending Files ». Animated and video sticker set thumbnails can't be uploaded via HTTP URL. If omitted, then the thumbnail is dropped and the first sticker is used as the thumbnail. */ + /** A .WEBP or .PNG image with the thumbnail, must be up to 128 kilobytes in size and have a width and height of exactly 100px, or a .TGS animation with a thumbnail up to 32 kilobytes in size (see https://core.telegram.org/stickers#animation-requirements for animated sticker technical requirements), or a .WEBM video with the thumbnail up to 32 kilobytes in size; see https://core.telegram.org/stickers#video-requirements for video sticker technical requirements. Pass a file_id as a String to send a file that already exists on the Telegram servers, pass an HTTP URL as a String for Telegram to get a file from the Internet, or upload a new one using multipart/form-data.. Animated and video sticker set thumbnails can't be uploaded via HTTP URL. If omitted, then the thumbnail is dropped and the first sticker is used as the thumbnail. */ thumbnail?: | Buffer | ReadStream @@ -2273,7 +2561,7 @@ export type ApiMethods = { sendGift(args: { /** Required if chat_id is not specified. Unique identifier of the target user who will receive the gift. */ userId?: number | string; - /** 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. */ + /** Required if user_id is not specified. Unique identifier for the chat or username of the channel (bot, supergroup or channel in the format @username) that will receive the gift. */ chatId?: number | string; /** Identifier of the gift */ giftId: string; @@ -2318,7 +2606,7 @@ export type ApiMethods = { answerInlineQuery(args: { /** Unique identifier for the answered query */ inlineQueryId: string; - /** An array of results for the inline query */ + /** An Array of results for the inline query */ results: readonly InlineQueryResult[]; /** The maximum amount of time in seconds that the result of the inline query may be cached on the server. Defaults to 300. */ cacheTime?: number; @@ -2367,7 +2655,7 @@ export type ApiMethods = { /** Use this method to send invoices. On success, the sent Message is returned. */ sendInvoice(args: { - /** Unique identifier for the target chat or username of the target channel (in the format @channelusername) */ + /** Unique identifier for the target chat or username of the target channel (bot, supergroup or channel in the format @username) */ chatId: number | string; /** 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 */ messageThreadId?: string | number; @@ -2387,7 +2675,7 @@ export type ApiMethods = { prices: readonly LabeledPrice[]; /** The maximum accepted amount for tips in the smallest units of the currency (integer, not float/double). For example, for a maximum tip of US$ 1.45 pass maxTipAmount = 145. See the exp parameter in currencies.json, it shows the number of digits past the decimal point for each currency (2 for the majority of currencies). Defaults to 0. Not supported for payments in Telegram Stars. */ maxTipAmount?: number; - /** An array of suggested amounts of tips in the smallest units of the currency (integer, not float/double). At most 4 suggested tip amounts can be specified. The suggested tip amounts must be positive, passed in a strictly increased order and must not exceed maxTipAmount. */ + /** An Array of suggested amounts of tips in the smallest units of the currency (integer, not float/double). At most 4 suggested tip amounts can be specified. The suggested tip amounts must be positive, passed in a strictly increased order and must not exceed maxTipAmount. */ suggestedTipAmounts?: number[]; /** Unique deep-linking parameter. If left empty, forwarded copies of the sent message will have a Pay button, allowing multiple users to pay directly from the forwarded message, using the same invoice. If non-empty, forwarded copies of the sent message will have a URL button with a deep link to the bot (instead of a Pay button), with the value used as the start parameter */ startParameter?: string; @@ -2453,7 +2741,7 @@ export type ApiMethods = { subscriptionPeriod?: number; /** The maximum accepted amount for tips in the smallest units of the currency (integer, not float/double). For example, for a maximum tip of US$ 1.45 pass maxTipAmount = 145. See the exp parameter in currencies.json, it shows the number of digits past the decimal point for each currency (2 for the majority of currencies). Defaults to 0 */ maxTipAmount?: number; - /** An array of suggested amounts of tips in the smallest units of the currency (integer, not float/double). At most 4 suggested tip amounts can be specified. The suggested tip amounts must be positive, passed in a strictly increased order and must not exceed maxTipAmount. */ + /** An Array of suggested amounts of tips in the smallest units of the currency (integer, not float/double). At most 4 suggested tip amounts can be specified. The suggested tip amounts must be positive, passed in a strictly increased order and must not exceed maxTipAmount. */ suggestedTipAmounts?: number[]; /** Data about the invoice, which will be shared with the payment provider. A detailed description of required fields should be provided by the payment provider. */ providerData?: string; @@ -2501,7 +2789,7 @@ export type ApiMethods = { /** Verifies a chat on behalf of the organization which is represented by the bot. Returns True on success. */ verifyChat(args: { - /** Unique identifier for the target chat or username of the target channel (in the format @channelusername). Channel direct messages chats can't be verified. */ + /** Unique identifier for the target chat or username of the target channel (bot, supergroup or channel in the format @username). Channel direct messages chats can't be verified. */ chatId: number | string; /** Custom description for the verification; 0-70 characters. Must be empty if the organization isn't allowed to provide a custom verification description. */ customDescription?: string; @@ -2515,7 +2803,7 @@ export type ApiMethods = { /** Removes verification from a chat that is currently verified on behalf of the organization represented by the bot. Returns True on success. */ removeChatVerification(args: { - /** Unique identifier for the target chat or username of the target channel (in the format @channelusername) */ + /** Unique identifier for the target chat or username of the target channel (bot, supergroup or channel in the format @username) */ chatId: number | string; }): true; @@ -2525,7 +2813,7 @@ export type ApiMethods = { shippingQueryId: string; /** Pass True if delivery to the specified address is possible and False if there are any problems (for example, if delivery to the specified address is not possible) */ ok: boolean; - /** Required if ok is True. An array of available shipping options. */ + /** Required if ok is True. An Array of available shipping options. */ shippingOptions?: readonly ShippingOption[]; /** Required if ok is False. Error message in human readable form that explains why it is impossible to complete the order (e.g. "Sorry, delivery to your desired address is unavailable'). Telegram will display this message to the user. */ errorMessage?: string; @@ -2563,7 +2851,7 @@ export type ApiMethods = { setPassportDataErrors(args: { /** User identifier */ userId: string | number; - /** An array describing the errors */ + /** An Array describing the errors */ errors: readonly PassportElementError[]; }): true; @@ -2652,12 +2940,14 @@ export interface InputSticker { - InputMediaDocument - InputMediaAudio - InputMediaPhoto + - InputMediaLivePhoto - InputMediaVideo */ export type InputMedia = | InputMediaAnimation | InputMediaDocument | InputMediaAudio | InputMediaPhoto + | InputMediaLivePhoto | InputMediaVideo; /** Represents a photo to be sent. */ @@ -2678,6 +2968,26 @@ export interface InputMediaPhoto { has_spoiler?: boolean; } +/** Represents a live photo to be sent. */ +export interface InputMediaLivePhoto { + /** Type of the result, must be live_photo */ + type: "live_photo"; + /** Video of the live photo to send. Pass a file_id to send a file that exists on the Telegram servers (recommended) or pass “attach://\” to upload a new one using multipart/form-data under \ name. Sending live photos by a URL is currently unsupported. */ + media: MediaDataParam; + /** The static photo to send. Pass a file_id to send a file that exists on the Telegram servers (recommended) or pass “attach://\” to upload a new one using multipart/form-data under \ name. Sending live photos by a URL is currently unsupported. */ + photo: MediaDataParam; + /** Caption of the live photo to be sent, 0-1024 characters after entities parsing */ + caption?: string; + /** Mode for parsing entities in the live photo caption. See formatting options for more details. */ + parse_mode?: ParseMode; + /** List of special entities that appear in the caption, which can be specified instead of parse_mode */ + caption_entities?: MessageEntity[]; + /** Pass True, if the caption must be shown above the message media */ + show_caption_above_media?: boolean; + /** Pass True if the live photo needs to be covered with a spoiler animation */ + has_spoiler?: boolean; +} + /** Represents a video to be sent. */ export interface InputMediaVideo { /** Type of the result, must be video */ @@ -2712,7 +3022,7 @@ export interface InputMediaVideo { /** Represents an animation file (GIF or H.264/MPEG-4 AVC video without sound) to be sent. */ export interface InputMediaAnimation { - /** Type of the result, must be animation */ + /** Type of the media, must be animation */ type: "animation"; /** File to send. Pass a fileId to send a file that exists on the Telegram servers (recommended), pass an HTTP URL for Telegram to get a file from the Internet, or pass "attach://" to upload a new one using multipart/form-data under name. */ media: MediaDataParam; @@ -2738,7 +3048,7 @@ export interface InputMediaAnimation { /** Represents an audio file to be treated as music to be sent. */ export interface InputMediaAudio { - /** Type of the result, must be audio */ + /** Type of the media, must be audio */ type: "audio"; /** File to send. Pass a fileId to send a file that exists on the Telegram servers (recommended), pass an HTTP URL for Telegram to get a file from the Internet, or pass "attach://" to upload a new one using multipart/form-data under name. */ media: MediaDataParam; @@ -2758,9 +3068,128 @@ export interface InputMediaAudio { title?: string; } +/** Represents a location to be sent. */ +export interface InputMediaLocation { + /** Type of the media, must be location */ + type: "location"; + /** Latitude of the location */ + latitude: number; + /** Longitude of the location */ + longitude: number; + /** The radius of uncertainty for the location, measured in meters; 0-1500 */ + horizontal_accuracy?: number; +} + +/** Represents a voice message file to be sent. */ +export interface InputMediaVoiceNote { + /** Type of the media, must be voice_note */ + type: "voice_note"; + /** File to send. Pass a file_id to send a file that exists on the Telegram servers (recommended), pass an HTTP URL for Telegram to get a file from the Internet, or pass "attach://\" to upload a new one using multipart/form-data under \ name. More information on Sending Files » */ + media: MediaDataParam; + /** Caption of the voice message to be sent, 0-1024 characters after entities parsing */ + caption?: string; + /** Mode for parsing entities in the voice message caption. See formatting options for more details. */ + parseMode?: ParseMode; + /** List of special entities that appear in the caption, which can be specified instead of parse_mode */ + captionEntities?: MessageEntity[]; + /** Duration of the voice message in seconds */ + duration?: number; +} + +/** This object contains information about one answer option in a poll to send. */ +export interface InputPollOption { + /** Option text, 1-100 characters */ + text: string; + /** Mode for parsing entities in the text. See formatting options for more details. Currently, only custom emoji entities are allowed. */ + text_parse_mode?: ParseMode; + /** A list of special entities that appear in the poll option text. It can be specified instead of text_parse_mode. */ + text_entities?: MessageEntity[]; + /** Media added to the poll option */ + media?: InputPollOptionMedia; +} + +/** Represents a venue to be sent. */ +export interface InputMediaVenue { + /** Type of the result, must be venue */ + type: "venue"; + /** Latitude of the location */ + latitude: number; + /** Longitude of the location */ + longitude: number; + /** Name of the venue */ + title: string; + /** Address of the venue */ + address: string; + /** Foursquare identifier of the venue */ + foursquare_id?: string; + /** Foursquare type of the venue, if known. (For example, “arts_entertainment/default”, “arts_entertainment/aquarium” or “food/icecream”.) */ + foursquare_type?: string; + /** Google Places identifier of the venue */ + google_place_id?: string; + /** Google Places type of the venue. (See supported types.) */ + google_place_type?: string; +} + +/** Represents a sticker file to be sent. */ +export interface InputMediaSticker { + /** Type of the media, must be sticker */ + type: "sticker"; + /** File to send. Pass a file_id to send a file that exists on the Telegram servers (recommended), pass an HTTP URL for Telegram to get a .WEBP sticker from the Internet, or pass “attach://\” to upload a new .WEBP, .TGS, or .WEBM sticker using multipart/form-data under \ name. */ + media: MediaDataParam; + /** Emoji associated with the sticker; only for just uploaded stickers */ + emoji?: string; +} + +/** Represents an HTTP link to be sent. */ +export interface InputMediaLink { + /** Type of the media, must be link */ + type: "link"; + /** HTTP URL of the link */ + url: string; +} + +/** This object represents the content of a poll description or a quiz explanation to be sent. It should be one of + +- InputMediaAnimation +- InputMediaAudio +- InputMediaDocument +- InputMediaLivePhoto +- InputMediaLocation +- InputMediaPhoto +- InputMediaVenue +- InputMediaVideo */ +export type InputPollMedia = + | InputMediaAnimation + | InputMediaAudio + | InputMediaDocument + | InputMediaLivePhoto + | InputMediaLocation + | InputMediaPhoto + | InputMediaVenue + | InputMediaVideo; + +/** This object represents the content of a poll option to be sent. It should be one of + - InputMediaAnimation + - InputMediaLink + - InputMediaLivePhoto + - InputMediaLocation + - InputMediaPhoto + - InputMediaSticker + - InputMediaVenue + - InputMediaVideo */ +export type InputPollOptionMedia = + | InputMediaAnimation + | InputMediaLink + | InputMediaLivePhoto + | InputMediaLocation + | InputMediaPhoto + | InputMediaSticker + | InputMediaVenue + | InputMediaVideo; + /** Represents a general file to be sent. */ export interface InputMediaDocument { - /** Type of the result, must be document */ + /** Type of the media, must be document */ type: "document"; /** File to send. Pass a fileId to send a file that exists on the Telegram servers (recommended), pass an HTTP URL for Telegram to get a file from the Internet, or pass "attach://" to upload a new one using multipart/form-data under name. */ media: MediaDataParam; @@ -2779,13 +3208,24 @@ export interface InputMediaDocument { /** This object describes the paid media to be sent. Currently, it can be one of - InputPaidMediaPhoto - InputPaidMediaVideo */ -export type InputPaidMedia = InputMediaPhoto | InputPaidMediaVideo; +export type InputPaidMedia = + InputMediaPhoto | InputPaidMediaVideo | InputPaidMediaLivePhoto; + +/** The paid media to send is a live photo. */ +export interface InputPaidMediaLivePhoto { + /** Type of the media, must be live_photo */ + type: "live_photo"; + /** Video of the live photo to send. Pass a file_id to send a file that exists on the Telegram servers (recommended) or pass “attach://\” to upload a new one using multipart/form-data under \ name. Sending live photos by a URL is currently unsupported. */ + media: MediaDataParam; + /** The static photo to send. Pass a file_id to send a file that exists on the Telegram servers (recommended) or pass “attach://\” to upload a new one using multipart/form-data under \ name. Sending live photos by a URL is currently unsupported. */ + photo: MediaDataParam; +} /** The paid media to send is a photo. */ export interface InputPaidMediaPhoto { /** Type of the media, must be photo */ type: "photo"; - /** File to send. Pass a fileId to send a file that exists on the Telegram servers (recommended), pass an HTTP URL for Telegram to get a file from the Internet, or pass “attach://” to upload a new one using multipart/form-data under name. More information on Sending Files » */ + /** File to send. Pass a fileId to send a file that exists on the Telegram servers (recommended), pass an HTTP URL for Telegram to get a file from the Internet, or pass “attach://” to upload a new one using multipart/form-data under name. */ media: MediaDataParam; } @@ -2793,9 +3233,9 @@ export interface InputPaidMediaPhoto { export interface InputPaidMediaVideo { /** Type of the media, must be video */ type: "video"; - /** File to send. Pass a fileId to send a file that exists on the Telegram servers (recommended), pass an HTTP URL for Telegram to get a file from the Internet, or pass “attach://” to upload a new one using multipart/form-data under name. More information on Sending Files » */ + /** File to send. Pass a fileId to send a file that exists on the Telegram servers (recommended), pass an HTTP URL for Telegram to get a file from the Internet, or pass “attach://” to upload a new one using multipart/form-data under name. */ media: MediaDataParam; - /** Thumbnail of the file sent; can be ignored if thumbnail generation for the file is supported server-side. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail's width and height should not exceed 320. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can't be reused and can be only uploaded as a new file, so you can pass “attach://” if the thumbnail was uploaded using multipart/form-data under . More information on Sending Files » */ + /** Thumbnail of the file sent; can be ignored if thumbnail generation for the file is supported server-side. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail's width and height should not exceed 320. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can't be reused and can be only uploaded as a new file, so you can pass “attach://” if the thumbnail was uploaded using multipart/form-data under . */ thumbnail?: MediaDataParam; /** Cover for the video in the message. Pass a file_id to send a file that exists on the Telegram servers (recommended), pass an HTTP URL for Telegram to get a file from the Internet, or pass “attach://” to upload a new one using multipart/form-data under name. */ cover?: MediaDataParam; @@ -2815,14 +3255,13 @@ export interface InputPaidMediaVideo { - InputProfilePhotoStatic - InputProfilePhotoAnimated */ export type InputProfilePhoto = - | InputProfilePhotoStatic - | InputProfilePhotoAnimated; + InputProfilePhotoStatic | InputProfilePhotoAnimated; /** A static profile photo in the .JPG format. */ export interface InputProfilePhotoStatic { /** Type of the profile photo, must be “static” */ type: "static"; - /** The static profile photo. Profile photos can't be reused and can only be uploaded as a new file, so you can pass “attach://” if the photo was uploaded using multipart/form-data under . More information on Sending Files » */ + /** The static profile photo. Profile photos can't be reused and can only be uploaded as a new file, so you can pass “attach://” if the photo was uploaded using multipart/form-data under . */ photo: MediaDataParam; } @@ -2830,7 +3269,7 @@ export interface InputProfilePhotoStatic { export interface InputProfilePhotoAnimated { /** Type of the profile photo, must be “animated” */ type: "animated"; - /** The animated profile photo. Profile photos can't be reused and can only be uploaded as a new file, so you can pass “attach://” if the photo was uploaded using multipart/form-data under . More information on Sending Files » */ + /** The animated profile photo. Profile photos can't be reused and can only be uploaded as a new file, so you can pass “attach://” if the photo was uploaded using multipart/form-data under . */ animation: MediaDataParam; /** Timestamp in seconds of the frame that will be used as the static profile photo. Defaults to 0.0. */ main_frame_timestamp?: number; @@ -2845,7 +3284,7 @@ export type InputStoryContent = InputStoryContentPhoto | InputStoryContentVideo; export interface InputStoryContentPhoto { /** Type of the content, must be “photo” */ type: "photo"; - /** The photo to post as a story. The photo must be of the size 1080x1920 and must not exceed 10 MB. The photo can't be reused and can only be uploaded as a new file, so you can pass “attach://” if the photo was uploaded using multipart/form-data under . More information on Sending Files » */ + /** The photo to post as a story. The photo must be of the size 1080x1920 and must not exceed 10 MB. The photo can't be reused and can only be uploaded as a new file, so you can pass “attach://” if the photo was uploaded using multipart/form-data under . */ photo: MediaDataParam; } @@ -2853,7 +3292,7 @@ export interface InputStoryContentPhoto { export interface InputStoryContentVideo { /** Type of the content, must be “video” */ type: "video"; - /** The video to post as a story. The video must be of the size 720x1280, streamable, encoded with H.265 codec, with key frames added each second in the MPEG4 format, and must not exceed 30 MB. The video can't be reused and can only be uploaded as a new file, so you can pass “attach://” if the video was uploaded using multipart/form-data under . More information on Sending Files » */ + /** The video to post as a story. The video must be of the size 720x1280, streamable, encoded with H.265 codec, with key frames added each second in the MPEG4 format, and must not exceed 30 MB. The video can't be reused and can only be uploaded as a new file, so you can pass “attach://” if the video was uploaded using multipart/form-data under . */ video: MediaDataParam; /** Precise duration of the video in seconds; 0-60 */ duration?: number; diff --git a/src/client/interfaces/RichMessage.ts b/src/client/interfaces/RichMessage.ts new file mode 100644 index 00000000..1a782a9a --- /dev/null +++ b/src/client/interfaces/RichMessage.ts @@ -0,0 +1,1393 @@ +import type { + CopyTextButton, + DisabledButton, + LoginUrl, + SwitchInlineQueryChosenChat, + WebAppInfo, +} from "./Markup"; +import type { + User, + Animation, + Audio, + Document, + Location, + PhotoSize, + Video, + Voice, +} from "./Message"; +import type { + InputMediaAnimation, + InputMediaAudio, + InputMediaDocument, + InputMediaPhoto, + InputMediaVideo, + InputMediaVoiceNote, +} from "./Methods"; + +/** Describes a rich message to be sent. Exactly one of the fields html, markdown, or blocks must be used. + * + * Rich messages support advanced structured formatting options like headings, lists, tables, media, block quotations, collapsible blocks, footnotes, and formulas. Telegram clients will render them accordingly. You can specify rich message content using Markdown-style or HTML-style formatting, or explicit blocks. + * + * Plain URLs, e-mail addresses, username mentions, hashtags, cashtags, bot commands, phone numbers, and bank card numbers are detected automatically. To disable automatic entity detection, pass True in the skip_entity_detection field. Note that Telegram clients will display an alert to the user before opening an inline link ('Open this link?' together with the full URL). + * + * When Markdown-style or HTML-style formatting is used, you can use links in the form tg://photo?id=..., tg://video?id=..., tg://document?id=..., and tg://audio?id=... instead of an HTTP URL to reuse previously uploaded files or upload a new file. + * + * #### Rich Message Limits + * + * Rich messages are subject to the following limits: + * + * - Up to 32768 UTF-8 characters in the rich message text, including custom emoji alternative text and formula source. + * - Up to 500 blocks, including nested blocks, list items, ordered list items, table rows, quotation blocks, and details blocks. + * - Up to 16 levels of nested formatting and blocks. + * - Up to 50 media attachments in total. + * - Up to 20 columns in a table. + * + * #### Rich Markdown style + * + * To use this mode, pass rich message content in the markdown field. Use the following syntax in your message: + * + * ````markdown + * **bold text** + * __bold text__ + * *italic text* + * _italic text_ + * ~~strikethrough text~~ + * `inline fixed-width code` + * ==marked text== + * ||spoiler|| + * + * [inline URL](https://t.me/) + * [inline e-mail](mailto:user@example.com) + * [inline phone number](tel:+123456789) + * [inline mention of a user](tg://user?id=123456789) + * ![👍](tg://emoji?id=5368324170671202286) + * ![22:45 tomorrow](tg://time?unix=1647531900&format=wDT) + * $x^2 + y^2$ + * \#hashtag $USD +12345678901, card: 4242 4242 4242 4242, https://t.me t.me a@t.me /command @username + * all the text above was on the same line + * + * # Heading 1 + * ## Heading 2 + * ### Heading 3 + * #### Heading 4 + * ##### Heading 5 + * ###### Heading 6 + * + * Paragraph text + * + * ```python + * print('pre-formatted fixed-width code block written in the Python programming language') + * ``` + * + * --- + * + * - unordered list item + * * unordered list item + * + unordered list item + * + * 1. ordered list item + * 2. ordered list item + * + * - [ ] task list item + * - [x] completed task list item + * + * >Block quotation started + * > + * >Block quotation continued on the next line + * >Block quotation continued on the same line + * > + * >The last line of the block quotation + * + * ![](https://telegram.org/example/photo.jpg) + * ![](https://telegram.org/example/video.mp4) + * ![](https://telegram.org/example/audio.mp3) + * ![](https://telegram.org/example/audio.ogg) + * ![](https://telegram.org/example/animation.gif) + * ![](https://telegram.org/example/document.zip) + * + * ![](https://telegram.org/example/photo.jpg "Photo caption") + * ![](https://telegram.org/example/video.mp4 "Video caption") + * ![](https://telegram.org/example/audio.mp3 "Audio caption") + * ![](https://telegram.org/example/audio.ogg "Voice note caption") + * ![](https://telegram.org/example/animation.gif "Animation caption") + * ![](https://telegram.org/example/document.zip "Document caption") + * + * | Header 1 | Header 2 | + * |:---------|:--------:| + * | left | center | + * + * Text with a reference[^id1] and another one[^id2]. + * + * [^id1]: Definition of the first footnote. + * [^id2]: Definition of the second footnote. + * + * $$E = mc^2$$ + * + * ```math + * E = mc^2 + * ``` + * + * ## Example Nested Syntax Report for _Q1_ + * Intro with underlined text, ==marked text==, and $x^2 + y^2$. + * **Bold _italic underlined italic bold italic_ bold** + * In inline tags, nested **markdown** is parsed + * >Quote with **bold text, ~~strikethrough, and spoiler~~**, plus [a link](https://t.me/). + * + * - List item with `code`, superscript, subscript, and a footnote[^note] + * - Another item with **bold spoiler code** + * - Another item with ~~strikethrough and inserted text~~ + * + * | Metric | Value | + * |:-------|------:| + * | Speed | **42** ms | + * | Status | ready | + * + * [^note]: Footnote with _italic text_ and HTML underline. + * + * --- + * + * # Details blocks can contain Markdown content: + * + *
Summary with **bold text** + * + * ### Details heading + * - List item with _italic text_ + * - List item with spoiler + * + *
+ * + * # Collages and slideshows can contain Markdown media blocks: + * + * + * + * ![](https://telegram.org/example/photo.jpg) + * ![](https://telegram.org/example/video.mp4) + * + * + * + * + * + * ![](https://telegram.org/example/photo.jpg) + * ![](https://telegram.org/example/video.mp4) + * + * + * ```` + * + * For formatting features that don't have Markdown syntax, use HTML tags: + * + * ```html + * underlined text, underlined text + * subscript text + * superscript text + * + * + *
TitleContent
+ * + *
CaptionThe Author
+ * + *

Inline buttons: + * url + * user + * callback with the date 22:45 tomorrow and the custom emoji 👍 + * Mini App (private chats only) + * login (requires domain set up via @BotFather) + * inline + * inline 2 + * inline 3 + * Copy + * Disabled + *

+ * + * url + * user + * callback + * + * + * Mini App (private chats only) + * + * + * login (requires domain set up via @BotFather) + * + * + * inline + * inline 2 + * inline 3 + * + * + * Copy + * Disabled + * + * ``` + * + * Please note: + * + * - Rich Markdown is compatible with GitHub Flavored Markdown where possible and can contain arbitrary HTML. Supported rich message HTML tags are parsed as described in Rich HTML style. + * - Media can be specified only as a separate block. + * - Media blocks support only HTTP and HTTPS URLs. + * - Media type is determined by the MIME type and the URL of the media. + * - In media syntax, the optional title after the URL is used as the caption; for example, displays “Photo caption” under the media. + * - Table cells can contain only inline formatting. + * - Formula source is treated as raw LaTeX. + * - See date-time entity formatting for more details about supported date-time formats. + * + * #### Rich HTML style + * + * To use this mode, pass rich message content in the html field. The following tags are currently supported: + * + * ```html + * + * bold text, bold text + * italic text, italic text + * underlined text, underlined text + * strikethrough text, strikethrough text, strikethrough text + * inline fixed-width code + * marked text + * subscript text + * superscript text + * spoiler + * + * Reference + * inline URL + * inline e-mail + * inline phone number + * inline mention of a user + * in-document link + * + * + * Referenced text + * 👍 + * 👍 + * 22:45 tomorrow + * x^2 + y^2 + * + * #hashtag $USD +12345678901, card: 4242 4242 4242 4242, https://t.me t.me a@t.me /command @username + * + * all the text above was on the same line + * + *

Heading 1

+ *

Heading 2

+ *

Heading 3

+ *

Heading 4

+ *
Heading 5
+ *
Heading 6
+ * + * + * + *

Paragraph text

+ *
pre-formatted fixed-width code block
+ *
  print('pre-formatted fixed-width code block written in the Python programming language')
+ *
Footer text
+ *
+ *
  • unordered list item
+ *
  1. ordered list item
+ *
  1. ordered list item
+ *
  1. ordered list item with explicit number
+ *
    + *
  • Checked checkbox
  • + *
  • Unchecked checkbox
  • + *
+ * + *
Block quotation started
Block quotation continued
The last line of the block quotationThe Author
+ *
Expandable block quotation started
Expandable block quotation continued
Expandable block quotation continued
Expandable block quotation continued
The last line of the expandable block quotationThe Author
+ * + * + * + * + * + * + * + * + * + *
Photo captionPhoto credit
+ *
Video caption
+ *
Audio caption
+ *
Voice note caption
+ *
Animation caption
+ *
Document caption
+ * + * + *
Map caption
+ * + * + * + * + * + * + *
Header 1Header 2
Value 1Value 2
+ * + * + * + *
Table caption
ValueValue2Value3
Value4Value5Value6
Value7
+ * + *
TitleContent
+ *
TitleContent
+ * E = mc^2 + *

Inline buttons: + * url + * user + * callback with the date 22:45 tomorrow and the custom emoji 👍 + * Mini App (private chats only) + * login (requires domain set up via @BotFather) + * inline + * inline 2 + * inline 3 + * Copy + * Disabled + *

+ * + * url + * user + * callback + * + * + * Mini App (private chats only) + * + * + * login (requires domain set up via @BotFather) + * + * + * inline + * inline 2 + * inline 3 + * + * + * Copy + * Disabled + * + * ``` + * + * Please note: + * + * - Only the tags mentioned above are currently supported. + * - All numerical HTML entities are supported. + * - The API currently supports only the following named HTML entities: <, >, &, ", ',  , …, —, –, ‘, ’, “ and ”. + * - Use nested pre and code tags to define the programming language for a pre-formatted block. + * - Programming language can't be specified for standalone code tags. + * - Links mailto:..., tel:..., and tg://user?id=... are rendered as e-mail links, phone links, and inline mentions respectively. Other supported links are rendered as regular inline links. + * - Images, videos, and audio files can be specified only as separate media blocks. + * - Media blocks support only HTTP and HTTPS URLs. + * - An empty \ on its own creates an anchor that can be linked to with \.... + * - In \
, you can use \ tags to specify caption credit. + * - Use \... to define referenced text that can be linked to with \.... + * - The body of a \
tag can contain rich message content. If the open attribute is specified, the block is expanded by default. + * - Formula source is treated as raw LaTeX. + * - See date-time entity formatting for more details about supported date-time formats. */ +export interface InputRichMessage { + /** Content of the rich message to send described as a list of blocks */ + blocks?: InputRichBlock[]; + /** Content of the rich message to send described using HTML formatting. See rich message formatting options for more details. Use media field to specify the media used in the message. */ + html?: string; + /** Content of the rich message to send described using Markdown formatting. See rich message formatting options for more details. Use media field to specify the media used in the message. */ + markdown?: string; + /** List of media that are specified in the markdown or html fields using tg://photo?id=, tg://video?id=, tg://document?id=, and tg://audio?id= links */ + media?: InputRichMessageMedia[]; + /** Pass True if the rich message must be shown right-to-left */ + is_rtl?: boolean; + /** Pass True to skip automatic detection of entities (e.g., URLs, email addresses, username mentions, hashtags, cashtags, bot commands, or phone numbers) in the text */ + skip_entity_detection?: boolean; +} + +/** Describes a media element embedded in an outgoing rich message. */ +export interface InputRichMessageMedia { + /** Unique identifier of the media used in a tg://photo?id=, tg://video?id=, tg://document?id=, or tg://audio?id= link. 1-64 characters, only A-Z, a-z, 0-9, _ and - are allowed. */ + id: string; + /** The media to be sent. Everything except the media itself and its properties is ignored. */ + media: + | InputMediaAnimation + | InputMediaAudio + | InputMediaDocument + | InputMediaPhoto + | InputMediaVideo + | InputMediaVoiceNote; +} + +/** This object represents a rich formatted text. Currently, it can be either a String for plain text, an Array of RichText, or any of the following types: + +- RichTextBold +- RichTextItalic +- RichTextUnderline +- RichTextStrikethrough +- RichTextSpoiler +- RichTextDateTime +- RichTextTextMention +- RichTextSubscript +- RichTextSuperscript +- RichTextMarked +- RichTextCode +- RichTextCustomEmoji +- RichTextMathematicalExpression +- RichTextUrl +- RichTextEmailAddress +- RichTextPhoneNumber +- RichTextBankCardNumber +- RichTextMention +- RichTextHashtag +- RichTextCashtag +- RichTextBotCommand +- RichTextButton +- RichTextAnchor +- RichTextAnchorLink +- RichTextReference +- RichTextReferenceLink */ +export type RichText = + | string + | RichText[] + | RichTextBold + | RichTextItalic + | RichTextUnderline + | RichTextStrikethrough + | RichTextSpoiler + | RichTextDateTime + | RichTextTextMention + | RichTextSubscript + | RichTextSuperscript + | RichTextMarked + | RichTextCode + | RichTextCustomEmoji + | RichTextMathematicalExpression + | RichTextUrl + | RichTextEmailAddress + | RichTextPhoneNumber + | RichTextBankCardNumber + | RichTextMention + | RichTextHashtag + | RichTextCashtag + | RichTextBotCommand + | RichTextButton + | RichTextAnchor + | RichTextAnchorLink + | RichTextReference + | RichTextReferenceLink; + +/** A bold text. */ +export interface RichTextBold { + /** Type of the rich text, always “bold” */ + type: "bold"; + /** The text */ + text: RichText; +} + +/** An italicized text. */ +export interface RichTextItalic { + /** Type of the rich text, always “italic” */ + type: "italic"; + /** The text */ + text: RichText; +} + +/** An underlined text. */ +export interface RichTextUnderline { + /** Type of the rich text, always “underline” */ + type: "underline"; + /** The text */ + text: RichText; +} + +/** A strikethrough text. */ +export interface RichTextStrikethrough { + /** Type of the rich text, always “strikethrough” */ + type: "strikethrough"; + /** The text */ + text: RichText; +} + +/** A text covered by a spoiler. */ +export interface RichTextSpoiler { + /** Type of the rich text, always “spoiler” */ + type: "spoiler"; + /** The text */ + text: RichText; +} + +/** Formatted date and time. */ +export interface RichTextDateTime { + /** Type of the rich text, always “date_time” */ + type: "date_time"; + /** The text */ + text: RichText; + /** The Unix time associated with the entity */ + unix_time: number; + /** The string that defines the formatting of the date and time. See date-time entity formatting for more details. */ + date_time_format: "r" | `${"w" | ""}${"d" | "D" | ""}${"t" | "T" | ""}`; +} + +/** A mention of a Telegram user by their identifier. */ +export interface RichTextTextMention { + /** Type of the rich text, always “text_mention” */ + type: "text_mention"; + /** The text */ + text: RichText; + /** The mentioned user */ + user: User; +} + +/** A subscript text. */ +export interface RichTextSubscript { + /** Type of the rich text, always “subscript” */ + type: "subscript"; + /** The text */ + text: RichText; +} + +/** A superscript text. */ +export interface RichTextSuperscript { + /** Type of the rich text, always “superscript” */ + type: "superscript"; + /** The text */ + text: RichText; +} + +/** A marked text. */ +export interface RichTextMarked { + /** Type of the rich text, always “marked” */ + type: "marked"; + /** The text */ + text: RichText; +} + +/** A monowidth text. */ +export interface RichTextCode { + /** Type of the rich text, always “code” */ + type: "code"; + /** The text */ + text: RichText; +} + +/** A custom emoji. */ +export interface RichTextCustomEmoji { + /** Type of the rich text, always “custom_emoji” */ + type: "custom_emoji"; + /** Unique identifier of the custom emoji. Use getCustomEmojiStickers to get full information about the sticker. */ + custom_emoji_id: string; + /** Alternative emoji for the custom emoji */ + alternative_text: string; +} + +/** A mathematical expression. */ +export interface RichTextMathematicalExpression { + /** Type of the rich text, always “mathematical_expression” */ + type: "mathematical_expression"; + /** The expression in LaTeX format */ + expression: string; +} + +/** A text with a link. */ +export interface RichTextUrl { + /** Type of the rich text, always “url” */ + type: "url"; + /** The text */ + text: RichText; + /** URL of the link */ + url: string; +} + +/** A text with an email address. */ +export interface RichTextEmailAddress { + /** Type of the rich text, always “email_address” */ + type: "email_address"; + /** The text */ + text: RichText; + /** The email address */ + email_address: string; +} + +/** A text with a phone number. */ +export interface RichTextPhoneNumber { + /** Type of the rich text, always “phone_number” */ + type: "phone_number"; + /** The text */ + text: RichText; + /** The phone number */ + phone_number: string; +} + +/** A text with a bank card number. */ +export interface RichTextBankCardNumber { + /** Type of the rich text, always “bank_card_number” */ + type: "bank_card_number"; + /** The text */ + text: RichText; + /** The bank card number */ + bank_card_number: string; +} + +/** A mention by a username. */ +export interface RichTextMention { + /** Type of the rich text, always “mention” */ + type: "mention"; + /** The text */ + text: RichText; + /** The mentioned user */ + username: string; +} + +/** A hashtag. */ +export interface RichTextHashtag { + /** Type of the rich text, always “hashtag” */ + type: "hashtag"; + /** The text */ + text: RichText; + /** The hashtag */ + hashtag: string; +} + +/** A cashtag. */ +export interface RichTextCashtag { + /** Type of the rich text, always “cashtag” */ + type: "cashtag"; + /** The text */ + text: RichText; + /** The cashtag */ + cashtag: string; +} + +/** A bot command. */ +export interface RichTextBotCommand { + /** Type of the rich text, always “bot_command” */ + type: "bot_command"; + /** The text */ + text: RichText; + /** The bot command */ + bot_command: string; +} + +/** An anchor. */ +export interface RichTextAnchor { + /** Type of the rich text, always “anchor” */ + type: "anchor"; + /** The name of the anchor */ + name: string; +} + +/** A link to an anchor. */ +export interface RichTextAnchorLink { + /** Type of the rich text, always “anchor_link” */ + type: "anchor_link"; + /** The link text */ + text: RichText; + /** The name of the anchor. If the name is empty, then the link brings back to the top of the message. */ + anchor_name: string; +} + +/** A reference. */ +export interface RichTextReference { + /** Type of the rich text, always “reference” */ + type: "reference"; + /** Text of the reference */ + text: RichText; + /** The name of the reference */ + name: string; +} + +/** A link to a reference. */ +export interface RichTextReferenceLink { + /** Type of the rich text, always “reference_link” */ + type: "reference_link"; + /** The link text */ + text: RichText; + /** The name of the reference */ + reference_name: string; +} + +/** Caption of a rich formatted block. */ +export interface RichBlockCaption { + /** Block caption */ + text: RichText; + /** Block credit which corresponds to the HTML tag \ */ + credit?: RichText; +} + +/** Cell in a table. */ +export interface RichBlockTableCell { + /** Text in the cell. If omitted, then the cell is invisible. */ + text?: RichText; + /** True, if the cell is a header cell */ + is_header?: true; + /** The number of columns the cell spans if it is bigger than 1 */ + colspan?: number; + /** The number of rows the cell spans if it is bigger than 1 */ + rowspan?: number; + /** Horizontal cell content alignment. Currently, must be one of “left”, “center”, or “right”. */ + align: "left" | "center" | "right"; + /** Vertical cell content alignment. Currently, must be one of “top”, “middle”, or “bottom”. */ + valign: "top" | "middle" | "bottom"; +} + +/** An item of a list. */ +export interface RichBlockListItem { + /** Label of the item */ + label: string; + /** The content of the item */ + blocks: RichBlock[]; + /** True, if the item has a checkbox */ + has_checkbox?: true; + /** True, if the item has a checked checkbox */ + is_checked?: true; + /** For ordered lists, the numeric value of the item label */ + value?: number; + /** For ordered lists, the type of the item label; must be one of “a” for lowercase letters, “A” for uppercase letters, “i” for lowercase Roman numerals, “I” for uppercase Roman numerals, or “1” for decimal numbers */ + type?: "a" | "A" | "i" | "I" | "1"; +} + +/** This object represents a block in a rich formatted message. Currently, it can be any of the following types: + +- RichBlockParagraph +- RichBlockSectionHeading +- RichBlockPreformatted +- RichBlockFooter +- RichBlockDivider +- RichBlockMathematicalExpression +- RichBlockAnchor +- RichBlockList +- RichBlockBlockQuotation +- RichBlockExpandableBlockQuotation +- RichBlockPullQuotation +- RichBlockCollage +- RichBlockSlideshow +- RichBlockTable +- RichBlockDetails +- RichBlockMap +- RichBlockAnimation +- RichBlockAudio +- RichBlockDocument +- RichBlockPhoto +- RichBlockVideo +- RichBlockVoiceNote +- RichBlockButtons +- RichBlockThinking */ +export type RichBlock = + | RichBlockParagraph + | RichBlockSectionHeading + | RichBlockPreformatted + | RichBlockFooter + | RichBlockDivider + | RichBlockMathematicalExpression + | RichBlockAnchor + | RichBlockList + | RichBlockBlockQuotation + | RichBlockExpandableBlockQuotation + | RichBlockPullQuotation + | RichBlockCollage + | RichBlockSlideshow + | RichBlockTable + | RichBlockDetails + | RichBlockMap + | RichBlockAnimation + | RichBlockAudio + | RichBlockDocument + | RichBlockPhoto + | RichBlockVideo + | RichBlockVoiceNote + | RichBlockButtons + | RichBlockThinking; + +/** A text paragraph, corresponding to the HTML tag \

. */ +export interface RichBlockParagraph { + /** Type of the block, always “paragraph” */ + type: "paragraph"; + /** Text of the block */ + text: RichText; +} + +/** A section heading, corresponding to the HTML tags \

, \

, \

, \

, \

, or \
. */ +export interface RichBlockSectionHeading { + /** Type of the block, always “heading” */ + type: "heading"; + /** Text of the block */ + text: RichText; + /** Relative size of the text font; 1-6, 1 is the largest, 6 is the smallest */ + size: 1 | 2 | 3 | 4 | 5 | 6; +} + +/** A preformatted text block, corresponding to the nested HTML tags \
 and \. */
+export interface RichBlockPreformatted {
+  /** Type of the block, always “pre” */
+  type: "pre";
+  /** Text of the block */
+  text: RichText;
+  /** The programming language of the text */
+  language?: string;
+}
+
+/** A footer, corresponding to the HTML tag \