UNPKG

grammy

Version:

The Telegram Bot Framework.

768 lines β€’ 139 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Api = void 0; const client_js_1 = require("./client.js"); /** * This class provides access to the full Telegram Bot API. All methods of the * API have an equivalent on this class, with the most important parameters * pulled up into the function signature, and the other parameters captured by * an object. * * In addition, this class has a property `raw` that provides raw access to the * complete Telegram API, with the method signatures 1:1 represented as * documented on the website (https://core.telegram.org/bots/api). * * Every method takes an optional `AbortSignal` object that allows you to cancel * the request if desired. * * In advanced use cases, this class allows to install transformers that can * modify the method and payload on the fly before sending it to the Telegram * servers. Confer the `config` property for this. */ class Api { /** * Constructs a new instance of `Api`. It is independent from all other * instances of this class. For example, this lets you install a custom set * of transformers. * * @param token Bot API token obtained from [@BotFather](https://t.me/BotFather) * @param options Optional API client options for the underlying client instance * @param webhookReplyEnvelope Optional envelope to handle webhook replies */ constructor(token, options, webhookReplyEnvelope) { this.token = token; this.options = options; const { raw, use, installedTransformers } = (0, client_js_1.createRawApi)(token, options, webhookReplyEnvelope); this.raw = raw; this.config = { use, installedTransformers: () => installedTransformers.slice(), }; } /** * Use this method to receive incoming updates using long polling (wiki). Returns an Array of Update objects. * * Notes * 1. This method will not work if an outgoing webhook is set up. * 2. In order to avoid getting duplicate updates, recalculate offset after each server response. * * @param other Optional remaining parameters, confer the official reference below * @param signal Optional `AbortSignal` to cancel the request * * **Official reference:** https://core.telegram.org/bots/api#getupdates */ getUpdates(other, signal) { return this.raw.getUpdates({ ...other }, signal); } /** * Use this method to specify a URL and receive incoming updates via an outgoing webhook. Whenever there is an update for the bot, we will send an HTTPS POST request to the specified URL, containing a JSON-serialized Update. In case of an unsuccessful request, we will give up after a reasonable amount of attempts. Returns True on success. * * If you'd like to make sure that the webhook was set by you, you can specify secret data in the parameter secret_token. If specified, the request will contain a header β€œX-Telegram-Bot-Api-Secret-Token” with the secret token as content. * * Notes * 1. You will not be able to receive updates using getUpdates for as long as an outgoing webhook is set up. * 2. To use a self-signed certificate, you need to upload your public key certificate using certificate parameter. Please upload as InputFile, sending a String will not work. * 3. Ports currently supported for Webhooks: 443, 80, 88, 8443. * * If you're having any trouble setting up webhooks, please check out this amazing guide to webhooks. * * @param url HTTPS url to send updates to. Use an empty string to remove webhook integration * @param other Optional remaining parameters, confer the official reference below * @param signal Optional `AbortSignal` to cancel the request * * **Official reference:** https://core.telegram.org/bots/api#setwebhook */ setWebhook(url, other, signal) { return this.raw.setWebhook({ url, ...other }, signal); } /** * Use this method to remove webhook integration if you decide to switch back to getUpdates. Returns True on success. * * @param other Optional remaining parameters, confer the official reference below * @param signal Optional `AbortSignal` to cancel the request * * **Official reference:** https://core.telegram.org/bots/api#deletewebhook */ deleteWebhook(other, signal) { return this.raw.deleteWebhook({ ...other }, signal); } /** * Use this method to get current webhook status. Requires no parameters. On success, returns a WebhookInfo object. If the bot is using getUpdates, will return an object with the url field empty. * * @param signal Optional `AbortSignal` to cancel the request * * **Official reference:** https://core.telegram.org/bots/api#getwebhookinfo */ getWebhookInfo(signal) { return this.raw.getWebhookInfo(signal); } /** * 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. * * @param signal Optional `AbortSignal` to cancel the request * * **Official reference:** https://core.telegram.org/bots/api#getme */ getMe(signal) { return this.raw.getMe(signal); } /** * 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. * * @param signal Optional `AbortSignal` to cancel the request * * **Official reference:** https://core.telegram.org/bots/api#logout */ logOut(signal) { return this.raw.logOut(signal); } /** * Use this method to close the bot instance before moving it from one local server to another. You need to delete the webhook before calling this method to ensure that the bot isn't launched again after server restart. The method will return error 429 in the first 10 minutes after the bot is launched. Returns True on success. Requires no parameters. * * @param signal Optional `AbortSignal` to cancel the request * * **Official reference:** https://core.telegram.org/bots/api#close */ close(signal) { return this.raw.close(signal); } /** * Use this method to send text messages. On success, the sent Message is returned. * * @param chat_id Unique identifier for the target chat or username of the target channel (in the format @channelusername) * @param text Text of the message to be sent, 1-4096 characters after entities parsing * @param other Optional remaining parameters, confer the official reference below * @param signal Optional `AbortSignal` to cancel the request * * **Official reference:** https://core.telegram.org/bots/api#sendmessage */ sendMessage(chat_id, text, other, signal) { return this.raw.sendMessage({ chat_id, text, ...other }, signal); } /** * 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. * * @param chat_id Unique identifier for the target chat or username of the target channel (in the format @channelusername) * @param from_chat_id Unique identifier for the chat where the original message was sent (or channel username in the format @channelusername) * @param message_id Message identifier in the chat specified in from_chat_id * @param other Optional remaining parameters, confer the official reference below * @param signal Optional `AbortSignal` to cancel the request * * **Official reference:** https://core.telegram.org/bots/api#forwardmessage */ forwardMessage(chat_id, from_chat_id, message_id, other, signal) { return this.raw.forwardMessage({ chat_id, from_chat_id, message_id, ...other }, signal); } /** * 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. * * @param chat_id Unique identifier for the target chat or username of the target channel (in the format @channelusername) * @param from_chat_id Unique identifier for the chat where the original messages were sent (or channel username in the format @channelusername) * @param message_ids A list of 1-100 identifiers of messages in the chat from_chat_id to forward. The identifiers must be specified in a strictly increasing order. * @param other Optional remaining parameters, confer the official reference below * @param signal Optional `AbortSignal` to cancel the request * * **Official reference:** https://core.telegram.org/bots/api#forwardmessages */ forwardMessages(chat_id, from_chat_id, message_ids, other, signal) { return this.raw.forwardMessages({ chat_id, from_chat_id, message_ids, ...other, }, signal); } /** * 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 correct_option_id 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. * * @param chat_id Unique identifier for the target chat or username of the target channel (in the format @channelusername) * @param from_chat_id Unique identifier for the chat where the original message was sent (or channel username in the format @channelusername) * @param message_id Message identifier in the chat specified in from_chat_id * @param other Optional remaining parameters, confer the official reference below * @param signal Optional `AbortSignal` to cancel the request * * **Official reference:** https://core.telegram.org/bots/api#copymessage */ copyMessage(chat_id, from_chat_id, message_id, other, signal) { return this.raw.copyMessage({ chat_id, from_chat_id, message_id, ...other }, signal); } /** * 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. * * @param chat_id Unique identifier for the target chat or username of the target channel (in the format @channelusername) * @param from_chat_id Unique identifier for the chat where the original messages were sent (or channel username in the format @channelusername) * @param message_ids A list of 1-100 identifiers of messages in the chat from_chat_id to copy. The identifiers must be specified in a strictly increasing order. * @param other Optional remaining parameters, confer the official reference below * @param signal Optional `AbortSignal` to cancel the request * * **Official reference:** https://core.telegram.org/bots/api#copymessages */ copyMessages(chat_id, from_chat_id, message_ids, other, signal) { return this.raw.copyMessages({ chat_id, from_chat_id, message_ids, ...other, }, signal); } /** * Use this method to send photos. On success, the sent Message is returned. * * @param chat_id Unique identifier for the target chat or username of the target channel (in the format @channelusername) * @param photo Photo to send. Pass a file_id as String to send a photo that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get a photo from the Internet, or upload a new photo using multipart/form-data. The photo must be at most 10 MB in size. The photo's width and height must not exceed 10000 in total. Width and height ratio must be at most 20. * @param other Optional remaining parameters, confer the official reference below * @param signal Optional `AbortSignal` to cancel the request * * **Official reference:** https://core.telegram.org/bots/api#sendphoto */ sendPhoto(chat_id, photo, other, signal) { return this.raw.sendPhoto({ chat_id, photo, ...other }, signal); } /** * 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. * * @param chat_id Unique identifier for the target chat or username of the target channel (in the format @channelusername) * @param audio Audio file to send. Pass a file_id 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. * @param other Optional remaining parameters, confer the official reference below * @param signal Optional `AbortSignal` to cancel the request * * **Official reference:** https://core.telegram.org/bots/api#sendaudio */ sendAudio(chat_id, audio, other, signal) { return this.raw.sendAudio({ chat_id, audio, ...other }, signal); } /** * Use this method to send general files. On success, the sent Message is returned. Bots can currently send files of any type of up to 50 MB in size, this limit may be changed in the future. * * @param chat_id Unique identifier for the target chat or username of the target channel (in the format @channelusername) * @param document File to send. Pass a file_id 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. * @param other Optional remaining parameters, confer the official reference below * @param signal Optional `AbortSignal` to cancel the request * * **Official reference:** https://core.telegram.org/bots/api#senddocument */ sendDocument(chat_id, document, other, signal) { return this.raw.sendDocument({ chat_id, document, ...other }, signal); } /** * Use this method to send video files, Telegram clients support mp4 videos (other formats may be sent as Document). On success, the sent Message is returned. Bots can currently send video files of up to 50 MB in size, this limit may be changed in the future. * * @param chat_id Unique identifier for the target chat or username of the target channel (in the format @channelusername) * @param video Video to send. Pass a file_id 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. * @param other Optional remaining parameters, confer the official reference below * @param signal Optional `AbortSignal` to cancel the request * * **Official reference:** https://core.telegram.org/bots/api#sendvideo */ sendVideo(chat_id, video, other, signal) { return this.raw.sendVideo({ chat_id, video, ...other }, signal); } /** * 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. * * @param chat_id Unique identifier for the target chat or username of the target channel (in the format @channelusername) * @param animation Animation to send. Pass a file_id 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. * @param other Optional remaining parameters, confer the official reference below * @param signal Optional `AbortSignal` to cancel the request * * **Official reference:** https://core.telegram.org/bots/api#sendanimation */ sendAnimation(chat_id, animation, other, signal) { return this.raw.sendAnimation({ chat_id, animation, ...other }, signal); } /** * Use this method to send audio files, if you want Telegram clients to display the file as a playable voice message. For this to work, your audio must be in an .OGG file encoded with OPUS (other formats may be sent as Audio or Document). On success, the sent Message is returned. Bots can currently send voice messages of up to 50 MB in size, this limit may be changed in the future. * * @param chat_id Unique identifier for the target chat or username of the target channel (in the format @channelusername) * @param voice Audio file to send. Pass a file_id 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. * @param other Optional remaining parameters, confer the official reference below * @param signal Optional `AbortSignal` to cancel the request * * **Official reference:** https://core.telegram.org/bots/api#sendvoice */ sendVoice(chat_id, voice, other, signal) { return this.raw.sendVoice({ chat_id, voice, ...other }, signal); } /** * Use this method to send video messages. On success, the sent Message is returned. * As of v.4.0, Telegram clients support rounded square mp4 videos of up to 1 minute long. * * @param chat_id Unique identifier for the target chat or username of the target channel (in the format @channelusername) * @param video_note Video note to send. Pass a file_id 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 * @param other Optional remaining parameters, confer the official reference below * @param signal Optional `AbortSignal` to cancel the request * * **Official reference:** https://core.telegram.org/bots/api#sendvideonote */ sendVideoNote(chat_id, video_note, other, signal) { return this.raw.sendVideoNote({ chat_id, video_note, ...other }, signal); } /** * 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. * * @param chat_id Unique identifier for the target chat or username of the target channel (in the format @channelusername) * @param media An array describing messages to be sent, must include 2-10 items * @param other Optional remaining parameters, confer the official reference below * @param signal Optional `AbortSignal` to cancel the request * * **Official reference:** https://core.telegram.org/bots/api#sendmediagroup */ sendMediaGroup(chat_id, media, other, signal) { return this.raw.sendMediaGroup({ chat_id, media, ...other }, signal); } /** * Use this method to send point on the map. On success, the sent Message is returned. * * @param chat_id Unique identifier for the target chat or username of the target channel (in the format @channelusername) * @param latitude Latitude of the location * @param longitude Longitude of the location * @param other Optional remaining parameters, confer the official reference below * @param signal Optional `AbortSignal` to cancel the request * * **Official reference:** https://core.telegram.org/bots/api#sendlocation */ sendLocation(chat_id, latitude, longitude, other, signal) { return this.raw.sendLocation({ chat_id, latitude, longitude, ...other }, signal); } /** * Use this method to edit live location messages. A location can be edited until its live_period expires or editing is explicitly disabled by a call to stopMessageLiveLocation. On success, if the edited message is not an inline message, the edited Message is returned, otherwise True is returned. * * @param chat_id Unique identifier for the target chat or username of the target channel (in the format @channelusername) * @param message_id Identifier of the message to edit * @param latitude Latitude of new location * @param longitude Longitude of new location * @param other Optional remaining parameters, confer the official reference below * @param signal Optional `AbortSignal` to cancel the request * * **Official reference:** https://core.telegram.org/bots/api#editmessagelivelocation */ editMessageLiveLocation(chat_id, message_id, latitude, longitude, other, signal) { return this.raw.editMessageLiveLocation({ chat_id, message_id, latitude, longitude, ...other }, signal); } /** * Use this method to edit live location inline messages. A location can be edited until its live_period expires or editing is explicitly disabled by a call to stopMessageLiveLocation. On success, if the edited message is not an inline message, the edited Message is returned, otherwise True is returned. * * @param inline_message_id Identifier of the inline message * @param latitude Latitude of new location * @param longitude Longitude of new location * @param other Optional remaining parameters, confer the official reference below * @param signal Optional `AbortSignal` to cancel the request * * **Official reference:** https://core.telegram.org/bots/api#editmessagelivelocation */ editMessageLiveLocationInline(inline_message_id, latitude, longitude, other, signal) { return this.raw.editMessageLiveLocation({ inline_message_id, latitude, longitude, ...other }, signal); } /** * Use this method to stop updating a live location message before live_period expires. On success, if the message is not an inline message, the edited Message is returned, otherwise True is returned. * * @param chat_id Unique identifier for the target chat or username of the target channel (in the format @channelusername) * @param message_id Identifier of the message with live location to stop * @param other Optional remaining parameters, confer the official reference below * @param signal Optional `AbortSignal` to cancel the request * * **Official reference:** https://core.telegram.org/bots/api#stopmessagelivelocation */ stopMessageLiveLocation(chat_id, message_id, other, signal) { return this.raw.stopMessageLiveLocation({ chat_id, message_id, ...other }, signal); } /** * Use this method to stop updating a live location message before live_period expires. On success, if the message is not an inline message, the edited Message is returned, otherwise True is returned. * * @param inline_message_id Identifier of the inline message * @param other Optional remaining parameters, confer the official reference below * @param signal Optional `AbortSignal` to cancel the request * * **Official reference:** https://core.telegram.org/bots/api#stopmessagelivelocation */ stopMessageLiveLocationInline(inline_message_id, other, signal) { return this.raw.stopMessageLiveLocation({ inline_message_id, ...other }, signal); } /** * Use this method to send paid media. On success, the sent Message is returned. * * @param chat_id Unique identifier for the target chat or username of the target channel (in the format @channelusername) * @param star_count The number of Telegram Stars that must be paid to buy access to the media * @param media An array describing the media to be sent; up to 10 items * @param other Optional remaining parameters, confer the official reference below * @param signal Optional `AbortSignal` to cancel the request * * **Official reference:** https://core.telegram.org/bots/api#sendpaidmedia */ sendPaidMedia(chat_id, star_count, media, other, signal) { return this.raw.sendPaidMedia({ chat_id, star_count, media, ...other }, signal); } /** * Use this method to send information about a venue. On success, the sent Message is returned. * * @param chat_id Unique identifier for the target chat or username of the target channel (in the format @channelusername) * @param latitude Latitude of the venue * @param longitude Longitude of the venue * @param title Name of the venue * @param address Address of the venue * @param other Optional remaining parameters, confer the official reference below * @param signal Optional `AbortSignal` to cancel the request * * **Official reference:** https://core.telegram.org/bots/api#sendvenue */ sendVenue(chat_id, latitude, longitude, title, address, other, signal) { return this.raw.sendVenue({ chat_id, latitude, longitude, title, address, ...other }, signal); } /** * Use this method to send phone contacts. On success, the sent Message is returned. * * @param chat_id Unique identifier for the target chat or username of the target channel (in the format @channelusername) * @param phone_number Contact's phone number * @param first_name Contact's first name * @param other Optional remaining parameters, confer the official reference below * @param signal Optional `AbortSignal` to cancel the request * * **Official reference:** https://core.telegram.org/bots/api#sendcontact */ sendContact(chat_id, phone_number, first_name, other, signal) { return this.raw.sendContact({ chat_id, phone_number, first_name, ...other }, signal); } /** * Use this method to send a native poll. On success, the sent Message is returned. * * @param chat_id Unique identifier for the target chat or username of the target channel (in the format @channelusername) * @param question Poll question, 1-300 characters * @param options A list of answer options, 2-12 strings 1-100 characters each * @param other Optional remaining parameters, confer the official reference below * @param signal Optional `AbortSignal` to cancel the request * * **Official reference:** https://core.telegram.org/bots/api#sendpoll */ sendPoll(chat_id, question, options, other, signal) { const opts = options.map((o) => typeof o === "string" ? { text: o } : o); return this.raw.sendPoll({ chat_id, question, options: opts, ...other }, signal); } /** * Use this method to send a checklist on behalf of a connected business account. On success, the sent Message is returned. * * @param business_connection_id Unique identifier of the business connection on behalf of which the message will be sent * @param chat_id Unique identifier for the target chat * @param checklist An object for the checklist to send * @param other Optional remaining parameters, confer the official reference below * @param signal Optional `AbortSignal` to cancel the request * * **Official reference:** https://core.telegram.org/bots/api#sendchecklist */ sendChecklist(business_connection_id, chat_id, checklist, other, signal) { return this.raw.sendChecklist({ business_connection_id, chat_id, checklist, ...other, }, signal); } /** * Use this method to edit a checklist on behalf of a connected business account. On success, the edited Message is returned. * * @param business_connection_id Unique identifier of the business connection on behalf of which the message will be sent * @param chat_id Unique identifier for the target chat * @param message_id Unique identifier for the target message * @param checklist An object for the new checklist * @param other Optional remaining parameters, confer the official reference below * @param signal Optional `AbortSignal` to cancel the request * * **Official reference:** https://core.telegram.org/bots/api#editmessagechecklist */ editMessageChecklist(business_connection_id, chat_id, message_id, checklist, other, signal) { return this.raw.editMessageChecklist({ business_connection_id, chat_id, message_id, checklist, ...other, }, signal); } /** * Use this method to send an animated emoji that will display a random value. On success, the sent Message is returned. * * @param chat_id Unique identifier for the target chat or username of the target channel (in the format @channelusername) * @param emoji 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 β€œπŸŽ²β€ * @param other Optional remaining parameters, confer the official reference below * @param signal Optional `AbortSignal` to cancel the request * * **Official reference:** https://core.telegram.org/bots/api#senddice */ sendDice(chat_id, emoji, other, signal) { return this.raw.sendDice({ chat_id, emoji, ...other }, signal); } /** * Use this method to change the chosen reactions on a message. Service messages of some types can't be reacted to. Automatically forwarded messages from a channel to its discussion group have the same available reactions as messages in the channel. Bots can't use paid reactions. Returns True on success. * * @param chat_id Unique identifier for the target chat or username of the target channel (in the format @channelusername) * @param message_id Identifier of the target message * @param reaction A list of reaction types to set on the message. Currently, as non-premium users, bots can set up to one reaction per message. A custom emoji reaction can be used if it is either already present on the message or explicitly allowed by chat administrators. Paid reactions can't be used by bots. * @param other Optional remaining parameters, confer the official reference below * @param signal Optional `AbortSignal` to cancel the request * * **Official reference:** https://core.telegram.org/bots/api#setmessagereaction */ setMessageReaction(chat_id, message_id, reaction, other, signal) { return this.raw.setMessageReaction({ chat_id, message_id, reaction, ...other, }, signal); } /** * 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. * * We only recommend using this method when a response from the bot will take a noticeable amount of time to arrive. * * @param chat_id Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername). Channel chats and channel direct messages chats aren't supported. * @param action Type of action to broadcast. Choose one, depending on what the user is about to receive: typing for text messages, upload_photo for photos, record_video or upload_video for videos, record_voice or upload_voice for voice notes, upload_document for general files, choose_sticker for stickers, find_location for location data, record_video_note or upload_video_note for video notes. * @param other Optional remaining parameters, confer the official reference below * @param signal Optional `AbortSignal` to cancel the request * * **Official reference:** https://core.telegram.org/bots/api#sendchataction */ sendChatAction(chat_id, action, other, signal) { return this.raw.sendChatAction({ chat_id, action, ...other }, signal); } /** * Use this method to get a list of profile pictures for a user. Returns a UserProfilePhotos object. * * @param user_id Unique identifier of the target user * @param other Optional remaining parameters, confer the official reference below * @param signal Optional `AbortSignal` to cancel the request * * **Official reference:** https://core.telegram.org/bots/api#getuserprofilephotos */ getUserProfilePhotos(user_id, other, signal) { return this.raw.getUserProfilePhotos({ user_id, ...other }, signal); } /** * 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. * * @param user_id Unique identifier of the target user * @param other Optional remaining parameters, confer the official reference below * @param signal Optional `AbortSignal` to cancel the request * * **Official reference:** https://core.telegram.org/bots/api#setuseremojistatus */ setUserEmojiStatus(user_id, other, signal) { return this.raw.setUserEmojiStatus({ user_id, ...other }, signal); } /** * 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. * * @param chat_id Unique identifier for the chat or username of the channel (in the format @channelusername) * @param user_id Unique identifier of the target user * @param signal Optional `AbortSignal` to cancel the request * * **Official reference:** https://core.telegram.org/bots/api#getuserchatboosts */ getUserChatBoosts(chat_id, user_id, signal) { return this.raw.getUserChatBoosts({ chat_id, user_id }, signal); } /** * Use this method to get information about the connection of the bot with a business account. Returns a BusinessConnection object on success. * * @param business_connection_id Unique identifier of the business connection * @param signal Optional `AbortSignal` to cancel the request * * **Official reference:** https://core.telegram.org/bots/api#getbusinessconnection */ getBusinessConnection(business_connection_id, signal) { return this.raw.getBusinessConnection({ business_connection_id }, signal); } /** * Use this method to get basic info about a file and prepare it for downloading. For the moment, bots can download files of up to 20MB in size. On success, a File object is returned. The file can then be downloaded via the link `https://api.telegram.org/file/bot<token>/<file_path>`, where `<file_path>` is taken from the response. It is guaranteed that the link will be valid for at least 1 hour. When the link expires, a new one can be requested by calling getFile again. * * Note: This function may not preserve the original file name and MIME type. You should save the file's MIME type and name (if available) when the File object is received. * * @param file_id File identifier to get info about * @param signal Optional `AbortSignal` to cancel the request * * **Official reference:** https://core.telegram.org/bots/api#getfile */ getFile(file_id, signal) { return this.raw.getFile({ file_id }, signal); } /** @deprecated Use `banChatMember` instead. */ kickChatMember(...args) { return this.banChatMember(...args); } /** * 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. * * @param chat_id Unique identifier for the target group or username of the target supergroup or channel (in the format @channelusername) * @param user_id Unique identifier of the target user * @param other Optional remaining parameters, confer the official reference below * @param signal Optional `AbortSignal` to cancel the request * * **Official reference:** https://core.telegram.org/bots/api#banchatmember */ banChatMember(chat_id, user_id, other, signal) { return this.raw.banChatMember({ chat_id, user_id, ...other }, signal); } /** * Use this method to unban a previously banned user in a supergroup or channel. The user will not return to the group or channel automatically, but will be able to join via link, etc. The bot must be an administrator for this to work. By default, this method guarantees that after the call the user is not a member of the chat, but will be able to join it. So if the user is a member of the chat they will also be removed from the chat. If you don't want this, use the parameter only_if_banned. Returns True on success. * * @param chat_id Unique identifier for the target group or username of the target supergroup or channel (in the format @username) * @param user_id Unique identifier of the target user * @param other Optional remaining parameters, confer the official reference below * @param signal Optional `AbortSignal` to cancel the request * * **Official reference:** https://core.telegram.org/bots/api#unbanchatmember */ unbanChatMember(chat_id, user_id, other, signal) { return this.raw.unbanChatMember({ chat_id, user_id, ...other }, signal); } /** * Use this method to restrict a user in a supergroup. The bot must be an administrator in the supergroup for this to work and must have the appropriate administrator rights. Pass True for all permissions to lift restrictions from a user. Returns True on success. * * @param chat_id Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername) * @param user_id Unique identifier of the target user * @param permissions An object for new user permissions * @param other Optional remaining parameters, confer the official reference below * @param signal Optional `AbortSignal` to cancel the request * * **Official reference:** https://core.telegram.org/bots/api#restrictchatmember */ restrictChatMember(chat_id, user_id, permissions, other, signal) { return this.raw.restrictChatMember({ chat_id, user_id, permissions, ...other }, signal); } /** * 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. * * @param chat_id Unique identifier for the target chat or username of the target channel (in the format @channelusername) * @param user_id Unique identifier of the target user * @param other Optional remaining parameters, confer the official reference below * @param signal Optional `AbortSignal` to cancel the request * * **Official reference:** https://core.telegram.org/bots/api#promotechatmember */ promoteChatMember(chat_id, user_id, other, signal) { return this.raw.promoteChatMember({ chat_id, user_id, ...other }, signal); } /** * Use this method to set a custom title for an administrator in a supergroup promoted by the bot. Returns True on success. * * @param chat_id Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername) * @param user_id Unique identifier of the target user * @param custom_title New custom title for the administrator; 0-16 characters, emoji are not allowed * @param signal Optional `AbortSignal` to cancel the request * * **Official reference:** https://core.telegram.org/bots/api#setchatadministratorcustomtitle */ setChatAdministratorCustomTitle(chat_id, user_id, custom_title, signal) { return this.raw.setChatAdministratorCustomTitle({ chat_id, user_id, custom_title }, signal); } /** * 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. * * @param chat_id Unique identifier for the target chat or username of the target channel (in the format @channelusername) * @param sender_chat_id Unique identifier of the target sender chat * @param signal Optional `AbortSignal` to cancel the request * * **Official reference:** https://core.telegram.org/bots/api#banchatsenderchat */ banChatSenderChat(chat_id, sender_chat_id, signal) { return this.raw.banChatSenderChat({ chat_id, sender_chat_id }, signal); } /** * 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. * * @param chat_id Unique identifier for the target chat or username of the target channel (in the format @channelusername) * @param sender_chat_id Unique identifier of the target sender chat * @param signal Optional `AbortSignal` to cancel the request * * **Official reference:** https://core.telegram.org/bots/api#unbanchatsenderchat */ unbanChatSenderChat(chat_id, sender_chat_id, signal) { return this.raw.unbanChatSenderChat({ chat_id, sender_chat_id }, signal); } /** * Use this method to set default chat permissions for all members. The bot must be an administrator in the group or a supergroup for this to work and must have the can_restrict_members administrator rights. Returns True on success. * * @param chat_id Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername) * @param permissions New default chat permissions * @param other Optional remaining parameters, confer the official reference below * @param signal Optional `AbortSignal` to cancel the request * * **Official reference:** https://core.telegram.org/bots/api#setchatpermissions */ setChatPermissions(chat_id, permissions, other, signal) { return this.raw.setChatPermissions({ chat_id, permissions, ...other }, signal); } /** * Use this method to generate a new primary invite link for a chat; any previously generated primary link is revoked. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns the new invite link as String on success. * * 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. * * @param chat_id Unique identifier for the target chat or username of the target channel (in the format @channelusername) * @param signal Optional `AbortSignal` to cancel the request * * **Official reference:** https://core.telegram.org/bots/api#exportchatinvitelink */ exportChatInviteLink(chat_id, signal) { return this.raw.exportChatInviteLink({ chat_id }, signal); } /** * 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. * * @param chat_id Unique identifier for the target chat or username of the target channel (in the format @channelusername) * @param other Optional remaining parameters, confer the official reference below * @param signal Optional `AbortSignal` to cancel the request * * **Official reference:** https://core.telegram.org/bots/api#createchatinvitelink */ createChatInviteLink(chat_id, other, signal) { return this.raw.createChatInviteLink({ chat_id, ...other }, signal); } /** * 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. * * @param chat_id Unique identifier for the target chat or username of the target channel (in the format @channelusername) * @param invite_link The invite link to edit * @param other Optional remaining parameters, confer the official reference below * @param signal Optional `AbortSignal` to cancel the request * * **Official reference:** https://core.telegram.org/bots/api#editchatinvitelink */ editChatInviteLink(chat_id, invite_link, other, signal) { return this.raw.editChatInviteLink({ chat_id, invite_link, ...other }, signal); } /** * 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. * * @param chat_id Unique identifier for the target channel chat or username of the target channel (in the format @channelusername) * @param subscription_period The number of seconds the subscription will be active for before the next payment. Currently, it must always be 2592000 (30 days). * @param subscription_price The amount of Telegram Stars a user must pay initially and after each subsequent subscription period to be a member of the chat; 1-2500 * @param other Optional remaining parameters, confer the official reference below * @param signal Optional `AbortSignal` to cancel the request * * **Official reference:** https://core.telegram.org/bots/api#createchatsubscriptioninvitelink */ createChatSubscriptionInviteLink(chat_id, subscription_period, subscription_price, other, signal) { return this.raw.createChatSubscriptionInviteLink({ chat_id, subscription_period, subscription_price, ...other }, signal); } /** * 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. * * @param chat_id Unique identifier for the target chat or username of the target channel (in the format @channelusername) * @param invite_link The invite link to edit * @param other Optional remaining parameters, confer the official reference below * @param signal Optional `AbortSignal` to cancel the request * * **Official reference:** https://core.telegram.org/bots/api#editchatsubscriptioninvitelink */ editChatSubscriptionInviteLink(chat_id, invite_link, other, signal) { return this.raw.editChatSubscriptionInviteLink({ chat_id, invite_link, ...other }, signal); } /** * 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. * * @param chat_id Unique identifier of the target chat or username of the target channel (in the format @channelusername) * @param invite_link The invite link to revoke * @param signal Optional `AbortSignal` to canc