UNPKG

typescript-telegram-bot-api

Version:

Telegram Bot API wrapper for Node.js written in TypeScript

1,042 lines 92.8 kB
import { EventEmitter } from 'events'; import FormData from 'form-data'; import { TelegramError } from './errors'; import { ReadStream } from 'fs'; import { Update, UpdateType, MessageEntity, Message, MessageId, LinkPreviewOptions, ReplyParameters, InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply, User, InputFile, InputMediaAudio, InputMediaDocument, InputMediaPhoto, InputMediaVideo, InputPollOption, UserProfilePhotos, ChatPermissions, ChatInviteLink, ChatFullInfo, Sticker, ReactionType, ChatMember, ForumTopic, BusinessConnection, BotCommandScope, BotCommand, BotName, BotDescription, BotShortDescription, MenuButton, ChatAdministratorRights, InputMedia, Poll, ChatBoost, StickerSet, InputSticker, InlineQueryResult, InlineQueryResultsButton, SentWebAppMessage, LabeledPrice, ShippingOption, MaskPosition, PassportElementError, GameHighScore, ParseMode, EventTypes, MessageTypes, StarTransactions, InputPaidMedia, WebhookInfo, Currencies, Gifts } from './types/'; import * as TelegramTypes from './types/'; import { ExactlyOne } from './utils'; /** * All events such as `message`, `callback_query`, `message:location` etc. */ type allEmittedTypes = EventTypes & MessageTypes; /** * A class for wrapping files or buffers, intended for use when sending files in requests. * Allows you to specify additional file parameters. */ export declare class FileOptions { file: ReadStream | Buffer | File; options?: (FormData.AppendOptions | string) | undefined; constructor(file: ReadStream | Buffer | File, options?: (FormData.AppendOptions | string) | undefined); } export declare class TelegramBot extends EventEmitter { private readonly polling; botToken: string; testEnvironment: boolean; baseURL: string; autoRetry: boolean; autoRetryLimit: number; allowedUpdates: UpdateType[]; pollingTimeout: number; constructor(options: { botToken: string; testEnvironment?: boolean; baseURL?: string; autoRetry?: boolean; autoRetryLimit?: number; allowedUpdates?: UpdateType[]; pollingTimeout?: number; }); static isTelegramError(error: unknown): error is TelegramError; startPolling(): Promise<void>; stopPolling(): Promise<void>; private request; private serializeJSON; private handleObject; private createFormData; private callApi; processUpdate(update: Update): Promise<void>; /** * ## getUpdates * Use this method to receive incoming updates using long polling [wiki](https://en.wikipedia.org/wiki/Push_technology#Long_polling). Returns an Array of Update objects. * @see https://core.telegram.org/bots/api#getupdates */ getUpdates(options?: { /** * Identifier of the first update to be returned. Must be greater by one than the highest among the identifiers of * previously received updates. By default, updates starting with the earliest unconfirmed update are returned. An * update is considered confirmed as soon as getUpdates is called with an offset higher than its update_id. The * negative offset can be specified to retrieve updates starting from -offset update from the end of the updates * queue. All previous updates will be forgotten. */ offset?: number; /** * Limits the number of updates to be retrieved. Values between 1-100 are accepted. Defaults to 100. */ limit?: number; /** * Timeout in seconds for long polling. Defaults to 0, i.e. usual short polling. Should be positive, short polling * should be used for testing purposes only. */ timeout?: number; /** * A JSON-serialized list of the update types you want your bot to receive. For example, specify `["message", * "edited_channel_post", "callback_query"]` to only receive updates of these types. See Update for a complete * list of available update types. Specify an empty list to receive all update types except chat_member, * message_reaction, and message_reaction_count (default). If not specified, the previous setting will be used. * * Please note that this parameter doesn't affect updates created before the call to the getUpdates, so unwanted * updates may be received for a short period of time. */ allowed_updates?: UpdateType[]; }, abortController?: AbortController): Promise<Update[]>; /** * ## setWebhook * 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. * @see https://core.telegram.org/bots/api#setwebhook */ setWebhook(options: { /** * HTTPS URL to send updates to. Use an empty string to remove webhook integration */ url: string; /** * Upload your public key certificate so that the root certificate in use can be checked. See our self-signed guide * for details. */ certificate?: InputFile; /** * The fixed IP address which will be used to send webhook requests instead of the IP address resolved through DNS */ ip_address?: string; /** * The maximum allowed number of simultaneous HTTPS connections to the webhook for update delivery, 1-100. Defaults * to 40. Use lower values to limit the load on your bot's server, and higher values to increase your bot's * throughput. */ max_connections?: number; /** * A JSON-serialized list of the update types you want your bot to receive. For example, specify `["message", * "edited_channel_post", "callback_query"]` to only receive updates of these types. See Update for a complete list * of available update types. Specify an empty list to receive all update types except chat_member, * message_reaction, and message_reaction_count (default). If not specified, the previous setting will be used. * Please note that this parameter doesn't affect updates created before the call to the setWebhook, so unwanted * updates may be received for a short period of time. */ allowed_updates?: UpdateType[]; /** * Pass True to drop all pending updates */ drop_pending_updates?: boolean; /** * A secret token to be sent in a header “X-Telegram-Bot-Api-Secret-Token” in every webhook request, 1-256 * characters. Only characters `A-Z`, `a-z`, `0-9`, `_` and `-` are allowed. The header is useful to ensure that the * request comes from a webhook set by you. */ secret_token?: string; }): Promise<true>; /** * ## deleteWebhook * Use this method to remove webhook integration if you decide to switch back to getUpdates. Returns True on success. * @see https://core.telegram.org/bots/api#deletewebhook */ deleteWebhook(options?: { drop_pending_updates?: boolean; }): Promise<true>; /** * ## getWebhookInfo * 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. * @see https://core.telegram.org/bots/api#getwebhookinfo */ getWebhookInfo(): Promise<WebhookInfo | { url: ''; }>; /** * ## getMe * 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. * @see https://core.telegram.org/bots/api#getme */ getMe(): Promise<User>; /** * ## logOut * 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. * @see https://core.telegram.org/bots/api#logout */ logOut(): Promise<true>; /** * ## close * 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. * @see https://core.telegram.org/bots/api#close */ close(): Promise<true>; /** * ## sendMessage * Use this method to send text messages. On success, the sent Message is returned. * @see https://core.telegram.org/bots/api#sendmessage */ sendMessage(options: { /** * Unique identifier of the business connection on behalf of which the message will be sent */ business_connection_id?: string; /** * Unique identifier for the target chat or username of the target channel (in the format `@channelusername`) */ chat_id: number | string; /** * Unique identifier for the target message thread (topic) of the forum; for forum supergroups only */ message_thread_id?: number; /** * 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. */ parse_mode?: ParseMode; /** * A JSON-serialized 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 */ link_preview_options?: LinkPreviewOptions; /** * Sends the message silently. Users will receive a notification with no sound. */ disable_notification?: boolean; /** * Protects the contents of the sent message from forwarding and saving */ protect_content?: boolean; /** * Pass True to allow up to 1000 messages per second, ignoring * [broadcasting limits](https://core.telegram.org/bots/faq#how-can-i-message-all-of-my-bot-39s-subscribers-at-once) * for a fee of 0.1 Telegram Stars per message. The relevant Stars will be withdrawn from the bot's balance */ allow_paid_broadcast?: boolean; /** * Unique identifier of the message effect to be added to the message; for private chats only */ message_effect_id?: string; /** * Description of the message to reply to */ reply_parameters?: ReplyParameters; /** * Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, * instructions to remove a reply keyboard or to force a reply from the user */ reply_markup?: InlineKeyboardMarkup | ReplyKeyboardMarkup | ReplyKeyboardRemove | ForceReply; }): Promise<Message>; /** * ## forwardMessage * 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. * @see https://core.telegram.org/bots/api#forwardmessage */ forwardMessage(options: { chat_id: number | string; message_thread_id?: number; from_chat_id: number | string; video_start_timestamp?: number; disable_notification?: boolean; protect_content?: boolean; message_id: number; }): Promise<Message>; /** * ## forwardMessages * 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. * @see https://core.telegram.org/bots/api#forwardmessages */ forwardMessages(options: { chat_id: number | string; message_thread_id?: number; from_chat_id: number | string; message_ids: number[]; disable_notification?: boolean; protect_content?: boolean; }): Promise<MessageId[]>; /** * ## copyMessage * 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. * @see https://core.telegram.org/bots/api#copymessage */ copyMessage(options: { chat_id: number | string; message_thread_id?: number; from_chat_id: number | string; message_id: number; video_start_timestamp?: number; caption?: string; parse_mode?: ParseMode; caption_entities?: MessageEntity[]; show_caption_above_media?: boolean; disable_notification?: boolean; protect_content?: boolean; /** * Pass True to allow up to 1000 messages per second, ignoring * [broadcasting limits](https://core.telegram.org/bots/faq#how-can-i-message-all-of-my-bot-39s-subscribers-at-once) * for a fee of 0.1 Telegram Stars per message. The relevant Stars will be withdrawn from the bot's balance */ allow_paid_broadcast?: boolean; reply_parameters?: ReplyParameters; reply_markup?: InlineKeyboardMarkup | ReplyKeyboardMarkup | ReplyKeyboardRemove | ForceReply; }): Promise<MessageId>; /** * ## copyMessages * Use this method to copy messages of any kind. If some of the specified messages can't be found or copied, they are * skipped. Service messages, giveaway messages, giveaway winners messages, and invoice messages can't be copied. A * quiz poll can be copied only if the value of the field correct_option_id is known to the bot. The method is * analogous to the method forwardMessages, but the copied messages don't have a link to the original message. Album * grouping is kept for copied messages. On success, an array of MessageId of the sent messages is returned. * @see https://core.telegram.org/bots/api#copymessages */ copyMessages(options: { chat_id: number | string; message_thread_id?: number; from_chat_id: number | string; message_ids: number[]; disable_notification?: boolean; protect_content?: boolean; remove_caption?: boolean; }): Promise<MessageId[]>; /** * ## sendPhoto * Use this method to copy messages of any kind. If some of the specified messages can't be found or copied, they are * skipped. Service messages, giveaway messages, giveaway winners messages, and invoice messages can't be copied. A * quiz poll can be copied only if the value of the field correct_option_id is known to the bot. The method is * analogous to the method forwardMessages, but the copied messages don't have a link to the original message. Album * grouping is kept for copied messages. On success, an array of MessageId of the sent messages is returned. * @see https://core.telegram.org/bots/api#sendphoto */ sendPhoto(options: { business_connection_id?: string; chat_id: number | string; message_thread_id?: number; photo: InputFile | string; caption?: string; parse_mode?: ParseMode; caption_entities?: MessageEntity[]; show_caption_above_media?: boolean; has_spoiler?: boolean; disable_notification?: boolean; protect_content?: boolean; /** * Pass True to allow up to 1000 messages per second, ignoring * [broadcasting limits](https://core.telegram.org/bots/faq#how-can-i-message-all-of-my-bot-39s-subscribers-at-once) * for a fee of 0.1 Telegram Stars per message. The relevant Stars will be withdrawn from the bot's balance */ allow_paid_broadcast?: boolean; message_effect_id?: string; reply_parameters?: ReplyParameters; reply_markup?: InlineKeyboardMarkup | ReplyKeyboardMarkup | ReplyKeyboardRemove | ForceReply; }): Promise<Message>; /** * ## sendAudio * 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. * @see https://core.telegram.org/bots/api#sendaudio */ sendAudio(options: { business_connection_id?: string; chat_id: number | string; message_thread_id?: number; audio: InputFile | string; caption?: string; parse_mode?: ParseMode; caption_entities?: MessageEntity[]; duration?: number; performer?: string; title?: string; thumbnail?: InputFile | string; disable_notification?: boolean; protect_content?: boolean; /** * Pass True to allow up to 1000 messages per second, ignoring * [broadcasting limits](https://core.telegram.org/bots/faq#how-can-i-message-all-of-my-bot-39s-subscribers-at-once) * for a fee of 0.1 Telegram Stars per message. The relevant Stars will be withdrawn from the bot's balance */ allow_paid_broadcast?: boolean; message_effect_id?: string; reply_parameters?: ReplyParameters; reply_markup?: InlineKeyboardMarkup | ReplyKeyboardMarkup | ReplyKeyboardRemove | ForceReply; }): Promise<Message>; /** ## sendDocument * 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. * @see https://core.telegram.org/bots/api#senddocument */ sendDocument(options: { business_connection_id?: string; chat_id: number | string; message_thread_id?: number; document: InputFile | string; thumbnail?: InputFile | string; caption?: string; parse_mode?: ParseMode; caption_entities?: MessageEntity[]; disable_content_type_detection?: boolean; disable_notification?: boolean; protect_content?: boolean; /** * Pass True to allow up to 1000 messages per second, ignoring * [broadcasting limits](https://core.telegram.org/bots/faq#how-can-i-message-all-of-my-bot-39s-subscribers-at-once) * for a fee of 0.1 Telegram Stars per message. The relevant Stars will be withdrawn from the bot's balance */ allow_paid_broadcast?: boolean; message_effect_id?: string; reply_parameters?: ReplyParameters; reply_markup?: InlineKeyboardMarkup | ReplyKeyboardMarkup | ReplyKeyboardRemove | ForceReply; }): Promise<Message>; /** * ## sendVideo * Use this method to send video files, Telegram clients support MPEG4 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. * @see https://core.telegram.org/bots/api#sendvideo */ sendVideo(options: { business_connection_id?: string; chat_id: number | string; message_thread_id?: number; video: InputFile | string; duration?: number; width?: number; height?: number; thumbnail?: InputFile | string; cover?: InputFile | string; start_timestamp?: number; caption?: string; parse_mode?: ParseMode; caption_entities?: MessageEntity[]; show_caption_above_media?: boolean; has_spoiler?: boolean; supports_streaming?: boolean; disable_notification?: boolean; protect_content?: boolean; /** * Pass True to allow up to 1000 messages per second, ignoring * [broadcasting limits](https://core.telegram.org/bots/faq#how-can-i-message-all-of-my-bot-39s-subscribers-at-once) * for a fee of 0.1 Telegram Stars per message. The relevant Stars will be withdrawn from the bot's balance */ allow_paid_broadcast?: boolean; message_effect_id?: string; reply_parameters?: ReplyParameters; reply_markup?: InlineKeyboardMarkup | ReplyKeyboardMarkup | ReplyKeyboardRemove | ForceReply; }): Promise<Message>; /** * ## sendAnimation * 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. * @see https://core.telegram.org/bots/api#sendanimation */ sendAnimation(options: { business_connection_id?: string; chat_id: number | string; message_thread_id?: number; animation: InputFile | string; duration?: number; width?: number; height?: number; thumbnail?: InputFile | string; caption?: string; parse_mode?: ParseMode; caption_entities?: MessageEntity[]; show_caption_above_media?: boolean; has_spoiler?: boolean; disable_notification?: boolean; protect_content?: boolean; /** * Pass True to allow up to 1000 messages per second, ignoring * [broadcasting limits](https://core.telegram.org/bots/faq#how-can-i-message-all-of-my-bot-39s-subscribers-at-once) * for a fee of 0.1 Telegram Stars per message. The relevant Stars will be withdrawn from the bot's balance */ allow_paid_broadcast?: boolean; message_effect_id?: string; reply_parameters?: ReplyParameters; reply_markup?: InlineKeyboardMarkup | ReplyKeyboardMarkup | ReplyKeyboardRemove | ForceReply; }): Promise<Message>; /** * ## sendVoice * Use this method to send audio files, if you want Telegram clients to display the file as a playable voice message. * For this to work, your audio must be in an .OGG file encoded with OPUS, or in .MP3 format, or in .M4A format (other * formats may be sent as Audio 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. * @see https://core.telegram.org/bots/api#sendvoice */ sendVoice(options: { business_connection_id?: string; chat_id: number | string; message_thread_id?: number; voice: InputFile | string; caption?: string; parse_mode?: ParseMode; caption_entities?: MessageEntity[]; duration?: number; disable_notification?: boolean; protect_content?: boolean; /** * Pass True to allow up to 1000 messages per second, ignoring * [broadcasting limits](https://core.telegram.org/bots/faq#how-can-i-message-all-of-my-bot-39s-subscribers-at-once) * for a fee of 0.1 Telegram Stars per message. The relevant Stars will be withdrawn from the bot's balance */ allow_paid_broadcast?: boolean; message_effect_id?: string; reply_parameters?: ReplyParameters; reply_markup?: InlineKeyboardMarkup | ReplyKeyboardMarkup | ReplyKeyboardRemove | ForceReply; }): Promise<Message>; /** * ## sendVideoNote * As of v.4.0, Telegram clients support rounded square MPEG4 videos of up to 1 minute long. Use this method to send * video messages. On success, the sent Message is returned. * @see https://core.telegram.org/bots/api#sendvideonote */ sendVideoNote(options: { business_connection_id?: string; chat_id: number | string; message_thread_id?: number; video_note: InputFile | string; duration?: number; length?: number; thumbnail?: InputFile | string; disable_notification?: boolean; protect_content?: boolean; /** * Pass True to allow up to 1000 messages per second, ignoring * [broadcasting limits](https://core.telegram.org/bots/faq#how-can-i-message-all-of-my-bot-39s-subscribers-at-once) * for a fee of 0.1 Telegram Stars per message. The relevant Stars will be withdrawn from the bot's balance */ allow_paid_broadcast?: boolean; message_effect_id?: string; reply_parameters?: ReplyParameters; reply_markup?: InlineKeyboardMarkup | ReplyKeyboardMarkup | ReplyKeyboardRemove | ForceReply; }): Promise<Message>; /** * ## sendPaidMedia * Use this method to send paid media to channel chats. On success, the sent Message is returned. * @see https://core.telegram.org/bots/api#sendpaidmedia */ sendPaidMedia(options: { business_connection_id?: string; chat_id: number | string; star_count: number; media: InputPaidMedia[]; payload?: string; caption?: string; parse_mode?: ParseMode; caption_entities?: MessageEntity[]; show_caption_above_media?: boolean; disable_notification?: boolean; protect_content?: boolean; /** * Pass True to allow up to 1000 messages per second, ignoring * [broadcasting limits](https://core.telegram.org/bots/faq#how-can-i-message-all-of-my-bot-39s-subscribers-at-once) * for a fee of 0.1 Telegram Stars per message. The relevant Stars will be withdrawn from the bot's balance */ allow_paid_broadcast?: boolean; reply_parameters?: ReplyParameters; reply_markup?: InlineKeyboardMarkup | ReplyKeyboardMarkup | ReplyKeyboardRemove | ForceReply; }): Promise<Message>; /** * ## sendMediaGroup * 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. * @see https://core.telegram.org/bots/api#sendmediagroup */ sendMediaGroup(options: { business_connection_id?: string; chat_id: number | string; message_thread_id?: number; media: (InputMediaAudio | InputMediaDocument | InputMediaPhoto | InputMediaVideo)[]; disable_notification?: boolean; protect_content?: boolean; /** * Pass True to allow up to 1000 messages per second, ignoring * [broadcasting limits](https://core.telegram.org/bots/faq#how-can-i-message-all-of-my-bot-39s-subscribers-at-once) * for a fee of 0.1 Telegram Stars per message. The relevant Stars will be withdrawn from the bot's balance */ allow_paid_broadcast?: boolean; message_effect_id?: string; reply_parameters?: ReplyParameters; }): Promise<Message[]>; /** * ## sendLocation * Use this method to send point on the map. On success, the sent Message is returned. * @see https://core.telegram.org/bots/api#sendlocation */ sendLocation(options: { business_connection_id?: string; chat_id: number | string; message_thread_id?: number; latitude: number; longitude: number; horizontal_accuracy?: number; live_period?: number; heading?: number; proximity_alert_radius?: number; disable_notification?: boolean; protect_content?: boolean; /** * Pass True to allow up to 1000 messages per second, ignoring * [broadcasting limits](https://core.telegram.org/bots/faq#how-can-i-message-all-of-my-bot-39s-subscribers-at-once) * for a fee of 0.1 Telegram Stars per message. The relevant Stars will be withdrawn from the bot's balance */ allow_paid_broadcast?: boolean; message_effect_id?: string; reply_parameters?: ReplyParameters; reply_markup?: InlineKeyboardMarkup | ReplyKeyboardMarkup | ReplyKeyboardRemove | ForceReply; }): Promise<Message>; /** * ## sendVenue * Use this method to send information about a venue. On success, the sent Message is returned. * @see https://core.telegram.org/bots/api#sendvenue */ sendVenue(options: { business_connection_id?: string; chat_id: number | string; message_thread_id?: number; latitude: number; longitude: number; title: string; address: string; foursquare_id?: string; foursquare_type?: string; google_place_id?: string; google_place_type?: string; disable_notification?: boolean; protect_content?: boolean; /** * Pass True to allow up to 1000 messages per second, ignoring * [broadcasting limits](https://core.telegram.org/bots/faq#how-can-i-message-all-of-my-bot-39s-subscribers-at-once) * for a fee of 0.1 Telegram Stars per message. The relevant Stars will be withdrawn from the bot's balance */ allow_paid_broadcast?: boolean; message_effect_id?: string; reply_parameters?: ReplyParameters; reply_markup?: InlineKeyboardMarkup | ReplyKeyboardMarkup | ReplyKeyboardRemove | ForceReply; }): Promise<Message>; /** * ## sendContact * Use this method to send phone contacts. On success, the sent Message is returned. * @see https://core.telegram.org/bots/api#sendcontact */ sendContact(options: { business_connection_id?: string; chat_id: number | string; message_thread_id?: number; phone_number: string; first_name: string; last_name?: string; vcard?: string; disable_notification?: boolean; protect_content?: boolean; /** * Pass True to allow up to 1000 messages per second, ignoring * [broadcasting limits](https://core.telegram.org/bots/faq#how-can-i-message-all-of-my-bot-39s-subscribers-at-once) * for a fee of 0.1 Telegram Stars per message. The relevant Stars will be withdrawn from the bot's balance */ allow_paid_broadcast?: boolean; message_effect_id?: string; reply_parameters?: ReplyParameters; reply_markup?: InlineKeyboardMarkup | ReplyKeyboardMarkup | ReplyKeyboardRemove | ForceReply; }): Promise<Message>; /** * ## sendPoll * se this method to send a native poll. On success, the sent Message is returned. * @see https://core.telegram.org/bots/api#sendpoll */ sendPoll(options: { business_connection_id?: string; chat_id: number | string; message_thread_id?: number; question: string; question_parse_mode?: ParseMode; question_entities?: MessageEntity[]; options: InputPollOption[]; is_anonymous?: boolean; type?: 'quiz' | 'regular'; allows_multiple_answers?: boolean; correct_option_id?: number; explanation?: string; explanation_parse_mode?: ParseMode; explanation_entities?: MessageEntity[]; open_period?: number; close_date?: number; is_closed?: boolean; disable_notification?: boolean; protect_content?: boolean; /** * Pass True to allow up to 1000 messages per second, ignoring * [broadcasting limits](https://core.telegram.org/bots/faq#how-can-i-message-all-of-my-bot-39s-subscribers-at-once) * for a fee of 0.1 Telegram Stars per message. The relevant Stars will be withdrawn from the bot's balance */ allow_paid_broadcast?: boolean; message_effect_id?: string; reply_parameters?: ReplyParameters; reply_markup?: InlineKeyboardMarkup | ReplyKeyboardMarkup | ReplyKeyboardRemove | ForceReply; }): Promise<Message>; /** * ## sendDice * Use this method to send an animated emoji that will display a random value. On success, the sent Message is * returned. * @see https://core.telegram.org/bots/api#senddice */ sendDice(options: { business_connection_id?: string; chat_id: number | string; message_thread_id?: number; emoji?: '🎲' | '🎯' | '🏀' | '⚽' | '🎳' | '🎰'; disable_notification?: boolean; protect_content?: boolean; /** * Pass True to allow up to 1000 messages per second, ignoring * [broadcasting limits](https://core.telegram.org/bots/faq#how-can-i-message-all-of-my-bot-39s-subscribers-at-once) * for a fee of 0.1 Telegram Stars per message. The relevant Stars will be withdrawn from the bot's balance */ allow_paid_broadcast?: boolean; message_effect_id?: string; reply_parameters?: ReplyParameters; reply_markup?: InlineKeyboardMarkup | ReplyKeyboardMarkup | ReplyKeyboardRemove | ForceReply; }): Promise<Message>; /** * ## sendChatAction * 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. * @see https://core.telegram.org/bots/api#sendchataction */ sendChatAction(options: { business_connection_id?: string; chat_id: number | string; message_thread_id?: number; action: 'typing' | 'upload_photo' | 'record_video' | 'upload_video' | 'record_voice' | 'upload_voice' | 'upload_document' | 'choose_sticker' | 'find_location' | 'record_video_note' | 'upload_video_note'; }): Promise<true>; /** * ## setMessageReaction * Use this method to change the chosen reactions on a message. Service messages 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. Returns True on success. * @see https://core.telegram.org/bots/api#setmessagereaction */ setMessageReaction(options: { chat_id: number | string; message_id: number; reaction?: ReactionType[]; is_big?: boolean; }): Promise<true>; /** * ## getUserProfilePhotos * Use this method to get a list of profile pictures for a user. Returns a UserProfilePhotos object. * @see https://core.telegram.org/bots/api#getuserprofilephotos */ getUserProfilePhotos(options: { user_id: number; offset?: number; limit?: number; }): Promise<UserProfilePhotos>; /** * ## setUserEmojiStatus * 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. * @see https://core.telegram.org/bots/api#setuseremojistatus */ setUserEmojiStatus(options: { user_id: number; emoji_status_custom_emoji_id?: string; emoji_status_expiration_date?: number; }): Promise<boolean>; /** * ## getFile * Use this method to get basic information about a file and prepare it for downloading. For the moment, bots can * download files of up to 20MB in size. On success, a File 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. * @see https://core.telegram.org/bots/api#getfile */ getFile(options: { file_id: string; }): Promise<TelegramTypes.File>; /** * ## banChatMember * 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. * @see https://core.telegram.org/bots/api#banchatmember */ banChatMember(options: { chat_id: number | string; user_id: number; until_date?: number; revoke_messages?: boolean; }): Promise<true>; /** * ## unbanChatMember * 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. * @see https://core.telegram.org/bots/api#unbanchatmember */ unbanChatMember(options: { chat_id: number | string; user_id: number; only_if_banned?: boolean; }): Promise<true>; /** * ## restrictChatMember * 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. * @see https://core.telegram.org/bots/api#restrictchatmember */ restrictChatMember(options: { chat_id: number | string; user_id: number; permissions: ChatPermissions; use_independent_chat_permissions?: boolean; until_date?: number; }): Promise<true>; /** * ## promoteChatMember * 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. * @see https://core.telegram.org/bots/api#promotechatmember */ promoteChatMember(options: { chat_id: number | string; user_id: number; is_anonymous?: boolean; can_manage_chat?: boolean; can_delete_messages?: boolean; can_manage_video_chats?: boolean; can_restrict_members?: boolean; can_promote_members?: boolean; can_change_info?: boolean; can_invite_users?: boolean; can_post_stories?: boolean; can_edit_stories?: boolean; can_delete_stories?: boolean; can_post_messages?: boolean; can_edit_messages?: boolean; can_pin_messages?: boolean; can_manage_topics?: boolean; }): Promise<true>; /** * ## setChatAdministratorCustomTitle * Use this method to set a custom title for an administrator in a supergroup promoted by the bot. Returns True on * success. * @see https://core.telegram.org/bots/api#setchatadministratorcustomtitle */ setChatAdministratorCustomTitle(options: { chat_id: number | string; user_id: number; custom_title: string; }): Promise<true>; /** * ## banChatSenderChat * 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. * @see https://core.telegram.org/bots/api#banchatsenderchat */ banChatSenderChat(options: { chat_id: number | string; sender_chat_id: number; }): Promise<true>; /** * ## unbanChatSenderChat * 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. * @see https://core.telegram.org/bots/api#unbanchatsenderchat */ unbanChatSenderChat(options: { chat_id: number | string; sender_chat_id: number; }): Promise<true>; /** * ## setChatPermissions * 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. * @see https://core.telegram.org/bots/api#setchatpermissions */ setChatPermissions(options: { chat_id: number | string; permissions: ChatPermissions; use_independent_chat_permissions?: boolean; }): Promise<true>; /** * ## exportChatInviteLink * 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. * @see https://core.telegram.org/bots/api#exportchatinvitelink */ exportChatInviteLink(options: { chat_id: number | string; }): Promise<string>; /** * ## createChatSubscriptionInviteLink * 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(options: { chat_id: number | string; name?: string; subscription_period: number; subscription_price: number; }): Promise<ChatInviteLink>; /** * ## editChatSubscriptionInviteLink * 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(options: { chat_id: number | string; invite_link: string; name?: string; }): Promise<ChatInviteLink>; /** * ## createChatInviteLink * 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. * @see https://core.telegram.org/bots/api#createchatinvitelink */ createChatInviteLink(options: { chat_id: number | string; name?: string; expire_date?: number; member_limit?: number; creates_join_request?: boolean; }): Promise<ChatInviteLink>; /** * ## editChatInviteLink * 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. * @see https://core.telegram.org/bots/api#editchatinvitelink */ editChatInviteLink(options: { chat_id: number | string; invite_link: string; name?: string; expire_date?: number; member_limit?: number; creates_join_request?: boolean; }): Promise<ChatInviteLink>; /** * ## revokeChatInviteLink * 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. * @see https://core.telegram.org/bots/api#revokechatinvitelink */ revokeChatInviteLink(options: { chat_id: number | string; invite_link: string; }): Promise<ChatInviteLink>; /** * ## approveChatJoinRequest * 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. * @see https://core.telegram.org/bots/api#approvechatjoinrequest */ approveChatJoinRequest(options: { chat_id: number | string; user_id: number; }): Promise<true>; /** * ## declineChatJoinRequest * 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. * @see https://core.telegram.org/bots/api#declinechatjoinrequest */ declineChatJoinRequest(options: { chat_id: number | string; user_id: number; }): Promise<true>; /** * ## setChatPhoto * 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. * @see https://core.telegram.org/bots/api#setchatphoto */ setChatPhoto(options: { chat_id: number | string; photo: InputFile; }): Promise<true>; /** * ## deleteChatPhoto * 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. * @see https://core.telegram.org/bots/api#deletechatphoto */ deleteChatPhoto(options: { chat_id: number | string; }): Promise<true>; /** * ## setChatTitle * 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. * @see https://core.telegram.org/bots/api#setchattitle */ setChatTitle(options: { chat_id: number | string; title: string; }): Promise<true>; /** * ## setChatDescription * 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. * @see https://core.telegram.org/bots/api#setchatdescription */ setChatDescription(options: { chat_id: number | string; description?: string; }): Promise<true>; /** * ## pinChatMessage * Use this method to add a message to the list of pinned messages in a chat. If the chat is not a private chat, the * bot must be an administrator in the chat for this to work and must have the ```'can_pin_messages'``` administrator * right in a supergroup or ```'can_edit_messages'``` administrator right in a channel. Returns True on success. * @see https://core.telegram.org/bots/api#pinchatmessage */ pinChatMessage(options: { business_connection_id?: string; chat_id: number | string; message_id: number; disable_notification?: boolean; }): Promise<true>; /** * ## unpinChatMessage * Use this method to remove a message from the list of pinned messages in a chat. If the chat is not a private chat, * the bot must be an administrator in the chat for thi