import { default as Long } from 'long'; import { RpcCallOptions } from '../network/index.js'; import { tl } from '../tl/index.js'; import { MaybeArray, MaybePromise, PartialExcept, PartialOnly } from '../types/index.js'; import { BaseTelegramClientOptions } from './base.js'; import { ITelegramClient } from './client.types.js'; import { LogOutResult } from './methods/auth/log-out.js'; import { CreateGroupResult } from './methods/chats/create-group.js'; import { GetForumTopicsOffset, getForumTopics } from './methods/forums/get-forum-topics.js'; import { InputStarGiftAttributeIds, ResaleStarGiftsMeta } from './methods/gifts/get-resale-star-gifts.js'; import { StarGiftUpgradeOptions } from './methods/gifts/get-star-gift-upgrade-options.js'; import { GetInviteLinksOffset, getInviteLinks } from './methods/invite-links/get-invite-links.js'; import { StreamingDraft } from './methods/messages/create-streaming-draft.js'; import { DeleteMessagesParams } from './methods/messages/delete-messages.js'; import { ForwardMessageOptions } from './methods/messages/forward-messages.js'; import { GetHistoryOffset, getHistory } from './methods/messages/get-history.js'; import { GetReactionUsersOffset, getReactionUsers } from './methods/messages/get-reaction-users.js'; import { SearchGlobalOffset, searchGlobal } from './methods/messages/search-global.js'; import { SearchHashtagOffset, searchHashtag } from './methods/messages/search-hashtag.js'; import { SearchMessagesOffset, searchMessages } from './methods/messages/search-messages.js'; import { SearchPostsGlobalOffset } from './methods/messages/search-posts-global.js'; import { CommonSendParams } from './methods/messages/send-common.js'; import { SendCopyGroupParams } from './methods/messages/send-copy-group.js'; import { SendCopyParams } from './methods/messages/send-copy.js'; import { QuoteParamsFrom } from './methods/messages/send-quote.js'; import { InputStarsAmount } from './methods/premium/_normalize-stars-amount.js'; import { CanApplyBoostResult } from './methods/premium/can-apply-boost.js'; import { CanSendStoryResult } from './methods/stories/can-send-story.js'; import { ITelegramStorageProvider } from './storage/provider.js'; import { AllStories, ArrayPaginated, ArrayPaginatedWithMeta, ArrayWithTotal, Audio, Boost, BoostSlot, BoostStats, BotChatJoinRequestUpdate, BotCommands, BotReactionCountUpdate, BotReactionUpdate, BotStoppedUpdate, BusinessCallbackQuery, BusinessChatLink, BusinessConnection, BusinessMessage, BusinessWorkHoursDay, CallbackQuery, Chat, ChatEvent, ChatInviteLink, ChatInviteLinkMember, ChatJoinRequestUpdate, ChatlistPreview, ChatMember, ChatMemberUpdate, ChatPreview, ChosenInlineResult, CollectibleInfo, DeleteBusinessMessageUpdate, DeleteMessageUpdate, DeleteStoryUpdate, Dialog, FactCheck, FileDownloadLocation, FileDownloadParameters, ForumTopic, FullChat, FullUser, GameHighScore, HistoryReadUpdate, InlineCallbackQuery, InlineQuery, InputChatEventFilters, InputDialogFolder, InputDocumentId, InputFileLike, InputInlineResult, InputMediaAudio, InputMediaLike, InputMediaSticker, InputMessageId, InputPeerLike, InputPrivacyRule, InputReaction, InputStarGift, InputStickerSet, InputStickerSetItem, InputText, InputWebview, MaybeDynamic, Message, MessageEffect, MessageMedia, MessageReactions, ParametersSkip2, ParsedUpdate, Peer, PeerReaction, PeerSettings, PeerStories, Photo, Poll, PollUpdate, PollVoteUpdate, PreCheckoutQuery, RawDocument, ReplyMarkup, SavedStarGift, SentCode, StarGift, StarGiftUnique, StarGiftValue, StarsStatus, StarsTransaction, Sticker, StickerSet, StickerType, StoriesStealthMode, Story, StoryInteractions, StoryUpdate, StoryViewer, StoryViewersList, TakeoutSession, TextWithEntities, TypingStatus, UploadedFile, UploadFileLike, User, UserStatusUpdate, UserTypingUpdate, WebPageMedia, WebviewResult } from './types/index.js'; import { ParsedUpdateHandlerParams } from './updates/parsed.js'; import { RawUpdateInfo } from './updates/types.js'; import { InputStringSessionData } from './utils/string-session.js'; import { Emitter } from '@fuman/utils'; import { getChatEventLog } from './methods/chats/get-chat-event-log.js'; import { getChatMembers } from './methods/chats/get-chat-members.js'; import { getSavedStarGifts } from './methods/gifts/get-saved-star-gifts.js'; import { getInviteLinkMembers } from './methods/invite-links/get-invite-link-members.js'; import { sendMediaGroup } from './methods/messages/send-media-group.js'; import { sendMedia } from './methods/messages/send-media.js'; import { sendText } from './methods/messages/send-text.js'; import { getBoosts } from './methods/premium/get-boosts.js'; import { getStarsTransactions } from './methods/premium/get-stars-transactions.js'; import { getAllStories } from './methods/stories/get-all-stories.js'; import { getProfileStories } from './methods/stories/get-profile-stories.js'; import { getStoryViewers } from './methods/stories/get-story-viewers.js'; import { getProfilePhotos } from './methods/users/get-profile-photos.js'; type TelegramClientOptions = ((PartialOnly, 'transport' | 'crypto' | 'platform'> & { /** * Storage to use for this client. * * If a string is passed, it will be used as * a name for the default platform-specific storage provider to use. * * @default `"client.session"` */ storage?: string | ITelegramStorageProvider; }) | { client: ITelegramClient; }) & { /** * If true, all API calls will be wrapped with `tl.invokeWithoutUpdates`, * effectively disabling the server-sent events for the clients. * May be useful in some cases. * * @default false */ disableUpdates?: boolean; updates?: Omit; /** * If `true`, the updates that were handled by some {@link Conversation} * will not be dispatched any further. * * @default true */ skipConversationUpdates?: boolean; }; export interface TelegramClient extends ITelegramClient { /** Raw update emitter */ readonly onRawUpdate: Emitter; /** Parsed update emitter */ readonly onUpdate: Emitter; /** a new message handler */ readonly onNewMessage: Emitter; /** an edit message handler */ readonly onEditMessage: Emitter; /** a message group handler */ readonly onMessageGroup: Emitter; /** a delete message handler */ readonly onDeleteMessage: Emitter; /** a chat member update handler */ readonly onChatMemberUpdate: Emitter; /** an inline query handler */ readonly onInlineQuery: Emitter; /** a chosen inline result handler */ readonly onChosenInlineResult: Emitter; /** a callback query handler */ readonly onCallbackQuery: Emitter; /** an inline callback query handler */ readonly onInlineCallbackQuery: Emitter; /** a business callback query handler */ readonly onBusinessCallbackQuery: Emitter; /** a poll update handler */ readonly onPollUpdate: Emitter; /** a poll vote handler */ readonly onPollVote: Emitter; /** an user status update handler */ readonly onUserStatusUpdate: Emitter; /** an user typing handler */ readonly onUserTyping: Emitter; /** a history read handler */ readonly onHistoryRead: Emitter; /** a bot stopped handler */ readonly onBotStopped: Emitter; /** a bot chat join request handler */ readonly onBotChatJoinRequest: Emitter; /** a chat join request handler */ readonly onChatJoinRequest: Emitter; /** a pre checkout query handler */ readonly onPreCheckoutQuery: Emitter; /** a story update handler */ readonly onStoryUpdate: Emitter; /** a delete story handler */ readonly onDeleteStory: Emitter; /** a bot reaction update handler */ readonly onBotReactionUpdate: Emitter; /** a bot reaction count update handler */ readonly onBotReactionCountUpdate: Emitter; /** a business connection update handler */ readonly onBusinessConnectionUpdate: Emitter; /** a new business message handler */ readonly onNewBusinessMessage: Emitter; /** an edit business message handler */ readonly onEditBusinessMessage: Emitter; /** a business message group handler */ readonly onBusinessMessageGroup: Emitter; /** a delete business message handler */ readonly onDeleteBusinessMessage: Emitter; /** * Wrap this client so that all RPC calls will use the specified parameters. * * @param params Parameters to use * @returns Wrapped client */ withParams(params: RpcCallOptions): this; /** * Check your Two-Step verification password and log in * * **Available**: 👤 users only * * @returns The authorized user * @throws BadRequestError In case the password is invalid */ checkPassword(options: string | { /** Your Two-Step verification password */ password: string; /** Existing response from `account.getPassword`, if available (to avoid extra API calls) */ passwordObj?: tl.account.TypePassword; /** Abort signal */ abortSignal?: AbortSignal; }): Promise; /** * Get your Two-Step Verification password hint. * * **Available**: 👤 users only * * @returns The password hint as a string, if any */ getPasswordHint(): Promise; /** * Log out from Telegram account and optionally reset the session storage. * * When you log out, you can immediately log back in using * the same {@link TelegramClient} instance. * * **Available**: 👤 users only * * @returns On success, `true` is returned */ logOut(): Promise; /** * Recover your password with a recovery code and log in. * * **Available**: 👤 users only * * @returns The authorized user * @throws BadRequestError In case the code is invalid */ recoverPassword(params: { /** The recovery code sent via email */ recoveryCode: string; }): Promise; /** * Re-send the confirmation code using a different type. * * The type of the code to be re-sent is specified in the `nextType` attribute of * {@link SentCode} object returned by {@link sendCode} * **Available**: 👤 users only * */ resendCode(params: { /** Phone number in international format */ phone: string; /** Confirmation code identifier from {@link SentCode} */ phoneCodeHash: string; /** Abort signal */ abortSignal?: AbortSignal; }): Promise; /** * Send the confirmation code to the given phone number * * **Available**: 👤 users only * * @returns An object containing information about the sent confirmation code, * or a user if the user was already logged in */ sendCode(params: { /** Phone number in international format */ phone: string; /** Saved future auth tokens, if any */ futureAuthTokens?: Uint8Array[]; /** Additional code settings to pass to the server */ codeSettings?: Omit; /** Abort signal */ abortSignal?: AbortSignal; }): Promise; /** * Send a code to email needed to recover your password * * **Available**: 👤 users only * * @returns String containing email pattern to which the recovery code was sent */ sendRecoveryCode(): Promise; /** * Authorize a bot using its token issued by [@BotFather](//t.me/BotFather) * * **Available**: 👤 users only * * @param token Bot token issued by BotFather * @returns Bot's {@link User} object * @throws BadRequestError In case the bot token is invalid */ signInBot(token: string): Promise; /** * Execute the [QR login flow](https://core.telegram.org/api/qr-login). * * This method will resolve once the authorization is complete, * returning the authorized user. * **Available**: 👤 users only * */ signInQr(params: { /** * Function that will be called whenever the login URL is changed. * * The app is expected to display `url` as a QR code to the user */ onUrlUpdated: (url: string, expires: Date) => void; /** * Function that will be called when the user has scanned the QR code * (i.e. when `updateLoginToken` is received), and the library is finalizing the auth */ onQrScanned?: () => void; /** Password for 2FA */ password?: MaybeDynamic; /** * Function that will be called after the server has rejected the password. * * Note that in case {@link password} is not a function, * this callback will never be called, and an error will be thrown instead. */ invalidPasswordCallback?: () => MaybePromise; /** Abort signal */ abortSignal?: AbortSignal; }): Promise; /** * Authorize a user in Telegram with a valid confirmation code. * * **Available**: 👤 users only * * @returns If the code was valid and authorization succeeded, the {@link User} is returned. * @throws BadRequestError In case the arguments are invalid * @throws SessionPasswordNeededError In case a password is needed to sign in */ signIn(params: { /** Phone number in international format */ phone: string; /** Code identifier from {@link sendCode} */ phoneCodeHash: string; /** The confirmation code that was received */ phoneCode: string; /** Abort signal */ abortSignal?: AbortSignal; }): Promise; /** * Utility function to quickly authorize on test DC * using a [Test phone number](https://core.telegram.org/api/auth#test-phone-numbers), * which is randomly generated by default. * * > **Note**: Using this method assumes that you * > are using a test DC in `primaryDc` parameter. * * **Available**: 👤 users only * * @param params Additional parameters */ startTest(params?: { /** * Whether to log out if current session is logged in. * * @default false. */ logout?: boolean; /** * Override phone number. Must be a valid Test phone number. * * By default is randomly generated. */ phone?: string; /** * Override user's DC. Must be a valid test DC. */ dcId?: number; }): Promise; /** * Start the client in an interactive and declarative manner, * by providing callbacks for authorization details. * * This method handles both login and sign up, and also handles 2FV * * All parameters are `MaybeDynamic`, meaning you * can either supply `T`, or a function that returns `MaybePromise` * * This method is intended for *interactive* login. * If you are building some kind of headless service, you will most likely * want to use the underlying authorization methods directly. * **Available**: ✅ both users and bots * */ start(params: { /** * String session exported using {@link TelegramClient.exportSession}. * * This simply calls {@link TelegramClient.importSession} before anything else. * * Note that passed session will be ignored in case storage already * contains authorization. */ session?: string | InputStringSessionData; /** * Whether to overwrite existing session. */ sessionForce?: boolean; /** * When passed, [QR login flow](https://core.telegram.org/api/qr-login) * will be used instead of the regular login flow. * * This function will be called whenever the login URL is changed, * and the app is expected to display it as a QR code to the user. */ qrCodeHandler?: (url: string, expires: Date) => void; /** * Phone number of the account. * If account does not exist, it will be created */ phone?: MaybeDynamic; /** * Bot token to use. Ignored if `phone` is supplied. */ botToken?: MaybeDynamic; /** * 2FA password. Ignored if `botToken` is supplied */ password?: MaybeDynamic; /** * Code sent to the phone (either sms, call, flash call or other). * Ignored if `botToken` is supplied, must be present if `phone` is supplied. */ code?: MaybeDynamic; /** * If passed, this function will be called if provided code or 2FA password * was invalid. New code/password will be requested later. * * If provided `code`/`password` is a constant string, providing an * invalid one will interrupt authorization flow. */ invalidCodeCallback?: (type: 'code' | 'password') => MaybePromise; /** * Whether to force code delivery through SMS */ forceSms?: boolean; /** * Custom method that is called when a code is sent. Can be used * to show a GUI alert of some kind. * * This method is called *before* {@link start.params.code}. * * @param code * @default `console.log`. */ codeSentCallback?: (code: SentCode) => MaybePromise; /** Saved future auth tokens, if any */ futureAuthTokens?: Uint8Array[]; /** Additional code settings to pass to the server */ codeSettings?: Omit; /** Abort signal */ abortSignal?: AbortSignal; }): Promise; /** * Check if the given peer/input peer is referring to the current user * **Available**: ✅ both users and bots * */ isSelfPeer(peer: tl.TypeInputPeer | tl.TypePeer | tl.TypeInputUser): boolean; /** * Send an answer to a callback query. * * **Available**: 👤 users only * * @param queryId ID of the callback query, or the query itself * @param params Parameters of the answer */ answerCallbackQuery(queryId: Long | CallbackQuery, params?: { /** * Maximum amount of time in seconds for which * this result can be cached by the client (not server!). * * @default 0 */ cacheTime?: number; /** * Text of the notification (0-200 chars). * * If not set, nothing will be displayed */ text?: string; /** * Whether to show an alert in the middle of the screen * instead of a notification at the top of the screen. * * @default false */ alert?: boolean; /** * URL that the client should open. * * If this was a button containing a game, * you can provide arbitrary link to your game. * Otherwise, you can only use links in the format * `t.me/your_bot?start=...` that open your bot * with a deep-link parameter. */ url?: string; }): Promise; /** * Answer an inline query. * * **Available**: 👤 users only * * @param queryId Inline query ID * @param results Results of the query * @param params Additional parameters */ answerInlineQuery(queryId: tl.Long | InlineQuery, results: InputInlineResult[], params?: { /** * Maximum number of time in seconds that the results of the * query may be cached on the server for. * * @default 300 */ cacheTime?: number; /** * Whether the results should be displayed as a gallery instead * of a vertical list. Only applicable to some media types. * * In some cases changing this may lead to the results not being * displayed by the client. * * Default is derived automatically based on result types */ gallery?: boolean; /** * Whether the results should only be cached on the server * for the user who sent the query. * * @default false */ private?: boolean; /** * Next pagination offset (up to 64 bytes). * * When user has reached the end of the current results, * the client will re-send the inline query with the same text, but * with `offset` set to this value. * * If omitted or empty string is provided, it is assumed that * there are no more results. */ nextOffset?: string; /** * If passed, clients will display a button before any other results, * that when clicked switches the user to a private chat with the bot * and sends the bot `/start ${parameter}`. * * An example from the Bot API docs: * * An inline bot that sends YouTube videos can ask the user to connect * the bot to their YouTube account to adapt search results accordingly. * To do this, it displays a "Connect your YouTube account" button above * the results, or even before showing any. The user presses the button, * switches to a private chat with the bot and, in doing so, passes a start * parameter that instructs the bot to return an oauth link. Once done, the * bot can offer a switch_inline button so that the user can easily return to * the chat where they wanted to use the bot's inline capabilities */ switchPm?: { /** * Text of the button */ text: string; /** * Parameter for `/start` command */ parameter: string; }; /** * If passed, clients will display a button on top of the remaining inline result * list with the specified text, that switches the user to the specified bot web app. */ switchWebview?: { /** * Text of the button */ text: string; /** * URL to open */ url: string; }; }): Promise; /** * Answer a pre-checkout query. * * **Available**: 👤 users only * * @param queryId Pre-checkout query ID */ answerPreCheckoutQuery(queryId: tl.Long | PreCheckoutQuery, params?: { /** If pre-checkout is rejected, error message to show to the user */ error?: string; }): Promise; /** * Delete commands for the current bot and the given scope. * * Does the same as passing `null` to {@link setMyCommands} * * Learn more about scopes in the [Bot API docs](https://core.telegram.org/bots/api#botcommandscope) * **Available**: 👤 users only * */ deleteMyCommands(params?: { /** * Scope of the commands. * * @default `BotScope.default_` (i.e. `botCommandScopeDefault`) */ scope?: tl.TypeBotCommandScope | BotCommands.IntermediateScope; /** * User language applied to the scope. */ langCode?: string; }): Promise; /** * Gets information about a bot the current uzer owns (or the current bot) * **Available**: 👤 users only * */ getBotInfo(params: { /** * When called by a user, a bot the user owns must be specified. * When called by a bot, must be empty */ bot?: InputPeerLike; /** * If passed, will retrieve the bot's description in the given language. * If left empty, will retrieve the fallback description. */ langCode?: string; }): Promise; /** * Fetches the menu button set for the given user. * **Available**: 👤 users only * */ getBotMenuButton(user: InputPeerLike): Promise; /** * Request a callback answer from a bot, * i.e. click an inline button that contains data. * * **Available**: 👤 users only * * @param params */ getCallbackAnswer(params: InputMessageId & { /** Data contained in the button */ data: string | Uint8Array; /** * Timeout for the query in ms. * * @default `10000` (10 sec) */ timeout?: number; /** * Whether to "fire and forget" this request, * in which case the promise will resolve as soon * as the request is sent with an empty response. * * Useful for interacting with bots that don't correctly * answer to callback queries and the request always times out. * * **Note**: any errors will be silently ignored. */ fireAndForget?: boolean; /** * Whether this is a "play game" button */ game?: boolean; /** * If the button requires password entry, your 2FA password. * * Your password is never exposed to the bot, * it is checked by Telegram. */ password?: string; }): Promise; /** * Get high scores of a game * **Available**: 👤 users only * */ getGameHighScores(params: InputMessageId & { /** ID of the user to find high scores for */ userId?: InputPeerLike; }): Promise; /** * Get high scores of a game from an inline message * * **Available**: 👤 users only * * @param messageId ID of the inline message containing the game * @param userId ID of the user to find high scores for */ getInlineGameHighScores(messageId: string | tl.TypeInputBotInlineMessageID, userId?: InputPeerLike): Promise; /** * Get a list of current bot's commands for the given command scope * and user language. If they are not set, empty set is returned. * * Learn more about scopes in the [Bot API docs](https://core.telegram.org/bots/api#botcommandscope) * **Available**: 👤 users only * */ getMyCommands(params?: { /** * Scope of the commands. * * @default `BotScope.default_` (i.e. `botCommandScopeDefault`) */ scope?: tl.TypeBotCommandScope | BotCommands.IntermediateScope; /** * User language applied to the scope. */ langCode?: string; }): Promise; /** * Open a webview. * **Available**: 👤 users only * */ openWebview(params: { /** Information about the webview to open */ webview: InputWebview; /** * Bot whose webview to open */ bot: InputPeerLike; /** * Chat to report to the server as the "currently open chat", * also the chat to which the message will be sent in case of * `from_inline_keyboard`, `from_bot_menu` and `from_attach_menu` webviews */ chat?: InputPeerLike; /** * Theme parameters to pass to the mini app * * Each value should be a string (hex-encoded RGB, no alpha) */ theme?: tl.TypeDataJSON | { /** Background color */ bg_color?: string; /** Secondary background color */ secondary_bg_color?: string; /** Text color */ text_color?: string; /** Hint text color */ hint_color?: string; /** Link color */ link_color?: string; /** Button color */ button_color?: string; /** Button text color */ button_text_color?: string; /** Header background color */ header_bg_color?: string; /** Accent text color */ accent_text_color?: string; /** Section background color */ section_bg_color?: string; /** Section header text color */ section_header_text_color?: string; /** Section separator color */ section_separator_color?: string; /** Sub title text color */ subtitle_text_color?: string; /** Text color for destructive action buttons in prompts */ destructive_text_color?: string; }; /** * Webview platform to use in the init data * * Some of the known values: * - `android` - Android clients * - `ios` - iOS clients * - `tdesktop` - Telegram Desktop * - `macos` - Telegram for macOS * - `unigram` - Unigram */ platform: 'android' | 'ios' | 'tdesktop' | 'macos' | 'unigram' | (string & {}); }): Promise; /** * Close a webview previously opened by {@link openWebview} method. * * **Available**: ✅ both users and bots * * @param webview Webview result returned by {@link openWebview}, or its `.queryId` */ closeWebview(webview: WebviewResult | tl.Long): Promise; /** * Prepare an inline message result to be sent later via the * `shareMessage` [mini-app api method](https://core.telegram.org/bots/webapps#initializing-mini-apps). * **Available**: 👤 users only * */ prepareInlineMessage(params: { userId: InputPeerLike; result: InputInlineResult; /** * Filters for the client to use when prompting the user for the * chat to send the inline message to. * * Note that this is just a hint for the client, and the client is free to ignore it. */ filter?: tl.TypeInlineQueryPeerType[] | { /** private chat with the bot itself */ botSelf?: boolean; /** private chats */ private?: boolean; /** private chats with other bots */ bots?: boolean; /** "basic" chats */ chats?: boolean; /** supergroups */ supergroups?: boolean; /** broadcast channels */ channels?: boolean; }; }): Promise; /** * Sets information about a bot the current uzer owns (or the current bot) * **Available**: 👤 users only * */ setBotInfo(params: { /** * When called by a user, a bot the user owns must be specified. * When called by a bot, must be empty */ bot?: InputPeerLike; /** * If passed, will update the bot's description in the given language. * If left empty, will change the fallback description. */ langCode?: string; /** New bot name */ name?: string; /** New bio text (displayed in the profile) */ bio?: string; /** New description text (displayed when the chat is empty) */ description?: string; }): Promise; /** * Sets a menu button for the given user. * **Available**: 👤 users only * */ setBotMenuButton(user: InputPeerLike, button: tl.TypeBotMenuButton): Promise; /** * Set a score of a user in a game * * **Available**: 👤 users only * * @param params * @returns The modified message */ setGameScore(params: InputMessageId & { /** ID of the user who has scored */ userId: InputPeerLike; /** The new score (must be >0) */ score: number; /** * When `true`, the game message will not be modified * to include the new score */ noEdit?: boolean; /** * Whether to allow user's score to decrease. * This can be useful when fixing mistakes or banning cheaters */ force?: boolean; /** * Whether to dispatch the edit message event * to the client's update handler. */ shouldDispatch?: true; }): Promise; /** * Set a score of a user in a game contained in * an inline message * * **Available**: 👤 users only * * @param params */ setInlineGameScore(params: { /** ID of the inline message */ messageId: string | tl.TypeInputBotInlineMessageID; /** ID of the user who has scored */ userId: InputPeerLike; /** The new score (must be >0) */ score: number; /** * When `true`, the game message will not be modified * to include the new score */ noEdit?: boolean; /** * Whether to allow user's score to decrease. * This can be useful when fixing mistakes or banning cheaters */ force?: boolean; }): Promise; /** * Set or delete commands for the current bot and the given scope * * Learn more about scopes in the [Bot API docs](https://core.telegram.org/bots/api#botcommandscope) * **Available**: 👤 users only * */ setMyCommands(params: { /** * New list of bot commands for the given scope. * * Pass empty array or `null` to delete them. */ commands: tl.RawBotCommand[] | null; /** * Scope of the commands. * * @default `BotScope.default_` (i.e. `botCommandScopeDefault`) */ scope?: tl.TypeBotCommandScope | BotCommands.IntermediateScope; /** * User language applied to the scope. */ langCode?: string; }): Promise; /** * Sets the default chat permissions for the bot in the supergroup or channel. * **Available**: 👤 users only * */ setMyDefaultRights(params: { /** Whether to target groups or channels. */ target: 'channel' | 'group'; /** The default chat permissions. */ rights: Omit; }): Promise; /** * Give or revoke permission for a bot to update emoji status for your account * **Available**: 👤 users only * */ toggleEmojiStatusPermission(params: { /** Bot to which the permission should be granted/revoked */ userId: InputPeerLike; /** Whether to grant or revoke permission */ allow: boolean; }): Promise; /** * Add one or more new members to a group, supergroup or channel. * * **Available**: 👤 users only * * @param chatId ID of the chat or its username * @param users ID(s) of the user(s) to add * @returns List of users that were failed to be invited (may be empty) */ addChatMembers(chatId: InputPeerLike, users: MaybeArray, params: { /** * Number of old messages to be forwarded (0-100). * Only applicable to legacy groups, ignored for supergroups and channels * * @default 100 */ forwardCount?: number; }): Promise; /** * Archive one or more chats * * **Available**: 👤 users only * * @param chats Chat ID(s), username(s), phone number(s), `"me"` or `"self"` */ archiveChats(chats: MaybeArray): Promise; /** * Ban a user/channel from a legacy group, a supergroup or a channel. * They will not be able to re-join the group on their own, * manual administrator's action will be required. * * When banning a channel, the user won't be able to use * any of their channels to post until the ban is lifted. * * **Available**: 👤 users only * * @returns Service message about removed user, if one was generated. */ banChatMember(params: { /** Chat ID */ chatId: InputPeerLike; /** ID of the user/channel to ban */ participantId: InputPeerLike; untilDate?: number | Date; /** * Whether to dispatch the returned service message (if any) * to the client's update handler. */ shouldDispatch?: true; }): Promise; /** * Create a new broadcast channel * * **Available**: 👤 users only * * @returns Newly created channel */ createChannel(params: { /** * Channel title */ title: string; /** * Channel description */ description?: string; }): Promise; /** * Create a legacy group chat * * If you want to create a supergroup, use {@link createSupergroup} * instead. * **Available**: 👤 users only * */ createGroup(params: { /** * Group title */ title: string; /** * User(s) to be invited in the group (ID(s), username(s) or phone number(s)). * Due to Telegram limitations, you can't create a legacy group with just yourself. */ users: MaybeArray; /** * TTL period (in seconds) for the newly created chat * * @default 0 (i.e. messages don't expire) */ ttlPeriod?: number; }): Promise; /** * Create a new supergroup * * **Available**: 👤 users only * * @returns Newly created supergroup */ createSupergroup(params: { /** * Supergroup title */ title: string; /** * Supergroup description */ description?: string; /** * Whether to create a forum */ forum?: boolean; /** * TTL period (in seconds) for the newly created supergroup * * @default 0 (i.e. messages don't expire) */ ttlPeriod?: number; }): Promise; /** * Delete a channel or a supergroup * * **Available**: 👤 users only * * @param chatId Chat ID or username */ deleteChannel(chatId: InputPeerLike): Promise; /** * Delete a channel or a supergroup * * **Available**: 👤 users only * * @param chatId Chat ID or username */ deleteSupergroup(chatId: InputPeerLike): Promise; /** * Delete a chat photo * * You must be an administrator and have the appropriate permissions. * * **Available**: 👤 users only * * @param chatId Chat ID or username */ deleteChatPhoto(chatId: InputPeerLike): Promise; /** * Delete a legacy group chat for all members * * **Available**: 👤 users only * * @param chatId Chat ID */ deleteGroup(chatId: InputPeerLike): Promise; /** * Delete communication history (for private chats and legacy groups) * **Available**: 👤 users only * */ deleteHistory(chat: InputPeerLike, params?: { /** * Deletion mode. Can be: * - `delete`: delete messages (only for yourself) AND the dialog itself * - `clear`: delete messages (only for yourself), but keep the dialog in the list * - `revoke`: delete messages for all users * * @default 'delete' */ mode: 'delete' | 'clear' | 'revoke'; /** * Maximum ID of message to delete. * * @default 0, i.e. remove all messages */ maxId?: number; }): Promise; /** * Delete all messages of a user (or channel) in a supergroup * **Available**: 👤 users only * */ deleteUserHistory(params: { /** Chat ID */ chatId: InputPeerLike; /** User/channel ID whose messages to delete */ participantId: InputPeerLike; /** * Whether to dispatch the updates that will be generated by this call. * Doesn't follow `disableNoDispatch` */ shouldDispatch?: true; }): Promise; /** * Edit supergroup/channel admin rights of a user. * **Available**: 👤 users only * */ editAdminRights(params: { /** Chat ID */ chatId: InputPeerLike; /** User ID */ userId: InputPeerLike; /** New admin rights */ rights: Omit; /** Custom admin rank */ rank?: string; }): Promise; /** * Edit the custom rank (title) of a group chat participant. */ editChatMemberRank(params: { /** Chat ID */ chatId: InputPeerLike; /** ID of the user to edit the rank of */ participantId: InputPeerLike; /** New rank, or `null` to remove it */ rank: string | null; }): Promise; /** * Get chat event log ("Recent actions" in official clients). * * Only available for supergroups and channels, and * requires (any) administrator rights. * * Results are returned in reverse chronological * order (i.e. newest first) and event IDs are * in direct chronological order (i.e. newer * events have bigger event ID) * * **Available**: 👤 users only * * @param params */ getChatEventLog(chatId: InputPeerLike, params?: { /** * Search query */ query?: string; /** * Minimum event ID to return */ minId?: tl.Long; /** * Maximum event ID to return, * can be used as a base offset */ maxId?: tl.Long; /** * List of users whose actions to return */ users?: InputPeerLike[]; /** * Event filters. Can be a TL object, or one or more * action types. * * Note that some filters are grouped in TL * (i.e. `info=true` will return `title_changed`, * `username_changed` and many more), * and when passing one or more action types, * they will be filtered locally. */ filters?: InputChatEventFilters; /** * Limit the number of events returned. * * > Note: when using filters, there will likely be * > less events returned than specified here. * > This limit is only used to limit the number of * > events to fetch from the server. * > * > If you need to limit the number of events * > returned, use {@link iterChatEventLog} instead. * * @default 100 */ limit?: number; }): Promise; /** * Get information about a single chat member * * **Available**: 👤 users only * * @param chatId Chat ID or username * @param userId User ID, username, phone number, `"me"` or `"self"` * @returns Chat member, or `null` if user is not a member of the chat */ getChatMember(params: { /** Chat ID or username */ chatId: InputPeerLike; /** User ID, username, phone number, `"me"` or `"self"` */ userId: InputPeerLike; }): Promise; /** * Get a chunk of members of some chat. * * You can retrieve up to 200 members at once * * **Available**: 👤 users only * * @param chatId Chat ID or username * @param params Additional parameters */ getChatMembers(chatId: InputPeerLike, params?: { /** * Search query to filter members by their display names and usernames * * > **Note**: Only used for these values of `filter`: * > `all, banned, restricted, mention, contacts` * * @default `''` (empty string) */ query?: string; /** * Sequential number of the first member to be returned. */ offset?: number; /** * Maximum number of members to be retrieved. * * > **Note**: Telegram currently only allows you to ever retrieve at most * > 200 members, regardless of offset/limit. I.e. when passing * > `offset=201` nothing will ever be returned. * * @default 200 */ limit?: number; /** * Type of the query. Can be: * - `all`: get all members * - `banned`: get only banned members * - `restricted`: get only restricted members * - `bots`: get only bots * - `recent`: get recent members * - `admins`: get only administrators (and creator) * - `contacts`: get only contacts * - `mention`: get users that can be mentioned (see {@link tl.RawChannelParticipantsMentions}) * * Only used for channels and supergroups. * * @default `recent` */ type?: 'all' | 'banned' | 'restricted' | 'bots' | 'recent' | 'admins' | 'contacts' | 'mention'; }): Promise>; /** * Get preview information about a private chat. * * **Available**: 👤 users only * * @param inviteLink Invite link * @throws MtArgumentError In case invite link has invalid format * @throws MtPeerNotFoundError * In case you are trying to get info about private chat that you have already joined. * Use {@link getChat} or {@link getFullChat} instead. */ getChatPreview(inviteLink: string): Promise; /** * Get basic information about a chat. * * **Available**: ✅ both users and bots * * @param chatId ID of the chat, its username or invite link * @throws MtArgumentError * In case you are trying to get info about private chat that you haven't joined. * Use {@link getChatPreview} instead. */ getChat(chatId: InputPeerLike): Promise; /** * Get basic information about multiple chats. * * **Available**: ✅ both users and bots * * @param chatIds Chat identifiers. Can be ID, username or TL object * @returns The list of chats in the same order as the input */ getChats(chatIds: InputPeerLike[]): Promise<(Chat | null)[]>; /** * Get the user who will be made the creator of the chat/channel/supergroup if you were to leave it. * * You must be the creator of the chat/channel/supergroup to use this method. */ getCreatorAfterLeave(chatId: InputPeerLike): Promise; /** * Get full information about a chat. * * **Available**: ✅ both users and bots * * @param chatId ID of the chat, its username or invite link * @throws MtArgumentError * In case you are trying to get info about private chat that you haven't joined. * Use {@link getChatPreview} instead. */ getFullChat(chatId: InputPeerLike): Promise; /** * Get full information about a user. * * **Available**: ✅ both users and bots * * @param userId ID of the user or their username */ getFullUser(userId: InputPeerLike): Promise; getMessageAuthor(message: InputMessageId): Promise; /** Shorthand for {@link getChat} and {@link getUser} depending on the type of the peer */ getPeer(peer: InputPeerLike): Promise; /** * Get basic information about multiple peers. * * **Available**: ✅ both users and bots * * @param chatIds Chat identifiers. Can be ID, username or TL object * @returns The list of peers in the same order as the input */ getPeers(chatIds: InputPeerLike[]): Promise<(Peer | null)[]>; /** * Get channels that are similar to a given channel * * > **Note**: This method only returns the channels that the current user * > is not subscribed to. For non-premium users, this method will only return * > a few channels (with the total number of similar channels being specified in `.total`) * > * > Returns empty array in case there are no similar channels available. * **Available**: 👤 users only * */ getSimilarChannels(channel: InputPeerLike): Promise>; /** * Get basic information about a user. * * **Available**: ✅ both users and bots * * @param userId ID of the user or their username or invite link */ getUser(userId: InputPeerLike): Promise; /** * Iterate over chat event log. * * Small wrapper over {@link getChatEventLog} * * **Available**: ✅ both users and bots * * @param chatId Chat ID * @param params */ iterChatEventLog(chatId: InputPeerLike, params?: Parameters[2] & { /** * Total number of events to return. * * @default Infinity */ limit?: number; /** * Chunk size, passed as `limit` to {@link getChatEventLog}. * Usually you don't need to touch this. * * @default 100 */ chunkSize?: number; }): AsyncIterableIterator; /** * Iterate through chat members * * This method is a small wrapper over {@link getChatMembers}, * which also handles duplicate entries (i.e. does not yield * the same member twice) * * **Available**: ✅ both users and bots * * @param chatId Chat ID or username * @param params Additional parameters */ iterChatMembers(chatId: InputPeerLike, params?: Parameters[2] & { /** * Chunk size, which will be passed as `limit` parameter * to {@link getChatMembers}. Usually you shouldn't care about this. * * @default `200` */ chunkSize?: number; }): AsyncIterableIterator; /** * Join a channel or supergroup * * When using with invite links, this method may throw RPC error * `INVITE_REQUEST_SENT`, which means that you need to wait for admin approval. * You will get into the chat once they do so. * * **Available**: 👤 users only * * @param chatId * Chat identifier. Either an invite link (`t.me/joinchat/*`), a username (`@username`) * or ID of the linked supergroup or channel. */ joinChat(chatId: InputPeerLike): Promise; /** * Kick a user from a chat. * * This effectively bans a user and immediately unbans them. * * **Available**: ✅ both users and bots * * @returns Service message about removed user, if one was generated. */ kickChatMember(params: { /** Chat ID */ chatId: InputPeerLike; /** User ID */ userId: InputPeerLike; }): Promise; /** * Leave a group chat, supergroup or channel * * **Available**: 👤 users only * * @param chatId Chat ID or username */ leaveChat(chatId: InputPeerLike, params?: { /** * Whether to clear history after leaving (only for legacy group chats) */ clear?: boolean; }): Promise; /** * Mark a chat as unread * * **Available**: 👤 users only * * @param chatId Chat ID */ markChatUnread(chatId: InputPeerLike): Promise; /** * Inform the library that the user has opened a chat. * * Some library logic depends on this, for example, the library will * periodically ping the server to keep the updates flowing. * * > **Warning**: Opening a chat with `openChat` method will make the library make additional requests * > every so often. Which means that you should **avoid opening more than 5-10 chats at once**, * > as it will probably trigger server-side limits and you might start getting transport errors * > or even get banned. * * **Available**: ✅ both users and bots * * @param chat Chat to open */ openChat(chat: InputPeerLike): Promise; /** * Inform the library that the user has closed a chat. * Un-does the effect of {@link openChat}. * * Some library logic depends on this, for example, the library will * periodically ping the server to keep the updates flowing. * * **Available**: ✅ both users and bots * * @param chat Chat to open */ closeChat(chat: InputPeerLike): Promise; /** * Reorder usernames * * **Available**: 👤 users only * * @param peerId Bot, channel or "me"/"self" */ reorderUsernames(peerId: InputPeerLike, order: string[]): Promise; /** * Restrict a user in a supergroup. * **Available**: 👤 users only * */ restrictChatMember(params: { /** Chat ID */ chatId: InputPeerLike; /** User ID */ userId: InputPeerLike; /** * Restrictions for the user. Note that unlike Bot API, this object contains * the restrictions, and not the permissions, i.e. * passing `sendMessages=true` will disallow the user to send messages, * and passing `{}` (empty object) will lift any restrictions */ restrictions: Omit; /** * Date when the user will be unrestricted. * When `number` is passed, UNIX time in ms is expected. * If this value is less than 30 seconds or more than 366 days in * the future, user will be restricted forever. * * @default `0`, i.e. forever */ until?: number | Date; }): Promise; /** * Save or delete a draft message associated with some chat * * **Available**: 👤 users only * * @param chatId ID of the chat, its username, phone or `"me"` or `"self"` * @param draft Draft message, or `null` to delete. */ saveDraft(chatId: InputPeerLike, draft: null | Omit): Promise; /** * Set peer color and optionally background pattern * **Available**: 👤 users only * */ setChatColor(params: { /** * Peer where to update the color. * * By default will change the color for the current user */ peer?: InputPeerLike; /** * Color identificator * * Note that this value is **not** an RGB color representation. Instead, it is * a number which should be used to pick a color from a predefined * list of colors: * - `0-6` are the default colors used by Telegram clients: * `red, orange, purple, green, sea, blue, pink` * - `>= 7` are returned by `help.getAppConfig`. */ color: number; /** * Background pattern emoji ID. * * Must be an adaptive emoji, otherwise the request will fail. */ backgroundEmojiId?: tl.Long; /** * Whether to set this color for the profile * header instead of chat name/replies. */ forProfile?: boolean; }): Promise; /** * Change default chat permissions for all members. * * You must be an administrator in the chat and have appropriate permissions. * * **Available**: 👤 users only * * @param chatId Chat ID or username * @param restrictions * Restrictions for the chat. Note that unlike Bot API, this object contains * the restrictions, and not the permissions, i.e. * passing `sendMessages=true` will disallow the users to send messages, * and passing `{}` (empty object) will lift any restrictions */ setChatDefaultPermissions(chatId: InputPeerLike, restrictions: Omit): Promise; /** * Change chat description * * You must be an administrator and have the appropriate permissions. * * **Available**: 👤 users only * * @param chatId Chat ID or username * @param description New chat description, 0-255 characters */ setChatDescription(chatId: InputPeerLike, description: string): Promise; /** * Set a new chat photo or video. * * You must be an administrator and have the appropriate permissions. * **Available**: 👤 users only * */ setChatPhoto(params: { /** Chat ID or username */ chatId: InputPeerLike; /** Media type (photo or video) */ type: 'photo' | 'video'; /** Input media file */ media: InputFileLike; /** * When `type = video`, timestamp in seconds which will be shown * as a static preview. */ previewSec?: number; }): Promise; /** * Change chat title * * You must be an administrator and have the appropriate permissions. * * **Available**: 👤 users only * * @param chatId Chat ID or username * @param title New chat title, 1-255 characters */ setChatTitle(chatId: InputPeerLike, title: string): Promise; /** * Set maximum Time-To-Live of all newly sent messages in the specified chat * * **Available**: 👤 users only * * @param chatId Chat ID * @param period New TTL period, in seconds (or 0 to disable) */ setChatTtl(chatId: InputPeerLike, period: number): Promise; /** * Change supergroup/channel username * * You must be an administrator and have the appropriate permissions. * * **Available**: 👤 users only * * @param chatId Chat ID or current username * @param username New username, or `null` to remove */ setChatUsername(chatId: InputPeerLike, username: string | null): Promise; /** * Set supergroup's slow mode interval. * * **Available**: 👤 users only * * @param chatId Chat ID or username * @param [seconds=0] * Slow mode interval in seconds. * Users will be able to send a message only once per this interval. * Valid values are: `0 (off), 10, 30, 60 (1m), 300 (5m), 900 (15m) or 3600 (1h)` */ setSlowMode(chatId: InputPeerLike, seconds?: number): Promise; /** * Set whether a chat has content protection (i.e. forwarding messages is disabled) * * **Available**: 👤 users only * * @param chatId Chat ID or username * @param [enabled=false] Whether content protection should be enabled */ toggleContentProtection(chatId: InputPeerLike, enabled?: boolean, params?: { /** If this method was called in response to the other party enabling content protection, ID of that message */ requestMsgId?: number; }): Promise; /** * Toggle a collectible (Fragment) username * * > **Note**: non-collectible usernames must still be changed * > using {@link setUsername}/{@link setChatUsername} * **Available**: 👤 users only * */ toggleFragmentUsername(params: { /** Peer ID whose username to toggle */ peerId: InputPeerLike; /** * Username to toggle */ username: string; /** * Whether to enable or disable the username */ active: boolean; }): Promise; /** * Set whether a channel/supergroup has join requests enabled. * * > **Note**: this method only affects primary invite links. * > Additional invite links may exist with the opposite setting. * * **Available**: 👤 users only * * @param chatId Chat ID or username * @param [enabled=false] Whether join requests should be enabled */ toggleJoinRequests(chatId: InputPeerLike, enabled?: boolean): Promise; /** * Set whether a channel/supergroup has join-to-send setting enabled. * * This only affects discussion groups where users can send messages * without joining the group. * * **Available**: 👤 users only * * @param chatId Chat ID or username * @param [enabled=false] Whether join-to-send setting should be enabled */ toggleJoinToSend(chatId: InputPeerLike, enabled?: boolean): Promise; /** * Transfer ownership of a chat/channel/supergroup to another user. * * You must be the creator of the chat to use this method, * and your account must have 2FA enabled. */ transferChatOwnership(params: { /** ID of the chat/channel/supergroup to transfer */ chatId: InputPeerLike; /** ID of the user to transfer ownership to */ userId: InputPeerLike; /** Your 2FA password */ password: string; }): Promise; /** * Unarchive one or more chats * * **Available**: 👤 users only * * @param chats Chat ID(s), username(s), phone number(s), `"me"` or `"self"` */ unarchiveChats(chats: MaybeArray): Promise; /** * Unban a user/channel from a supergroup or a channel, * or remove any restrictions that they have. * Unbanning does not add the user back to the chat, this * just allows the user to join the chat again, if they want. * * This method acts as a no-op in case a legacy group is passed. * **Available**: 👤 users only * */ unbanChatMember(params: { /** Chat ID */ chatId: InputPeerLike; /** User/channel ID who should be unbanned */ participantId: InputPeerLike; }): Promise; /** * Unban a user/channel from a supergroup or a channel, * or remove any restrictions that they have. * Unbanning does not add the user back to the chat, this * just allows the user to join the chat again, if they want. * * This method acts as a no-op in case a legacy group is passed. * **Available**: 👤 users only * */ unrestrictChatMember(params: { /** Chat ID */ chatId: InputPeerLike; /** User/channel ID who should be unbanned */ participantId: InputPeerLike; }): Promise; /** * Add an existing Telegram user as a contact * **Available**: 👤 users only * */ addContact(params: { /** User ID, username or phone number */ userId: InputPeerLike; /** * First name of the contact */ firstName: string; /** * Last name of the contact */ lastName?: string; /** * Phone number of the contact, if available */ phone?: string; /** * Whether to share your own phone number * with the newly created contact * * @default false */ sharePhone?: boolean; /** * Note to the contact */ note?: InputText; }): Promise; /** * Delete one or more contacts from your Telegram contacts list * * Returns deleted contact's profiles. Does not return * profiles of users that were not in your contacts list * * **Available**: 👤 users only * * @param userIds User IDs, usernames or phone numbers */ deleteContacts(userIds: MaybeArray): Promise; /** * Get list of contacts from your Telegram contacts list. * **Available**: 👤 users only * */ getContacts(): Promise; /** * Import contacts to your Telegram contacts list. * * **Available**: 👤 users only * * @param contacts List of contacts */ importContacts(contacts: PartialOnly, 'clientId'>[]): Promise; /** * Set a note for a contact * * **Available**: 👤 users only * * @param userId ID of the user to set the note for * @param note Note text */ setContactNote(userId: InputPeerLike, note: InputText): Promise; /** * Create a folder from given parameters * * ID for the folder is optional, if not * provided it will be derived automatically. * * **Available**: 👤 users only * * @param folder Parameters for the folder * @returns Newly created folder */ createFolder(folder: PartialExcept): Promise; /** * Delete a folder by its ID * * **Available**: 👤 users only * * @param id Folder ID or folder itself */ deleteFolder(id: number | tl.RawDialogFilter): Promise; /** * Edit a folder with given modification * * **Available**: 👤 users only * * @returns Modified folder */ editFolder(params: { /** * Folder, folder ID or name. * Note that passing an ID or name will require re-fetching all folders, * and passing name might affect not the right folder if you have multiple * with the same name. */ folder: tl.RawDialogFilter | number | string; /** Modification to be applied to this folder */ modification: Partial>; }): Promise; /** * Try to find a dialog (dialogs) with a given peer (peers) by their ID, username or phone number. * * This might be an expensive call, as it will potentially iterate over all * dialogs to find the one with the given peer * * **Available**: 👤 users only * * @throws {MtPeerNotFoundError} If a dialog with any of the given peers was not found */ findDialogs(peers: MaybeArray): Promise; /** * Find a folder by its parameter. * * > **Note**: Searching by title and/or emoji might not be * > accurate since you can set the same title and/or emoji * > to multiple folders. * * **Available**: ✅ both users and bots * * @param params Search parameters. At least one must be set. */ findFolder(params: { /** Folder title */ title?: string; /** Folder emoji */ emoji?: string; /** Folder ID */ id?: number; }): Promise; /** * Get a preview of a chatlist by its invite link * * **Available**: 👤 users only * * @param link Invite link */ getChatlistPreview(link: string): Promise; /** * Get list of folders. * **Available**: 👤 users only * */ getFolders(): Promise; /** * Get dialogs with certain peers. * * **Available**: 👤 users only * * @param peers Peers for which to fetch dialogs. */ getPeerDialogs(peers: MaybeArray): Promise<(Dialog | null)[]>; /** * Iterate over dialogs. * * Note that due to Telegram API limitations, * ordering here can only be anti-chronological * (i.e. newest - first), and draft update date * is not considered when sorting. * * **Available**: 👤 users only * * @param params Fetch parameters */ iterDialogs(params?: { /** * Offset message date used as an anchor for pagination. */ offsetDate?: Date | number; /** * Offset message ID used as an anchor for pagination */ offsetId?: number; /** * Offset peer used as an anchor for pagination */ offsetPeer?: tl.TypeInputPeer; /** * Limits the number of dialogs to be received. * * @default `Infinity`, i.e. all dialogs are fetched */ limit?: number; /** * Chunk size which will be passed to `messages.getDialogs`. * You shouldn't usually care about this. * * @default 100. */ chunkSize?: number; /** * How to handle pinned dialogs? * * Whether to `include` them at the start of the list, * `exclude` them at all, or `only` return pinned dialogs. * * Additionally, for folders you can specify * `keep`, which will return pinned dialogs * ordered by date among other non-pinned dialogs. * * > **Note**: When using `include` mode with folders, * > pinned dialogs will only be fetched if all offset * > parameters are unset. * * @default `include`. */ pinned?: 'include' | 'exclude' | 'only' | 'keep'; /** * How to handle archived chats? * * Whether to `keep` them among other dialogs, * `exclude` them from the list, or `only` * return archived dialogs * * Ignored for folders, since folders * themselves contain information about archived chats. * * > **Note**: when `pinned=only`, `archived=keep` will act as `only` * > because of Telegram API limitations. * * @default `exclude` */ archived?: 'keep' | 'exclude' | 'only'; /** * Folder from which the dialogs will be fetched. * * You can pass folder object, id or title * * Note that passing anything except object will * cause the list of the folders to be fetched, * and passing a title may fetch from * a wrong folder if you have multiple with the same title. * * Also note that fetching dialogs in a folder is * orders of magnitudes* slower than normal because * of Telegram API limitations - we have to fetch all dialogs * and filter the ones we need manually. If possible, * use {@link Dialog.filterFolder} instead. * * When a folder with given ID or title is not found, * {@link MtArgumentError} is thrown * * @default (fetches from "All" folder) */ folder?: InputDialogFolder; /** * Additional filtering for the dialogs. * * If `folder` is not provided, this filter is used instead. * If `folder` is provided, fields from this object are used * to override filters inside the folder. */ filter?: Partial>; }): AsyncIterableIterator; /** * Join a chatlist by its link * * **Available**: 👤 users only * * @param link Invite link to the chatlist * @param params Additional parameters * @returns Folder representing the chatlist */ joinChatlist(link: string, params?: { /** Chats to join from the chatlist (all by default) */ peers?: MaybeArray; }): Promise; /** * Reorder folders * * **Available**: 👤 users only * * @param order New order of folders (folder IDs, where default = 0) */ setFoldersOrder(order: number[]): Promise; /** * Download a file and return its contents as a Buffer. * * > **Note**: This method _will_ download the entire file * > into memory at once. This might cause an issue, so use wisely! * * **Available**: ✅ both users and bots * * @param params File download parameters */ downloadAsBuffer(location: FileDownloadLocation, params?: FileDownloadParameters): Promise; /** * Download a single chunk of a file, using [`precise`](https://core.telegram.org/api/files#downloading-files) download mode * * **Available**: 👤 users only * * @param params Download parameters */ downloadChunk(params: { /** File from which to download a chunk */ location: FileDownloadLocation; /** * DC id from which the file will be downloaded. * * If provided DC is not the one storing the file, * redirection will be handled automatically. */ dcId?: number; /** Offset of the chunk in bytes */ offset: number; /** * Number of bytes to download (starting from the offset) * * Max 1MB (1048576) */ limit: number; maxRetryCount?: number; floodSleepThreshold?: number; abortSignal?: AbortSignal; }): Promise; /** * Download a remote file to a local file (only for Node.js). * Promise will resolve once the download is complete. * * **Available**: ✅ both users and bots * * @param filename Local file name to which the remote file will be downloaded * @param params File download parameters */ downloadToFile(filename: string, location: FileDownloadLocation, params?: FileDownloadParameters): Promise; _normalizeFileDownloadLocation(input: FileDownloadLocation): Promise<{ location: tl.TypeInputFileLocation | tl.TypeInputWebFileLocation | Uint8Array; dcId?: number; fileSize?: number; }>; /** * Download a file and return it as an iterable, which yields file contents * in chunks of a given size. Order of the chunks is guaranteed to be * consecutive. * * **Available**: 👤 users only * * @param params Download parameters */ downloadAsIterable(input: FileDownloadLocation, params?: FileDownloadParameters & { /** * A function to apply backpressure to the download. * * If the consumer isn't keeping up, the function is supposed to return a promise that resolves when the consumer is ready to receive more data. * * Note that this function will likely get called multiple times simultaneously, since the download is parallelized. */ throttle?: (chunkSize: number) => MaybePromise; }): AsyncIterableIterator; /** * Download a remote file as a Node.js Readable stream. * * **Available**: ✅ both users and bots * * @param params File download parameters */ downloadAsNodeStream(location: FileDownloadLocation, params?: FileDownloadParameters): import('node:stream').Readable; /** * Download a file and return it as a Web Stream, * streaming file contents. * * **Available**: ✅ both users and bots * * @param params File download parameters */ downloadAsStream(location: FileDownloadLocation, params?: FileDownloadParameters & { /** * If passed, the maximum number of bytes that can be buffered in the stream. * * If the consumer isn't keeping up, the stream will pause until the buffer is below this limit. * * Note that this parameter is not guaranteed to be strictly the maximum number of bytes * buffered at once, since the underlying download is parallelized, and is treated merely as a hint. * The actual number of bytes buffered at once can be as much as `partSize * numWorkers` */ highWaterMark?: number; }): ReadableStream; /** * Normalize a {@link InputFileLike} to `InputFile`, * uploading it if needed. * **Available**: ✅ both users and bots * */ _normalizeInputFile(input: InputFileLike, params: { progressCallback?: (uploaded: number, total: number) => void; abortSignal?: AbortSignal; fileName?: string; fileSize?: number; fileMime?: string; }): Promise; /** * Normalize an {@link InputMediaLike} to `InputMedia`, * uploading the file if needed. * **Available**: 👤 users only * */ _normalizeInputMedia(media: InputMediaLike, params?: { progressCallback?: (uploaded: number, total: number) => void; uploadPeer?: tl.TypeInputPeer; abortSignal?: AbortSignal; businessConnectionId?: string; }, uploadMedia?: boolean): Promise; /** * Upload a file to Telegram servers, without actually * sending a message anywhere. Useful when an `InputFile` is required. * * This method is quite low-level, and you should use other * methods like {@link sendMedia} that handle this under the hood. * * **Available**: ✅ both users and bots * * @param params Upload parameters */ uploadFile(params: { /** * Upload file source. */ file: UploadFileLike; /** * File name for the uploaded file. Is usually inferred from path, * but should be provided for files sent as `Buffer` or stream. * * When file name can't be inferred, it falls back to "unnamed" */ fileName?: string; /** * Total file size. Automatically inferred for Buffer, File and local files. */ fileSize?: number; /** * If the file size is unknown, you can provide an estimate, * which will be used to determine appropriate part size. */ estimatedSize?: number; /** * File MIME type. By default is automatically inferred from magic number * If MIME can't be inferred, it defaults to `application/octet-stream` */ fileMime?: string; /** * Upload part size (in KB). * * By default, automatically selected by file size. * Must not be bigger than 512 and must not be a fraction. */ partSize?: number; /** * Number of parts to be sent in parallel per connection. */ requestsPerConnection?: number; /** * Function that will be called after some part has been uploaded. * * @param uploaded Number of bytes already uploaded * @param total Total file size, if known */ progressCallback?: (uploaded: number, total: number) => void; /** * When using `inputMediaUploadedPhoto` (e.g. when sending an uploaded photo) require * the file size to be known beforehand. * * In case this is set to `true`, a stream is passed as `file` and the file size is unknown, * the stream will be buffered in memory and the file size will be inferred from the buffer. */ requireFileSize?: boolean; /** * When using `inputMediaUploadedPhoto` (e.g. when sending an uploaded photo) require * the file extension to be known beforehand. * * This will make the library try to guess the file extension from the file mime type, * or throw an error if it cannot be guessed. */ requireExtension?: boolean; abortSignal?: AbortSignal; }): Promise; /** * Upload a media to Telegram servers, without actually * sending a message anywhere. Useful when File ID is needed. * * The difference with {@link uploadFile} is that * the returned object will act like a message media * and contain fields like File ID. * * **Available**: 👤 users only * * @param media Media to upload * @param [params={}] Upload parameters */ uploadMedia(media: InputMediaLike, params?: { peer?: InputPeerLike; progressCallback?: (uploaded: number, total: number) => void; }): Promise>; /** * Create a topic in a forum * * Only admins with `manageTopics` permission can do this. * * **Available**: 👤 users only * * @returns Service message for the created topic */ createForumTopic(params: { /** Chat ID or username */ chatId: InputPeerLike; /** * Topic title */ title: string; /** * Icon of the topic. * * Can be a number (color in RGB, see {@link ForumTopic} static members for allowed values) * or a custom emoji ID. * * Icon color can't be changed after the topic is created. */ icon?: number | tl.Long; /** * Send as a specific channel */ sendAs?: InputPeerLike; /** * Whether to dispatch the returned service message (if any) * to the client's update handler. */ shouldDispatch?: true; }): Promise; /** * Delete a forum topic and all its history * * **Available**: 👤 users only * * @param chat Chat or user ID, username, phone number, `"me"` or `"self"` * @param topicId ID of the topic (i.e. its top message ID) */ deleteForumTopicHistory(chat: InputPeerLike, topicId: number | ForumTopic, params?: { /** * Whether to dispatch updates that will be generated by this call. * Doesn't follow `disableNoDispatch` */ shouldDispatch?: true; }): Promise; /** * Modify a topic in a forum * * Only admins with `manageTopics` permission can do this. * * **Available**: 👤 users only * * @param chatId Chat ID or username * @param topicId ID of the topic (i.e. its top message ID) * @returns Service message about the modification */ editForumTopic(params: { /** Chat ID or username */ chatId: InputPeerLike; /** ID of the topic (i.e. its top message ID) */ topicId: number | ForumTopic; /** * New topic title */ title?: string; /** * New icon of the topic. * * Can be a custom emoji ID, or `null` to remove the icon * and use static color instead */ icon?: tl.Long | null; /** * Whether to dispatch the returned service message (if any) * to the client's update handler. */ shouldDispatch?: true; /** Whether to (un)close the topic */ closed?: boolean; /** Whether to (un)hide the topic */ hidden?: boolean; }): Promise; /** * Get forum topics by their IDs * * **Available**: 👤 users only * * @param chatId Chat ID or username */ getForumTopicsById(chatId: InputPeerLike, ids: MaybeArray): Promise; /** * Get forum topics * * **Available**: 👤 users only * * @param chatId Chat ID or username */ getForumTopics(chatId: InputPeerLike, params?: { /** * Search query */ query?: string; /** * Offset for pagination */ offset?: GetForumTopicsOffset; /** * Maximum number of topics to return. * * @default 100 */ limit?: number; }): Promise>; /** * Iterate over forum topics. Wrapper over {@link getForumTopics}. * * **Available**: ✅ both users and bots * * @param chatId Chat ID or username */ iterForumTopics(chatId: InputPeerLike, params?: Parameters[2] & { /** * Maximum number of topics to return. * * @default `Infinity`, i.e. return all topics */ limit?: number; /** * Chunk size. Usually you shouldn't care about this. */ chunkSize?: number; }): AsyncIterableIterator; /** * Reorder pinned forum topics * * Only admins with `manageTopics` permission can do this. * **Available**: 👤 users only * */ reorderPinnedForumTopics(params: { /** Chat ID or username */ chatId: InputPeerLike; /** * Order of the pinned topics */ order: (number | ForumTopic)[]; /** * Whether to un-pin topics not present in the order */ force?: boolean; }): Promise; /** * Toggle open/close status of a topic in a forum * * Only admins with `manageTopics` permission can do this. * * **Available**: 👤 users only * * @returns Service message about the modification */ toggleForumTopicClosed(parmas: { /** Chat ID or username */ chatId: InputPeerLike; /** ID of the topic (i.e. its top message ID) */ topicId: number | ForumTopic; /** Whether the topic should be closed */ closed: boolean; /** * Whether to dispatch the returned service message (if any) * to the client's update handler. */ shouldDispatch?: true; }): Promise; /** * Toggle whether a topic in a forum is pinned * * Only admins with `manageTopics` permission can do this. * **Available**: 👤 users only * */ toggleForumTopicPinned(params: { /** Chat ID or username */ chatId: InputPeerLike; /** ID of the topic (i.e. its top message ID) */ topicId: number | ForumTopic; /** Whether the topic should be pinned */ pinned: boolean; }): Promise; /** * Update forum settings of a supergroup. * * Only owner of the supergroup can change this setting. * * **Available**: 👤 users only * * @param chatId Chat ID or username * @param settings New settings. `null` is a shorthand for `{ isForum: false }` */ updateForumSettings(chatId: InputPeerLike, settings: null | { /** Whether the supergroup should be a forum */ isForum: boolean; threadsMode: 'list' | 'tabs'; }): Promise; /** * Toggle whether "General" topic in a forum is hidden or not * * Only admins with `manageTopics` permission can do this. * * **Available**: 👤 users only * * @returns Service message about the modification */ toggleGeneralTopicHidden(params: { /** Chat ID or username */ chatId: InputPeerLike; /** Whether the topic should be hidden */ hidden: boolean; /** * Whether to dispatch the returned service message (if any) * to the client's update handler. */ shouldDispatch?: true; }): Promise; _normalizeInputStarGift(gift: InputStarGift): Promise; /** * Accept, hide or convert a star gift. * * **Available**: 👤 users only * * @returns Whether the action was successful */ acceptStarGift(params: { /** Input star gift to accept */ gift: InputStarGift; /** * Action to perform on the gift. * - `save` - save the gift to your profile * - `hide` - hide the gift from your profile * - `convert` - convert the gift to stars (can't be undone) */ action: 'save' | 'hide' | 'convert'; }): Promise; buyResaleGift(params: { /** Slug of the star gift to buy */ slug: string; /** ID of the user to buy the gift for */ recipient: InputPeerLike; /** * Whether to dispatch the new message event * to the client's update handler. */ shouldDispatch?: true; /** Whether to use TON currency for payment */ ton?: boolean; }): Promise; /** * Get a list of star gifts up for resale * **Available**: 👤 users only * */ getStarGiftResaleOptions(params: { /** ID of the gift to get resale options for */ giftId: tl.Long; /** * Sorting attribute * * - `price`: Sort by price * - `num`: Sort by its unique number */ sort?: 'price' | 'num'; /** Whether to filter for options that can be used in a craft */ forCraft?: boolean; /** * Hash of the `attributes` field, as returned by the server in the first response */ attributesHash?: Long; /** Attributes to filter for */ attributes?: tl.TypeStarGiftAttributeId[] | InputStarGiftAttributeIds; /** Offset for pagination */ offset?: string; /** Limit for pagination */ limit?: number; }): Promise>; /** Get one or more saved star gifts by their IDs */ getSavedStarGiftsById(gifts: MaybeArray): Promise; /** * Get a list of saved star gifts of a user/channel * * Note that filters currently only work for channels * **Available**: 👤 users only * */ getSavedStarGifts(params: { /** Peer to get saved gifts from */ owner: InputPeerLike; /** Whether to exclude hidden gifts */ excludeHidden?: boolean; /** Whether to exclude publicly visible gifts */ excludePublic?: boolean; /** Whether to exclude gifts with unlimited availability */ excludeUnlimited?: boolean; /** Whether to exclude unique gifts */ excludeUnique?: boolean; /** Whether to exclude gifts that cannot be upgraded (either not limited or already upgraded) */ excludeUnupgradable?: boolean; /** Whether to exclude gifts that can be upgraded */ excludeUpgradable?: boolean; /** Whether to exclude "hosted" gifts (i.e. those that are actually stored on the TON blockchain) */ excludeHosted?: boolean; /** Whether to only return gifts with peer color available */ peerColorAvailable?: boolean; /** ID of the collection to get gifts from */ collectionId?: number; /** Whether to sort by value */ sortByValue?: boolean; /** Offset for pagination */ offset?: string; /** Limit for pagination */ limit?: number; }): Promise>; /** * Get the list of available star gifts. * **Available**: 👤 users only * */ getStarGiftOptions(): Promise; /** * Get a list of all possible attributes when upgrading a given star gift * **Available**: 👤 users only * */ getStarGiftUpgradeOptions(giftId: tl.Long): Promise; /** * Get the value of a unique star gift * **Available**: 👤 users only * */ getStarGiftValue(params: { /** Slug of the star gift */ slug: string; }): Promise; getStarGiftWithdrawalUrl(params: { /** The star gift to withdraw */ gift: InputStarGift; /** 2FA password */ password: string; }): Promise; /** * Get information about a unique star gift by its slug * **Available**: 👤 users only * */ getUniqueStarGift(slug: string): Promise; /** * Iterate over saved star gifts of a user, * wrapper over {@link getSavedStarGifts} * **Available**: 👤 users only * */ iterSavedStarGifts(params: Parameters[1] & { /** * Number of gifts to fetch per request * * @default 100 */ chunkSize?: number; /** * Total number of gifts to fetch * * @default Infinity */ limit?: number; }): AsyncIterableIterator; /** * Toggles whether one or more star gift is pinned to the top of the list * **Available**: 👤 users only * */ togglePinnedStarGifts(params: { /** One or more gifts to pin */ gifts: MaybeArray; /** Peer where the gift is sent */ peer: InputPeerLike; }): Promise; /** * Pay for other user's star gift upgrade. * * > **Note**: this method is not indended to be used by full-fledged clients, * > as this method hides the actual invoice and payment form from the user. * > For GUI clients, you should refer to the method's source code and * > present the payment form to the user. * * **Available**: 👤 users only * * @returns Service message about the payment for the upgrade, if one was generated. */ prepayStarGiftUpgrade(params: { peer: InputPeerLike; /** Prepaid upgrade hash, taken from `SavedStarGift.prepaidUpgradeHash` */ hash: string; /** * Whether to dispatch the new message event * to the client's update handler. */ shouldDispatch?: true; }): Promise; /** * Accept or decline a purchase offer for a star gift * * **Available**: 👤 users only * * @returns The generated service message */ resolveStarGiftOffer(options: { /** ID of the message containing the offer */ message: number; /** Whether to accept or decline the offer */ action: 'accept' | 'decline'; /** * Whether to dispatch the new message event * to the client's update handler. */ shouldDispatch?: true; }): Promise; /** * Create a purchase offer for a unique star gift * **Available**: 👤 users only * * @param client * @param params */ sendStarGiftOffer(params: { /** ID of the peer to send the offer to */ peerId: InputPeerLike; /** Slug of the star gift to create an offer for */ slug: string; /** Amount of stars to offer */ price: InputStarsAmount; /** Duration of the offer in seconds */ duration: number; /** When the recipient has paid messages enabled, the maximum number of stars that you are willing to spend */ allowPaidMessages?: tl.Long; /** * Whether to dispatch the new message event * to the client's update handler. */ shouldDispatch?: true; }): Promise; /** * Send a star gift to a user. * * > **Note**: this method is not indended to be used by full-fledged clients, * > as this method hides the actual invoice and payment form from the user. * > For GUI clients, you should refer to the method's source code and * > present the payment form to the user. * * **Available**: 👤 users only * * @returns Service message about the sent gift, if one was generated. */ sendStarGift(params: { /** ID of the peer to send the gift to */ peerId: InputPeerLike; /** ID of the gift to send */ gift: Long | StarGift; /** * Whether to send the gift anonymously * (i.e. if the recipient chooses to display the gift * on their profile, your name won't be visible) */ anonymous?: boolean; /** Message to send along with the gift */ message?: InputText; /** Whether to automatically upgrade the gift to a unique star gift */ withUpgrade?: boolean; /** * Whether to dispatch the new message event * to the client's update handler. */ shouldDispatch?: true; }): Promise; /** Set resale price for an owned star gift */ setResaleStarGiftPrice(params: { /** Star gift to update the price of */ gift: InputStarGift; /** * New price of the gift (in stars), or `null` to unlist */ price: InputStarsAmount | null; }): Promise; /** * Transfer a unique star gift. * * > **Note**: this method is not indended to be used by full-fledged clients, * > as this method hides the actual invoice and payment form from the user. * > For GUI clients, you should refer to the method's source code and * > present the payment form to the user. * * **Available**: 👤 users only * * @returns Service message about the transferred gift, if one was generated. */ transferStarGift(params: { /** Star gift to transfer */ gift: InputStarGift; /** ID of the user to transfer the gift to */ recipient: InputPeerLike; /** * Whether to dispatch the new message event * to the client's update handler. */ shouldDispatch?: true; }): Promise; /** * Upgrades a star gift to a unique gift. * * > **Note**: this method is not indended to be used by full-fledged clients, * > as this method hides the actual invoice and payment form from the user. * > For GUI clients, you should refer to the method's source code and * > present the payment form to the user. * * **Available**: 👤 users only * * @returns Service message about the upgraded gift, if one was generated. */ upgradeStarGift(params: { gift: InputStarGift; /** * Whether to retain the original details of the gift * (like sender, recipient, date, message) */ keepOriginalDetails?: boolean; /** * Whether to dispatch the new message event * to the client's update handler. */ shouldDispatch?: true; }): Promise; /** * Create an additional invite link for the chat. * * You must be an administrator and have appropriate rights. * * **Available**: 👤 users only * * @param chatId Chat ID * @param params */ createInviteLink(chatId: InputPeerLike, params?: { /** * Date when this link will expire. * If `number` is passed, UNIX time in ms is expected. */ expires?: number | Date; /** * Maximum number of users that can be members of this chat * at the same time after joining using this link. * * Integer in range `[1, 99999]` or `Infinity` * * @default `Infinity` */ usageLimit?: number; /** * Whether users to be joined via this link need to be * approved by an admin */ withApproval?: boolean; /** * When a pricing plan is passed, this link will become a paid subscription link * * Currently the only allowed `.period` is 1 month, i.e. `2592000` */ subscriptionPricing?: tl.TypeStarsSubscriptionPricing; }): Promise; /** * Edit an invite link. You can only edit non-primary * invite links. * * Only pass the fields that you want to modify. * * **Available**: 👤 users only * * @param chatId Chat ID * @param link Invite link to edit * @param params * @returns Modified invite link */ editInviteLink(params: { /** Chat ID */ chatId: InputPeerLike; /** Invite link to edit */ link: string | ChatInviteLink; /** * Date when this link will expire. * If `number` is passed, UNIX time in ms is expected. */ expires?: number | Date; /** * Maximum number of users that can be members of this chat * at the same time after joining using this link. * * Integer in range `[1, 99999]` or `Infinity`, */ usageLimit?: number; /** * Whether users to be joined via this link need to be * approved by an admin */ withApproval?: boolean; }): Promise; /** * Generate a new primary invite link for a chat, * old primary link is revoked. * * > **Note**: each administrator has their own primary invite link, * > and bots by default don't have one. * * **Available**: 👤 users only * * @param chatId Chat IDs */ exportInviteLink(chatId: InputPeerLike): Promise; /** * Iterate over users who have joined * the chat with the given invite link. * * **Available**: 👤 users only * * @param chatId Chat ID * @param params Additional params */ getInviteLinkMembers(chatId: InputPeerLike, params?: { /** * Invite link for which to get members */ link?: string | ChatInviteLink; /** * Maximum number of users to return * * @default 100 */ limit?: number; /** * Offset request/join date used as an anchor for pagination. */ offsetDate?: Date | number; /** * Offset user used as an anchor for pagination */ offsetUser?: tl.TypeInputUser; /** * Whether to get users who have requested to join * the chat but weren't accepted yet */ requested?: boolean; /** * Search for a user in the pending join requests list * (if passed, {@link requested} is assumed to be true) * * Doesn't work when {@link link} is set (Telegram limitation) */ requestedSearch?: string; }): Promise>; /** * Get detailed information about an invite link * * **Available**: 👤 users only * * @param chatId Chat ID * @param link The invite link */ getInviteLink(chatId: InputPeerLike, link: string): Promise; /** * Get invite links created by some administrator in the chat. * * As an administrator you can only get your own links * (i.e. `adminId = "self"`), as a creator you can get * any other admin's links. * * **Available**: 👤 users only * * @param chatId Chat ID * @param adminId Admin who created the links * @param params */ getInviteLinks(chatId: InputPeerLike, params?: { /** * Only return this admin's links. * * @default `"self"` */ admin?: InputPeerLike; /** * Whether to fetch revoked invite links */ revoked?: boolean; /** * Limit the number of invite links to be fetched. * * @default 100 */ limit?: number; /** * Offset for pagination. */ offset?: GetInviteLinksOffset; }): Promise>; /** * Get primary invite link of a chat * * **Available**: 👤 users only * * @param chatId Chat ID */ getPrimaryInviteLink(chatId: InputPeerLike): Promise; /** * Approve or decline multiple join requests to a chat. * **Available**: 👤 users only * */ hideAllJoinRequests(params: { /** Chat/channel ID */ chatId: InputPeerLike; /** Whether to approve or decline the join requests */ action: 'approve' | 'decline'; /** Invite link to target */ link?: string | ChatInviteLink; }): Promise; /** * Approve or decline join request to a chat. * **Available**: 👤 users only * */ hideJoinRequest(params: { /** Chat/channel ID */ chatId: InputPeerLike; /** User ID */ user: InputPeerLike; /** Whether to approve or decline the join request */ action: 'approve' | 'decline'; }): Promise; /** * Iterate over users who have joined * the chat with the given invite link. * * **Available**: ✅ both users and bots * * @param chatId Chat ID * @param params Additional params */ iterInviteLinkMembers(chatId: InputPeerLike, params?: Parameters[2] & { /** * Maximum number of users to return * * @default `Infinity`, i.e. all users are fetched */ limit?: number; /** * Chunk size which will be passed to `messages.getChatInviteImporters`. * You shouldn't usually care about this. * * @default 100. */ chunkSize?: number; }): AsyncIterableIterator; /** * Iterate over invite links created by some administrator in the chat. * * As an administrator you can only get your own links * (i.e. `adminId = "self"`), as a creator you can get * any other admin's links. * * **Available**: ✅ both users and bots * * @param chatId Chat ID * @param adminId Admin who created the links * @param params */ iterInviteLinks(chatId: InputPeerLike, params?: Parameters[2] & { /** * Limit the number of invite links to be fetched. * By default, all links are fetched. */ limit?: number; /** * Size of chunks which are fetched. Usually not needed. * * @default `100` */ chunkSize?: number; }): AsyncIterableIterator; /** * Revoke an invite link. * * If `link` is a primary invite link, a new invite link will be * generated automatically by Telegram * * **Available**: 👤 users only * * @param chatId Chat ID * @param link Invite link to revoke * @returns If `link` is a primary invite, newly generated invite link, otherwise the revoked link */ revokeInviteLink(chatId: InputPeerLike, link: string | ChatInviteLink): Promise; /** * Append item(s) to a todo list * * **Available**: 👤 users only * * @returns Service message about the appended todo item(s), if any. */ appendTodoList(params: InputMessageId & { /** Items to append */ items: MaybeArray; /** * Whether to dispatch the new message event * to the client's update handler. */ shouldDispatch?: true; }): Promise; /** * Close a poll sent by you. * * Once closed, poll can't be re-opened, and nobody * will be able to vote in it * **Available**: 👤 users only * */ closePoll(params: InputMessageId & { /** * Whether to dispatch the edit message event * to the client's update handler. */ shouldDispatch?: true; }): Promise; /** * Create a streaming text message draft * * **Available**: 👤 users only * * @param chatId Chat ID * @param params */ createStreamingDraft(chatId: InputPeerLike, params?: { /** * Unique identifier of the business connection on behalf of which the action will be sent */ businessConnectionId?: string; /** * For comment threads, ID of the thread (i.e. top message) */ threadId?: number; /** * Mode of the draft's `send` method * * - `append` - appends the text to the previous draft * - `replace` - replaces the previous draft with the new one */ mode?: 'append' | 'replace'; }): Promise; /** * Delete messages by their IDs * * **Available**: 👤 users only * * @param chatId Chat's marked ID, its username, phone or `"me"` or `"self"`. * @param ids Message(s) ID(s) to delete. */ deleteMessagesById(chatId: InputPeerLike, ids: number[], params?: DeleteMessagesParams): Promise; /** * Delete one or more {@link Message} * * **Available**: ✅ both users and bots * * @param messages Message(s) to delete */ deleteMessages(messages: Message[], params?: DeleteMessagesParams): Promise; /** * Delete scheduled messages by their IDs. * * **Available**: 👤 users only * * @param chatId Chat's marked ID, its username, phone or `"me"` or `"self"`. * @param ids Message(s) ID(s) to delete. */ deleteScheduledMessages(chatId: InputPeerLike, ids: number[]): Promise; /** * Edit sent inline message text, media and reply markup. * * **Available**: 👤 users only * * @param messageId * Inline message ID, either as a TL object, or as a * TDLib and Bot API compatible string * @param params */ editInlineMessage(params: { /** * Inline message ID, either as a TL object, or as a * TDLib and Bot API compatible string */ messageId: tl.TypeInputBotInlineMessageID | string; /** * New message text * * When `media` is passed, `media.caption` is used instead */ text?: InputText; /** * New message media */ media?: InputMediaLike; /** * Whether to disable links preview in this message */ disableWebPreview?: boolean; /** * Whether to invert media position. * * Currently only supported for web previews and makes the * client render the preview above the caption and not below. */ invertMedia?: boolean; /** * For bots: new reply markup. * If omitted, existing markup will be removed. */ replyMarkup?: ReplyMarkup; /** * For media, upload progress callback. * * @param uploaded Number of bytes uploaded * @param total Total file size in bytes */ progressCallback?: (uploaded: number, total: number) => void; }): Promise; /** * Edit message text, media, reply markup and schedule date. * * **Available**: 👤 users only * * @param chatId ID of the chat, its username, phone or `"me"` or `"self"` * @param message Message or its ID * @param params */ editMessage(params: InputMessageId & { /** * New message text * * When `media` is passed, `media.caption` is used instead */ text?: InputText; /** * New message media */ media?: InputMediaLike; /** * Whether to disable links preview in this message */ disableWebPreview?: boolean; /** * For bots: new reply markup. * If omitted, existing markup will be removed. */ replyMarkup?: ReplyMarkup; /** * To re-schedule a message: new schedule date. * When passing a number, a UNIX time in ms is expected. */ scheduleDate?: Date | number; /** * For media, upload progress callback. * * @param uploaded Number of bytes uploaded * @param total Total file size in bytes */ progressCallback?: (uploaded: number, total: number) => void; /** * Whether to dispatch the edit message event * to the client's update handler. */ shouldDispatch?: true; /** * Whether to invert media position. * * Currently only supported for web previews and makes the * client render the preview above the caption and not below. */ invertMedia?: boolean; businessConnectionId?: string; }): Promise; /** * Forward one or more messages by their IDs. * You can forward no more than 100 messages at once. * * **Available**: 👤 users only * * @param toChatId Destination chat ID, username, phone, `"me"` or `"self"` * @param fromChatId Source chat ID, username, phone, `"me"` or `"self"` * @param messages Message IDs * @param params Additional sending parameters * @returns Newly sent, forwarded messages in the destination chat. */ forwardMessagesById(params: ForwardMessageOptions & { /** Source chat ID, username, phone, `"me"` or `"self"` */ fromChatId: InputPeerLike; /** Message IDs to forward */ messages: number[]; }): Promise; /** * Forward one or more {@link Message}s to another chat. * * > **Note**: all messages must be from the same chat. * **Available**: ✅ both users and bots * */ forwardMessages(params: ForwardMessageOptions & { messages: Message[]; }): Promise; /** * Get all scheduled messages in chat * * **Available**: 👤 users only * * @param chatId Chat's marked ID, its username, phone or `"me"` or `"self"` */ getAllScheduledMessages(chatId: InputPeerLike): Promise; /** * Get a list of available message effects * **Available**: 👤 users only * */ getAvailableMessageEffects(): Promise; /** * Get the message containing the button being clicked * in the given callback query. * **Available**: 🤖 bots only * */ getCallbackQueryMessage(id: CallbackQuery | tl.RawUpdateBotCallbackQuery | { messageId: number; queryId: tl.Long; peer: InputPeerLike; }): Promise; /** * Get discussion message for some channel post. * * Returns `null` if the post does not have a discussion * message. * * This method might throw `FLOOD_WAIT_X` error in case * the discussion message was not *yet* created. Error * is usually handled by the client, but if you disabled that, * you'll need to handle it manually. * * **Available**: 👤 users only * * @param peer Channel where the post was found * @param message ID of the channel post */ getDiscussionMessage(params: InputMessageId): Promise; /** * Get fact check information for one or more messages in a chat * * **Available**: 👤 users only * * @param chatId Chat where the messages are located * @param msgIds One or more message IDs */ getFactCheck(chatId: InputPeerLike, msgIds: MaybeArray): Promise<(FactCheck | null)[]>; /** * Get chat history. * * **Available**: 👤 users only * * @param chatId Chat's marked ID, its username, phone or `"me"` or `"self"`. * @param params Additional fetch parameters */ getHistory(chatId: InputPeerLike, params?: { /** * Limits the number of messages to be retrieved. * * @default 100 */ limit?: number; /** * Offset for pagination */ offset?: GetHistoryOffset; /** * Additional offset from {@link offset}, in resulting messages. * * This can be used for advanced use cases, like: * - Loading 20 messages newer than message with ID `MSGID`: * `offset = MSGID, addOffset = -20, limit = 20` * - Loading 20 messages around message with ID `MSGID`: * `offset = MSGID, addOffset = -10, limit = 20` * * @default `0` (disabled) */ addOffset?: number; /** * Minimum message ID to return * * @default `0` (disabled). */ minId?: number; /** * Maximum message ID to return. * * @default `0` (disabled). */ maxId?: number; /** * Whether to retrieve messages in reversed order (from older to recent), * starting from {@link offset} (inclusive). * * > **Note**: Using `reverse=true` requires you to pass offset from which to start * > fetching the messages "downwards". If you call `getHistory` with `reverse=true` * > and without any offset, it will return an empty array. * * @default false */ reverse?: boolean; }): Promise>; /** * Given a message link (e.g. `t.me/durov/1`), fetch the relevant message. * **Available**: ✅ both users and bots * */ getMessageByLink(link: string): Promise; /** * Get all messages inside of a message group * * **Available**: ✅ both users and bots * * @param chatId Chat ID * @param message ID of one of the messages in the group */ getMessageGroup(params: InputMessageId): Promise; /** * Get reactions to messages by their IDs. * * > Apps should short-poll reactions for visible messages * > (that weren't sent by the user) once every 15-30 seconds, * > but only if `message.reactions` is set * * **Available**: 👤 users only * * @param chatId ID of the chat with messages * @param messages Message IDs * @returns Reactions to corresponding messages, or `null` if there are none */ getMessageReactionsById(chatId: InputPeerLike, messages: number[]): Promise<(MessageReactions | null)[]>; /** * Get reactions to {@link Message}s. * * > **Note**: messages must all be from the same chat. * * > Apps should short-poll reactions for visible messages * > (that weren't sent by the user) once every 15-30 seconds, * > but only if `message.reactions` is set * * **Available**: ✅ both users and bots * * @param chatId ID of the chat with messages * @param messages Message IDs * @returns Reactions to corresponding messages, or `null` if there are none */ getMessageReactions(messages: Message[]): Promise<(MessageReactions | null)[]>; /** * Get messages from PM or legacy group by their IDs. * For channels, use {@link getMessages}. * * Unlike {@link getMessages}, this method does not * check if the message belongs to some chat. * * For messages that were not found, `null` will be * returned at that position. * * **Available**: 👤 users only * * @param messageIds Messages IDs * @param [fromReply] * Whether the reply to a given message should be fetched * (i.e. `getMessages(msg.chat.id, msg.id, true).id === msg.replyToMessageId`) */ getMessagesUnsafe(messageIds: MaybeArray, fromReply?: boolean): Promise<(Message | null)[]>; /** * Get messages in chat by their IDs * * For messages that were not found, `null` will be * returned at that position. * * **Available**: ✅ both users and bots * * @param chatId Chat's marked ID, its username, phone or `"me"` or `"self"` * @param messageIds Messages IDs * @param [fromReply] * Whether the reply to a given message should be fetched * (i.e. `getMessages(msg.chat.id, msg.id, true).id === msg.replyToMessageId`) */ getMessages(chatId: InputPeerLike, messageIds: MaybeArray, fromReply?: boolean): Promise<(Message | null)[]>; /** * Get users who have reacted to the message. * * **Available**: 👤 users only * * @param params */ getReactionUsers(params: InputMessageId & { /** * Get only reactions with the specified emoji */ emoji?: InputReaction; /** * Limit the number of users returned. * * @default 100 */ limit?: number; /** * Offset for pagination */ offset?: GetReactionUsersOffset; }): Promise>; /** * For messages containing a reply, fetch the message that is being replied. * * Note that even if a message has {@link replyToMessage}, * the message itself may have been deleted, in which case * this method will also return `null`. * **Available**: ✅ both users and bots * */ getReplyTo(message: Message): Promise; /** * Get scheduled messages in chat by their IDs * * For messages that were not found, `null` will be * returned at that position. * * **Available**: 👤 users only * * @param chatId Chat's marked ID, its username, phone or `"me"` or `"self"` * @param messageIds Scheduled messages IDs */ getScheduledMessages(chatId: InputPeerLike, messageIds: MaybeArray): Promise<(Message | null)[]>; /** * Get a preview of a web page contained in the message * * **Available**: 👤 users only * * @param text Text of the message, or simply the link for which the preview should be retrieved */ getWebPagePreview(text: InputText): Promise; /** * Iterate over chat history. Wrapper over {@link getHistory} * * **Available**: ✅ both users and bots * * @param chatId Chat's marked ID, its username, phone or `"me"` or `"self"`. * @param params Additional fetch parameters */ iterHistory(chatId: InputPeerLike, params?: Parameters[2] & { /** * Limits the number of messages to be retrieved. * * @default Infinity, i.e. all messages */ limit?: number; /** * Chunk size. Usually you shouldn't care about this. * * @default 100 */ chunkSize?: number; }): AsyncIterableIterator; /** * Iterate over users who have reacted to the message. * * Wrapper over {@link getReactionUsers}. * * **Available**: ✅ both users and bots * * @param chatId Chat ID * @param messageId Message ID * @param params */ iterReactionUsers(params: Parameters[1] & { /** * Limit the number of events returned. * * @default `Infinity`, i.e. all events are returned */ limit?: number; /** * Chunk size, usually not needed. * * @default 100 */ chunkSize?: number; }): AsyncIterableIterator; /** * Search for messages globally from all of your chats. * * Iterable version of {@link searchGlobal} * * **Note**: Due to Telegram limitations, you can only get up to ~10000 messages * * **Available**: ✅ both users and bots * * @param params Search parameters */ iterSearchGlobal(params?: Parameters[1] & { /** * Limits the number of messages to be retrieved. * * @default `Infinity`, i.e. all messages are returned */ limit?: number; /** * Chunk size, which will be passed as `limit` parameter * for `messages.search`. Usually you shouldn't care about this. * * @default 100 */ chunkSize?: number; }): AsyncIterableIterator; /** * Search for messages inside a specific chat * * Iterable version of {@link searchMessages} * * **Available**: ✅ both users and bots * * @param chatId Chat's marked ID, its username, phone or `"me"` or `"self"`. * @param params Additional search parameters */ iterSearchMessages(params?: Parameters[1] & { /** * Limits the number of messages to be retrieved. * * @default `Infinity`, i.e. all messages are returned */ limit?: number; /** * Chunk size, which will be passed as `limit` parameter * for `messages.search`. Usually you shouldn't care about this. * * @default `100` */ chunkSize?: number; }): AsyncIterableIterator; /** * Pin a message in a group, supergroup, channel or PM. * * For supergroups/channels, you must have appropriate permissions, * either as an admin, or as default permissions * * **Available**: 👤 users only * * @returns Service message about pinned message, if one was generated. */ pinMessage(params: InputMessageId & { /** Whether to send a notification (only for legacy groups and supergroups) */ notify?: boolean; /** Whether to pin for both sides (only for private chats) */ bothSides?: boolean; /** * Whether to dispatch the returned service message (if any) * to the client's update handler. */ shouldDispatch?: true; }): Promise; /** * Mark chat history as read. * * **Available**: 👤 users only * * @param chatId Chat ID */ readHistory(chatId: InputPeerLike, params?: { /** * Message up until which to read history * * @default 0, i.e. read everything */ maxId?: number; /** * Whether to also clear all mentions in the chat */ clearMentions?: boolean; /** * Whether to dispatch updates that will be generated by this call. * Doesn't follow `disableNoDispatch` */ shouldDispatch?: true; }): Promise; /** * Mark all reactions in chat as read. * * **Available**: 👤 users only * * @param chatId Chat ID */ readReactions(chatId: InputPeerLike, params?: { /** * Whether to dispatch updates that will be generated by this call. * Doesn't follow `disableNoDispatch` */ shouldDispatch?: true; }): Promise; /** * Search for messages globally from all of your chats * * **Note**: Due to Telegram limitations, you can only get up to ~10000 messages * * **Available**: 👤 users only * * @param params Search parameters */ searchGlobal(params?: { /** * Text query string. Use `"@"` to search for mentions. * * @default `""` (empty string) */ query?: string; /** * Limits the number of messages to be retrieved. * * @default 100 */ limit?: number; /** * Filter the results using some filter. (see {@link SearchFilters}) * * @default {@link SearchFilters.Empty} (i.e. will return all messages) */ filter?: tl.TypeMessagesFilter; /** * Offset data used for pagination */ offset?: SearchGlobalOffset; /** * Only return messages newer than this date */ minDate?: Date | number; /** * Only return messages older than this date */ maxDate?: Date | number; /** * Whether to only search across broadcast channels */ onlyChannels?: boolean; }): Promise>; /** * Perform a global hashtag search, across the entire Telegram * * **Available**: 👤 users only * * @param hashtag Hashtag to search for * @param params Additional parameters */ searchHashtag(hashtag: string, params?: { /** Offset for the search */ offset?: SearchHashtagOffset; /** Limit the number of results */ limit?: number; }): Promise>; /** * Perform a global hashtag search, across the entire Telegram * * Iterable version of {@link searchHashtag} * * **Available**: ✅ both users and bots * * @param hashtag Hashtag to search for * @param params Additional parameters */ iterSearchHashtag(hashtag: string, params?: Parameters[2] & { /** * Limits the number of messages to be retrieved. * * @default `Infinity`, i.e. all messages are returned */ limit?: number; /** * Chunk size, which will be passed as `limit` parameter * for `messages.search`. Usually you shouldn't care about this. * * @default 100 */ chunkSize?: number; }): AsyncIterableIterator; /** * Search for messages inside a specific chat * * **Available**: 👤 users only * * @param chatId Chat's marked ID, its username, phone or `"me"` or `"self"`. * @param params Additional search parameters */ searchMessages(params?: { /** * Text query string. Required for text-only messages, * optional for media. * * @default `""` (empty string) */ query?: string; /** * Chat where to search for messages. * * When empty, will search across common message box (i.e. private messages and legacy chats) */ chatId?: InputPeerLike; /** * Offset ID for the search. Only messages earlier than this ID will be returned. * * @default `0` (starting from the latest message). */ offset?: SearchMessagesOffset; /** * Additional offset from {@link offset}, in resulting messages. * * This can be used for advanced use cases, like: * - Loading 20 results newer than message with ID `MSGID`: * `offset = MSGID, addOffset = -20, limit = 20` * - Loading 20 results around message with ID `MSGID`: * `offset = MSGID, addOffset = -10, limit = 20` * * When {@link offset} is not set, this will be relative to the last message * * @default `0` (disabled) */ addOffset?: number; /** * Minimum message ID to return * * @default `0` (disabled). */ minId?: number; /** * Maximum message ID to return. * * Unless {@link addOffset} is used, this will work the same as {@link offset}. * * @default `0` (disabled). */ maxId?: number; /** * Minimum message date to return * * @default `0` (disabled). */ minDate?: number | Date; /** * Maximum message date to return * * @default `0` (disabled). */ maxDate?: number | Date; /** * Thread ID to return only messages from this thread. */ threadId?: number; /** * Limits the number of messages to be retrieved. * * @default 100 */ limit?: number; /** * Filter the results using some filter (see {@link SearchFilters}) * * @default {@link SearchFilters.Empty} (i.e. will return all messages) */ filter?: tl.TypeMessagesFilter; /** * Search only for messages sent by a specific user. * * You can pass their marked ID, username, phone or `"me"` or `"self"` */ fromUser?: InputPeerLike; }): Promise>; /** * Search for posts globally across all public channels in Telegram * * **Available**: 👤 users only * * @param query Keyword to search for * @param params Additional parameters */ searchPostsGlobal(query: string, params?: { /** Offset for the search */ offset?: SearchPostsGlobalOffset; /** Limit the number of results */ limit?: number; /** * The amount of stars you are willing to pay for the search */ payStars?: tl.Long; }): Promise>; /** Send a text to the same chat (and topic, if applicable) as a given message */ answerText(message: Message, ...params: ParametersSkip2): ReturnType; /** Send a media to the same chat (and topic, if applicable) as a given message */ answerMedia(message: Message, ...params: ParametersSkip2): ReturnType; /** Send a media group to the same chat (and topic, if applicable) as a given message */ answerMediaGroup(message: Message, ...params: ParametersSkip2): ReturnType; /** * Send a text comment to a given message. * * If this is a normal message (not a channel post), * a simple reply will be sent. * * **Available**: ✅ both users and bots * * @throws MtArgumentError * If this is a channel post which does not have comments section. * To check if a post has comments, use {@link Message#replies}.hasComments */ commentText(message: Message, ...params: ParametersSkip2): ReturnType; /** * Send a text comment to a given message. * * If this is a normal message (not a channel post), * a simple reply will be sent. * * **Available**: ✅ both users and bots * * @throws MtArgumentError * If this is a channel post which does not have comments section. * To check if a post has comments, use {@link Message#replies}.hasComments */ commentMedia(message: Message, ...params: ParametersSkip2): ReturnType; /** * Send a text comment to a given message. * * If this is a normal message (not a channel post), * a simple reply will be sent. * * **Available**: ✅ both users and bots * * @throws MtArgumentError * If this is a channel post which does not have comments section. * To check if a post has comments, use {@link Message#replies}.hasComments */ commentMediaGroup(message: Message, ...params: ParametersSkip2): ReturnType; /** * Copy a message group (i.e. send the same message group, but do not forward it). * * Note that all the provided messages must be in the same message group * **Available**: ✅ both users and bots * */ sendCopyGroup(params: SendCopyGroupParams & ({ /** Source chat ID */ fromChatId: InputPeerLike; /** Message IDs to forward */ messages: number[]; } | { messages: Message[]; })): Promise; /** * Copy a message (i.e. send the same message, but do not forward it). * * Note that if the message contains a webpage, * it will be copied simply as a text message, * and if the message contains an invoice, * it can't be copied. * **Available**: ✅ both users and bots * */ sendCopy(params: SendCopyParams & ({ /** Source chat ID */ fromChatId: InputPeerLike; /** Message ID to forward */ message: number; } | { message: Message; })): Promise; /** * Send a group of media. * * To add a caption to the group, add caption to the first * media in the group and don't add caption for any other. * * **Available**: 👤 users only * * @param chatId ID of the chat, its username, phone or `"me"` or `"self"` * @param medias Medias contained in the message. * @param params Additional sending parameters * @link InputMedia */ sendMediaGroup(chatId: InputPeerLike, medias: (InputMediaLike | string)[], params?: CommonSendParams & { /** * Whether to invert media position. * * Currently only supported for web previews and makes the * client render the preview above the caption and not below. */ invertMedia?: boolean; /** * Function that will be called after some part has been uploaded. * Only used when a file that requires uploading is passed, * and not used when uploading a thumbnail. * * @param index Index of the media in the original array * @param uploaded Number of bytes already uploaded * @param total Total file size */ progressCallback?: (index: number, uploaded: number, total: number) => void; }): Promise; /** * Send a single media (a photo or a document-based media) * * **Available**: 👤 users only * * @param chatId ID of the chat, its username, phone or `"me"` or `"self"` * @param media * Media contained in the message. You can also pass TDLib * and Bot API compatible File ID, which will be wrapped * in {@link InputMedia.auto} * @param params Additional sending parameters * @link InputMedia */ sendMedia(chatId: InputPeerLike, media: InputMediaLike | string, params?: CommonSendParams & { /** Override the default random ID, for streaming drafts */ randomId?: Long; /** * For bots: inline or reply markup or an instruction * to hide a reply keyboard or to force a reply. */ replyMarkup?: ReplyMarkup; /** * Whether to invert media position. * * Currently only supported for web previews and makes the * client render the preview above the caption and not below. */ invert?: boolean; /** * Override caption for `media`. * * Can be used, for example. when using File IDs * or when using existing InputMedia objects. */ caption?: InputText; /** * Function that will be called after some part has been uploaded. * Only used when a file that requires uploading is passed, * and not used when uploading a thumbnail. * * @param uploaded Number of bytes already uploaded * @param total Total file size */ progressCallback?: (uploaded: number, total: number) => void; }): Promise; /** * Send a paid reaction using Telegram Stars. * * **Available**: 👤 users only * * @returns * Message to which the reaction was sent, if available. * The message is normally available for users, but may not be available for bots in PMs. */ sendPaidReaction(params: InputMessageId & { /** * Whether to send the reaction anonymously */ anonymous?: boolean; /** * Peer as which to send the reaction, mutually exclusive with `anonymous` */ asPeer?: InputPeerLike; /** * Number of reactions to send * * @default 1 */ count?: number; /** * Whether to dispatch the returned edit message event * to the client's update handler. */ shouldDispatch?: true; }): Promise; /** Send a text in reply to a given quote */ quoteWithText(message: Message, params: QuoteParamsFrom[3]> & { /** Text to send */ text: Parameters[2]; }): ReturnType; /** Send a media in reply to a given quote */ quoteWithMedia(message: Message, params: QuoteParamsFrom[3]> & { /** Media to send */ media: Parameters[2]; }): ReturnType; /** Send a media group in reply to a given quote */ quoteWithMediaGroup(message: Message, params: QuoteParamsFrom[3]> & { /** Media group to send */ medias: Parameters[2]; }): ReturnType; /** * Send or remove a reaction. * * **Available**: 👤 users only * * @returns * Message to which the reaction was sent, if available. * The message is normally available for users, but may not be available for bots in PMs. */ sendReaction(params: InputMessageId & { /** Reaction emoji (or `null` to remove reaction) */ emoji?: MaybeArray | null; /** Whether to use a big reaction */ big?: boolean; /** * Whether to dispatch the returned edit message event * to the client's update handler. */ shouldDispatch?: true; }): Promise; /** Send a text in reply to a given message */ replyText(message: Message, ...params: ParametersSkip2): ReturnType; /** Send a media in reply to a given message */ replyMedia(message: Message, ...params: ParametersSkip2): ReturnType; /** Send a media group in reply to a given message */ replyMediaGroup(message: Message, ...params: ParametersSkip2): ReturnType; /** * Send previously scheduled message(s) * * Note that if the message belongs to a media group, * the entire group will be sent, and all the messages * will be returned. * * **Available**: 👤 users only * * @param peer Chat where the messages were scheduled * @param ids ID(s) of the messages */ sendScheduled(peer: InputPeerLike, ids: MaybeArray): Promise; /** * Send a text message * * **Available**: 👤 users only * * @param chatId ID of the chat, its username, phone or `"me"` or `"self"` * @param text Text of the message * @param params Additional sending parameters */ sendText(chatId: InputPeerLike, text: InputText, params?: CommonSendParams & { /** Override the default random ID, for streaming drafts */ randomId?: Long; /** * For bots: inline or reply markup or an instruction * to hide a reply keyboard or to force a reply. */ replyMarkup?: ReplyMarkup; /** * Whether to disable links preview in this message */ disableWebPreview?: boolean; /** * Whether to invert media position. * * Currently only supported for web previews and makes the * client render the preview above the caption and not below. */ invertMedia?: boolean; }): Promise; /** * Sends a current user/bot typing event * to a conversation partner or group. * * This status is set for 6 seconds, and is * automatically cancelled if you send a * message. * * If you need a continuous typing status, use {@link setTyping} instead. * * **Available**: 👤 users only * * @param chatId Chat ID * @param [status='typing'] Typing status * @param params */ sendTyping(chatId: InputPeerLike, status?: Exclude | tl.TypeSendMessageAction, params?: { /** * For `upload_*` and history import actions, progress of the upload */ progress?: number; /** * Unique identifier of the business connection on behalf of which the action will be sent */ businessConnectionId?: string; /** * For comment threads, ID of the thread (i.e. top message) */ threadId?: number; }): Promise; /** * Send or retract a vote in a poll. * **Available**: 👤 users only * */ sendVote(params: InputMessageId & { /** * Selected options, or `null` to retract. * You can pass indexes of the answers or the `Buffer`s * representing them. In case of indexes, the poll will first * be requested from the server. */ options: null | MaybeArray; }): Promise; /** * Sets whether a user is typing in a specific chat * * This status is automatically renewed by mtcute until a further * call with `cancel` is made, or a message is sent to the chat. * **Available**: 👤 users only * */ setTyping(params: { /** Chat ID where the user is currently typing */ peerId: InputPeerLike; /** * Typing status to send * * @default `typing` */ status?: Exclude | tl.TypeSendMessageAction; /** * For `upload_*` and history import actions, progress of the upload */ progress?: number; /** * Unique identifier of the business connection on behalf of which the action will be sent */ businessConnectionId?: string; /** * For comment threads, ID of the thread (i.e. top message) */ threadId?: number; }): Promise; /** * Toggle the completion status of a todo list item(s) * * **Available**: 👤 users only * * @returns Service message about the toggled items, if any. */ toggleTodoCompleted(params: InputMessageId & { /** Items to mark as completed */ completed: MaybeArray; /** Items to mark as uncompleted */ uncompleted: MaybeArray; /** * Whether to dispatch the new message event * to the client's update handler. */ shouldDispatch?: true; }): Promise; /** * Translate message text to a given language. * * Returns `null` if it could not translate the message. * **Available**: 👤 users only * */ translateMessage(params: InputMessageId & { /** Target language (two-letter ISO 639-1 language code) */ toLanguage: string; }): Promise; /** * Translate text to a given language. * * **Available**: 👤 users only * * @param text Text to translate * @param toLanguage Target language (two-letter ISO 639-1 language code) */ translateText(text: InputText, toLanguage: string): Promise; /** * Unpin all pinned messages in a chat. * * **Available**: 👤 users only * * @param chatId Chat or user ID */ unpinAllMessages(chatId: InputPeerLike, params?: { /** * For forums - unpin only messages from the given topic */ topicId?: number; /** * Whether to dispatch updates that will be generated by this call. * Doesn't follow `disableNoDispatch` */ shouldDispatch?: true; }): Promise; /** * Unpin a message in a group, supergroup, channel or PM. * * For supergroups/channels, you must have appropriate permissions, * either as an admin, or as default permissions * * **Available**: 👤 users only * * @param chatId Chat ID, username, phone number, `"self"` or `"me"` * @param messageId Message ID */ unpinMessage(params: InputMessageId): Promise; /** * Get information about a fragment collectible * **Available**: 👤 users only * */ getCollectibleInfo(kind: 'phone' | 'username', item: string): Promise; /** * Create a new takeout session * * **Available**: 👤 users only * * @param params Takeout session parameters */ initTakeoutSession(params: Omit): Promise; /** * Normalize {@link InputPrivacyRule}[] to `tl.TypeInputPrivacyRule`, * resolving the peers if needed. * **Available**: ✅ both users and bots * */ _normalizePrivacyRules(rules: InputPrivacyRule[]): Promise; /** * Change your 2FA password * **Available**: 👤 users only * */ changeCloudPassword(params: { /** Current password as plaintext */ currentPassword: string; /** New password as plaintext */ newPassword: string; /** Hint for the new password */ hint?: string; }): Promise; /** * Enable 2FA password on your account * * Note that if you pass `email`, `EmailUnconfirmedError` may be * thrown, and you should use {@link verifyPasswordEmail}, * {@link resendPasswordEmail} or {@link cancelPasswordEmail}, * and the call this method again * **Available**: 👤 users only * */ enableCloudPassword(params: { /** 2FA password as plaintext */ password: string; /** Hint for the new password */ hint?: string; /** Recovery email */ email?: string; }): Promise; /** * Verify an email to use as 2FA recovery method * * **Available**: 👤 users only * * @param code Code which was sent via email */ verifyPasswordEmail(code: string): Promise; /** * Resend the code to verify an email to use as 2FA recovery method. * **Available**: 👤 users only * */ resendPasswordEmail(): Promise; /** * Cancel the code that was sent to verify an email to use as 2FA recovery method * **Available**: 👤 users only * */ cancelPasswordEmail(): Promise; /** * Remove 2FA password from your account * * **Available**: 👤 users only * * @param password 2FA password as plaintext */ removeCloudPassword(password: string): Promise; /** * Boost a given channel * * **Available**: 👤 users only * * @param peerId Peer ID to boost */ applyBoost(peerId: InputPeerLike): Promise; /** * Check if the current user can apply boost to some channel * * **Available**: ✅ both users and bots * * @returns * - `{ can: true }` if the user can apply boost * - `.replace` - {@link Chat}s that can be replaced with the current one. * If the user can apply boost without replacing any chats, this field will be `undefined`. * - `{ can: false }` if the user can't apply boost * - `.reason == "no_slots"` if the user has no available slots * - `.reason == "need_premium"` if the user needs Premium to boost * - In all cases, `slots` will contain all the current user's boost slots */ canApplyBoost(): Promise; /** * Create a new business chat link * * **Available**: 👤 users only * * @param text Text to be inserted into the message input */ createBusinessChatLink(text: InputText, params?: { /** Custom title for the link */ title?: string; }): Promise; /** * Edit an existing business chat link * * **Available**: 👤 users only * * @param link The link to edit */ editBusinessChatLink(link: string | BusinessChatLink, params: { /** Text to be inserted in the message input */ text: InputText; /** Custom title for the link */ title?: string; }): Promise; /** * Delete a business chat link * * **Available**: 👤 users only * * @param link The link to delete */ deleteBusinessChatLink(link: string | BusinessChatLink): Promise; /** * Get information about boosts in a channel * * **Available**: 👤 users only * * @returns IDs of stories that were removed */ getBoostStats(peerId: InputPeerLike): Promise; /** * Get boosts of a channel * **Available**: 👤 users only * */ getBoosts(peerId: InputPeerLike, params?: { /** * Offset for pagination */ offset?: string; /** * Maximum number of boosters to fetch * * @default 100 */ limit?: number; }): Promise>; /** * Get current user's business chat links * **Available**: 👤 users only * */ getBusinessChatLinks(): Promise; /** * Get information about the connection of the bot with a business account * * **Available**: 🤖 bots only * * @param connectionId ID of the business connection */ getBusinessConnection(connectionId: string): Promise; /** * Get boost slots information of the current user. * * Includes information about the currently boosted channels, * as well as the slots that can be used to boost other channels. * **Available**: 👤 users only * */ getMyBoostSlots(): Promise; /** * Get Telegram Stars transactions for a given peer. * * You can either pass `self` to get your own transactions, * or a chat/bot ID to get transactions of that peer. * * **Available**: 👤 users only * * @param peerId Peer ID * @param params Additional parameters */ getStarsTransactions(peerId: InputPeerLike, params?: { /** * If passed, only transactions of this direction will be returned */ direction?: 'incoming' | 'outgoing'; /** * Direction to sort transactions date by (default: desc) */ sort?: 'asc' | 'desc'; /** * If passed, will only return transactions related to this subscription ID */ subscriptionId?: string; /** Pagination offset */ offset?: string; /** Whether to return transactions made in TON */ ton?: boolean; /** * Pagination limit * * @default 100 */ limit?: number; }): Promise; /** * Iterate over boosters of a channel. * * Wrapper over {@link getBoosters} * **Available**: ✅ both users and bots * */ iterBoosters(peerId: InputPeerLike, params?: Parameters[2] & { /** * Total number of boosters to fetch * * @default Infinity, i.e. fetch all boosters */ limit?: number; /** * Number of boosters to fetch per request * Usually you don't need to change this * * @default 100 */ chunkSize?: number; }): AsyncIterableIterator; /** * Iterate over Telegram Stars transactions for a given peer. * * You can either pass `self` to get your own transactions, * or a chat/bot ID to get transactions of that peer. * * Wrapper over {@link getStarsTransactions} * * **Available**: ✅ both users and bots * * @param peerId Peer ID * @param params Additional parameters */ iterStarsTransactions(peerId: InputPeerLike, params?: Parameters[2] & { /** * Total number of boosters to fetch * * @default Infinity, i.e. fetch all boosters */ limit?: number; /** * Number of boosters to fetch per request * Usually you don't need to change this * * @default 100 */ chunkSize?: number; }): AsyncIterableIterator; /** * Set current user's business introduction. * * **Available**: 👤 users only * * @param intro Introduction parameters, or `null` to remove */ setBusinessIntro(intro: { /** * Title of the introduction */ title?: string; /** * Description of the introduction */ description?: string; /** * Sticker to show beneath the introduction */ sticker?: InputMediaSticker | InputFileLike | tl.TypeInputDocument; } | null): Promise; /** * Set current user's business work hours. * **Available**: 👤 users only * */ setBusinessWorkHours(params: ({ /** Timezone in which the hours are defined */ timezone: string; } & ({ /** * Business work intervals, per-day (like available in {@link BusinessWorkHours.days}) */ hours: ReadonlyArray; } | { /** Business work intervals, raw intervals */ intervals: tl.TypeBusinessWeeklyOpen[]; })) | null): Promise; /** * Add a sticker to a sticker set. * * For bots the sticker set must have been created by this bot. * * **Available**: 👤 users only * * @param setId Sticker set short name or TL object with input sticker set * @param sticker Sticker to be added * @param params * @returns Modfiied sticker set */ addStickerToSet(setId: InputStickerSet, sticker: InputStickerSetItem, params?: { /** * Upload progress callback * * @param uploaded Number of bytes uploaded * @param total Total file size */ progressCallback?: (uploaded: number, total: number) => void; }): Promise; /** * Create a new sticker set. * * **Available**: 👤 users only * * @param params * @returns Newly created sticker set */ createStickerSet(params: { /** * Owner of the sticker set (must be user). * * If this pack is created from a user account, * can only be `"self"` */ owner: InputPeerLike; /** * Title of the sticker set (1-64 chars) */ title: string; /** * Short name of the sticker set. * Can only contain English letters, digits and underscores * (i.e. must match `/^[a-zA-Z0-9_]+$/), * and (for bots) must end with `_by_` * (`` is case-insensitive). */ shortName: string; /** * Type of the stickers in this set. * * @default `sticker`, i.e. regular stickers. */ type?: StickerType; /** * Whether to create "adaptive" emoji set. * * Color of the emoji will be changed depending on the text color. * Only works for TGS-based emoji stickers */ adaptive?: boolean; /** * List of stickers to be immediately added into the pack. * There must be at least one sticker in this list. */ stickers: InputStickerSetItem[]; /** * Thumbnail for the set. * * The file must be either a `.png` file * up to 128kb, having size of exactly `100x100` px, * or a `.tgs` file up to 32kb. * * If not set, Telegram will use the first sticker * in the sticker set as the thumbnail */ thumb?: InputFileLike; /** * Upload progress callback. * * @param idx Index of the sticker * @param uploaded Number of bytes uploaded * @param total Total file size */ progressCallback?: (idx: number, uploaded: number, total: number) => void; }): Promise; /** * Delete a sticker from a sticker set * * For bots the sticker set must have been created by this bot. * * **Available**: 👤 users only * * @param sticker * TDLib and Bot API compatible File ID, or a * TL object representing a sticker to be removed * @returns Modfiied sticker set */ deleteStickerFromSet(sticker: InputDocumentId): Promise; /** * Get custom emoji stickers by their IDs, or `null` if not available/found. * * **Available**: 👤 users only * * @param ids IDs of the stickers (as defined in {@link MessageEntity.emojiId}) */ getCustomEmojis(ids: tl.Long[]): Promise<(Sticker | null)[]>; /** * Given one or more messages, extract all unique custom emojis from it and fetch them * **Available**: ✅ both users and bots * */ getCustomEmojisFromMessages(messages: MaybeArray): Promise; /** * Get a list of all installed sticker packs * * > **Note**: This method returns *brief* meta information about * > the packs, that does not include the stickers themselves. * > Use {@link getStickerSet} to get a stickerset that will include the stickers * **Available**: 👤 users only * */ getInstalledStickers(): Promise; /** * Get the list of sticker sets that were created by the current user * **Available**: 👤 users only * */ getMyStickerSets(params?: { /** Offset for pagination */ offset?: Long; /** Limit for pagination */ limit?: number; }): Promise>; /** * Get a sticker set and stickers inside of it. * * **Available**: 👤 users only * * @param setId Sticker set identifier */ getStickerSet(setId: InputStickerSet): Promise; /** * Move a sticker in a sticker set * to another position * * For bots the sticker set must have been created by this bot. * * **Available**: 👤 users only * * @param sticker * TDLib and Bot API compatible File ID, or a * TL object representing a sticker to be removed * @param position New sticker position (starting from 0) * @returns Modified sticker set */ moveStickerInSet(sticker: InputDocumentId, position: number): Promise; /** * Replace a sticker in a sticker set with another sticker * * For bots the sticker set must have been created by this bot. * * **Available**: ✅ both users and bots * * @param sticker * TDLib and Bot API compatible File ID, or a * TL object representing a sticker to be removed * @param newSticker New sticker to replace the old one with * @returns Modfiied sticker set */ replaceStickerInSet(sticker: InputDocumentId, newSticker: InputStickerSetItem, params?: { /** * Upload progress callback * * @param uploaded Number of bytes uploaded * @param total Total file size */ progressCallback?: (uploaded: number, total: number) => void; }): Promise; /** * Set group sticker set for a supergroup * * **Available**: 👤 users only * * @param setId Sticker set short name or a TL object with input sticker set * @param thumb Sticker set thumbnail * @param params * @returns Modified sticker set */ setChatStickerSet(chatId: InputPeerLike, setId: InputStickerSet): Promise; /** * Set sticker set thumbnail * * **Available**: 👤 users only * * @param id Sticker set short name or a TL object with input sticker set * @param thumb Sticker set thumbnail * @param params * @returns Modified sticker set */ setStickerSetThumb(id: InputStickerSet, thumb: InputFileLike | tl.TypeInputDocument, params?: { /** * Upload progress callback * * @param uploaded Number of bytes uploaded * @param total Total file size */ progressCallback?: (uploaded: number, total: number) => void; }): Promise; /** * Check if the current user can post stories as a given peer * * **Available**: 👤 users only * * @param peerId Peer ID whose stories to fetch * @returns * - `true` if the user can post stories * - `"need_admin"` if the user is not an admin in the chat * - `"need_boosts"` if the channel doesn't have enough boosts */ canSendStory(peerId: InputPeerLike): Promise; /** * Delete a story * * **Available**: 👤 users only * * @returns IDs of stories that were removed */ deleteStories(params: { /** * Story IDs to delete */ ids: MaybeArray; /** * Peer ID whose stories to delete * * @default `self` */ peer?: InputPeerLike; }): Promise; /** * Edit a sent story * * **Available**: 👤 users only * * @returns Edited story */ editStory(params: { /** * Story ID to edit */ id: number; /** * Peer ID to whose story to edit * * @default `self` */ peer?: InputPeerLike; /** * Media contained in a story. Currently can only be a photo or a video. */ media?: InputMediaLike; /** * Override caption for {@link media} */ caption?: InputText; /** * Interactive elements to add to the story */ interactiveElements?: tl.TypeMediaArea[]; /** * Privacy rules to apply to the story * * @default "Everyone" */ privacyRules?: InputPrivacyRule[]; }): Promise; /** * Get all stories (e.g. to load the top bar) * **Available**: 👤 users only * */ getAllStories(params?: { /** * Offset from which to fetch stories */ offset?: string; /** * Whether to fetch stories from "archived" (or "hidden") peers */ archived?: boolean; }): Promise; /** * Get stories of a given peer * * **Available**: 👤 users only * * @param peerId Peer ID whose stories to fetch */ getPeerStories(peerId: InputPeerLike): Promise; /** * Get profile stories * **Available**: 👤 users only * */ getProfileStories(peerId: InputPeerLike, params?: { /** * Kind of stories to fetch * - `pinned` - stories pinned to the profile and visible to everyone * - `archived` - "archived" stories that can later be pinned, only visible to the owner * * @default `pinned` */ kind?: 'pinned' | 'archived'; /** * Offset ID for pagination */ offsetId?: number; /** * Maximum number of stories to fetch * * @default 100 */ limit?: number; }): Promise>; /** * Get one or more stories by their IDs * * **Available**: 👤 users only * * @param peerId Peer ID whose stories to fetch * @param storyIds Story IDs */ getStoriesById(peerId: InputPeerLike, storyIds: MaybeArray): Promise; /** * Get brief information about stories interactions. * * The result will be in the same order as the input IDs * **Available**: 👤 users only * */ getStoriesInteractions(peerId: InputPeerLike, storyIds: MaybeArray): Promise; /** * Generate a link to a story. * * Basically the link format is `t.me//s/`, * and if the user doesn't have a username, `USER_PUBLIC_MISSING` is thrown. * * I have no idea why is this an RPC call, but whatever * **Available**: 👤 users only * */ getStoryLink(peerId: InputPeerLike, storyId: number): Promise; /** * Get viewers list of a story * **Available**: 👤 users only * */ getStoryViewers(peerId: InputPeerLike, storyId: number, params?: { /** * Whether to only fetch viewers from contacts */ onlyContacts?: boolean; /** * How to sort the results? * - `reaction` - by reaction (viewers who has reacted are first), then by date (newest first) * - `date` - by date, newest first * * @default `reaction` */ sortBy?: 'reaction' | 'date'; /** * Search query */ query?: string; /** * Offset ID for pagination */ offset?: string; /** * Maximum number of viewers to fetch * * @default 100 */ limit?: number; }): Promise; /** * Hide own stories views (activate so called "stealth mode") * * Currently has a cooldown of 1 hour, and throws FLOOD_WAIT error if it is on cooldown. * **Available**: 👤 users only * */ hideMyStoriesViews(params?: { /** * Whether to hide views from the last 5 minutes * * @default true */ past?: boolean; /** * Whether to hide views for the next 25 minutes * * @default true */ future?: boolean; }): Promise; /** * Increment views of one or more stories. * * This should be used for pinned stories, as they can't * be marked as read when the user sees them ({@link Story#isActive} == false) * * **Available**: 👤 users only * * @param peerId Peer ID whose stories to mark as read * @param ids ID(s) of the stories to increment views of (max 200) */ incrementStoriesViews(peerId: InputPeerLike, ids: MaybeArray): Promise; /** * Iterate over all stories (e.g. to load the top bar) * * Wrapper over {@link getAllStories} * **Available**: ✅ both users and bots * */ iterAllStories(params?: Parameters[1] & { /** * Maximum number of stories to fetch * * @default Infinity */ limit?: number; }): AsyncIterableIterator; /** * Iterate over profile stories. Wrapper over {@link getProfileStories} * **Available**: ✅ both users and bots * */ iterProfileStories(peerId: InputPeerLike, params?: Parameters[2] & { /** * Total number of stories to fetch * * @default `Infinity`, i.e. fetch all stories */ limit?: number; /** * Number of stories to fetch per request. * Usually you shouldn't care about this. * * @default 100 */ chunkSize?: number; }): AsyncIterableIterator; /** * Iterate over viewers list of a story. * Wrapper over {@link getStoryViewers} * **Available**: ✅ both users and bots * */ iterStoryViewers(peerId: InputPeerLike, storyId: number, params?: Parameters[3] & { /** * Total number of viewers to fetch * * @default Infinity, i.e. fetch all viewers */ limit?: number; /** * Number of viewers to fetch per request. * Usually you don't need to change this. * * @default 100 */ chunkSize?: number; }): AsyncIterableIterator; /** * Mark all stories up to a given ID as read * * This should only be used for "active" stories ({@link Story#isActive} == false) * * **Available**: 👤 users only * * @param peerId Peer ID whose stories to mark as read * @returns IDs of the stores that were marked as read */ readStories(peerId: InputPeerLike, maxId: number): Promise; /** * Send (or remove) a reaction to a story * **Available**: 👤 users only * */ sendStoryReaction(params: { peerId: InputPeerLike; storyId: number; reaction: InputReaction; /** * Whether to add this reaction to recently used */ addToRecent?: boolean; }): Promise; /** * Send a story * * **Available**: 👤 users only * * @returns Created story */ sendStory(params: { /** * Peer ID to send story as * * @default `self` */ peer?: InputPeerLike; /** * Media contained in a story. Currently can only be a photo or a video. * * You can also pass TDLib and Bot API compatible File ID, * which will be wrapped in {@link InputMedia.auto} */ media: InputMediaLike | string; /** * Override caption for {@link media} */ caption?: InputText; /** * Whether to automatically pin this story to the profile */ pinned?: boolean; /** * Whether to disallow sharing this story */ forbidForwards?: boolean; /** * Interactive elements to add to the story */ interactiveElements?: tl.TypeMediaArea[]; /** * Privacy rules to apply to the story * * @default "Everyone" */ privacyRules?: InputPrivacyRule[]; /** * TTL period of the story, in seconds * * @default 86400 */ period?: number; /** * IDs of albums to add the story to */ addToAlbums?: number[]; }): Promise; /** * Toggle whether peer's stories are archived (hidden) or not. * * This **does not** archive the chat with that peer, only stories. * **Available**: 👤 users only * */ togglePeerStoriesArchived(peerId: InputPeerLike, archived: boolean): Promise; /** * Toggle one or more stories pinned status * * **Available**: 👤 users only * * @returns IDs of stories that were toggled */ toggleStoriesPinned(params: { /** * Story ID(s) to toggle */ ids: MaybeArray; /** * Whether to pin or unpin the story */ pinned: boolean; /** * Peer ID whose stories to toggle * * @default `self` */ peer?: InputPeerLike; }): Promise; /** * Block a user * * **Available**: 👤 users only * * @param id User ID, username or phone number */ blockUser(id: InputPeerLike): Promise; /** * Delete your own profile photos * * **Available**: 👤 users only * * @param ids ID(s) of the photos. Can be file IDs or raw TL objects */ deleteProfilePhotos(ids: MaybeArray): Promise; /** * Edit "close friends" list directly using user IDs * * **Available**: 👤 users only * * @param ids User IDs */ editCloseFriendsRaw(ids: number[]): Promise; /** * Edit "close friends" list using `InputPeerLike`s * * **Available**: 👤 users only * * @param ids User IDs */ editCloseFriends(ids: InputPeerLike[]): Promise; /** * Get a list of common chats you have with a given user * * **Available**: 👤 users only * * @param userId User's ID, username or phone number * @throws MtInvalidPeerTypeError */ getCommonChats(userId: InputPeerLike): Promise; /** * Gets the current default value of the Time-To-Live setting, applied to all new chats. * **Available**: 👤 users only * */ getGlobalTtl(): Promise; /** * Get currently authorized user's full information * **Available**: 👤 users only * */ getMe(): Promise; /** * Get currently authorized user's username. * * This method uses locally available information and * does not call any API methods. * **Available**: ✅ both users and bots * */ getMyUsername(): Promise; /** Get {@link PeerSettings} for a peer */ getPeerSettings(peerId: InputPeerLike): Promise; /** * Get a single profile picture of a user by its ID * * **Available**: 👤 users only * * @param userId User ID, username, phone number, `"me"` or `"self"` * @param photoId ID of the photo to fetch * @param params */ getProfilePhoto(userId: InputPeerLike, photoId: tl.Long): Promise; /** * Get a list of profile pictures of a user * * **Available**: 👤 users only * * @param userId User ID, username, phone number, `"me"` or `"self"` * @param params */ getProfilePhotos(userId: InputPeerLike, params?: { /** * Offset from which to fetch. * * @default `0` */ offset?: number; /** * Maximum number of items to fetch (up to 100) * * @default `100` */ limit?: number; }): Promise>; /** * Get music files saved to the user's profile * **Available**: 👤 users only * */ getSavedMusic(params: { /** User ID, username, phone number, `"me"` or `"self"` */ userId: InputPeerLike; /** Offset for pagination */ offset?: number; /** Limit for pagination */ limit?: number; }): Promise>; /** * Get information about multiple users. * You can retrieve up to 200 users at once. * * **Available**: ✅ both users and bots * * @param ids Users' identifiers. Can be ID, username, phone number, `"me"`, `"self"` or TL object * @returns The list of users in the same order as the input */ getUsers(ids: MaybeArray): Promise<(User | null)[]>; /** * Check whether a given peer ID can be used to actually * interact with the Telegram API. * This method checks the internal peers cache for the given * input peer, and returns `true` if it is available there. * * You can think of this method as a stripped down version of * {@link resolvePeer}, which only returns `true` or `false`. * * > **Note:** This method works offline and never sends any requests. * > This means that when passing a username or phone number, it will * > only return `true` if the user with that username/phone number * > is cached in the storage, and will not try to resolve the peer by calling the API, * > which *may* lead to false negatives. * * **Available**: ✅ both users and bots * * @returns */ isPeerAvailable(peerId: InputPeerLike): Promise; /** * Iterate over profile photos * * **Available**: ✅ both users and bots * * @param userId User ID, username, phone number, `"me"` or `"self"` * @param params */ iterProfilePhotos(userId: InputPeerLike, params?: Parameters[2] & { /** * Maximum number of items to fetch * * @default `Infinity`, i.e. all items are fetched */ limit?: number; /** * Size of chunks which are fetched. Usually not needed. * * @default 100 */ chunkSize?: number; }): AsyncIterableIterator; /** * Get multiple `InputPeer`s at once, * while also normalizing and removing * peers that can't be normalized to that type. * * If a peer was not found, it will be skipped. * * Uses async pool internally, with a concurrent limit of 8 * * @param peerIds Peer Ids * @param normalizer Normalization function */ resolvePeerMany(peerIds: InputPeerLike[], normalizer: (obj: tl.TypeInputPeer) => T | null): Promise; /** * Get multiple `InputPeer`s at once. * * If a peer was not found, `null` will be returned instead * * Uses async pool internally, with a concurrent limit of 8 * * @param peerIds Peer Ids */ resolvePeerMany(peerIds: InputPeerLike[]): Promise<(tl.TypeInputPeer | null)[]>; /** * Get the `InputPeer` of a known peer id. * Useful when an `InputPeer` is needed in Raw API. * * **Available**: ✅ both users and bots * * @param peerId The peer identifier that you want to extract the `InputPeer` from. * @param [force=false] Whether to force re-fetch the peer from the server */ resolvePeer(peerId: InputPeerLike, force?: boolean): Promise; /** * Shorthand for `resolvePeer` that converts the input peer to `InputUser`. * **Available**: ✅ both users and bots * */ resolveUser(peerId: InputPeerLike, force?: boolean): Promise; /** * Shorthand for `resolvePeer` that converts the input peer to `InputChannel`. * **Available**: ✅ both users and bots * */ resolveChannel(peerId: InputPeerLike, force?: boolean): Promise; /** * Get the `InputPeer` by user's phone number. * Useful when an `InputPeer` is needed in Raw API. * * **Available**: ✅ both users and bots * * @param phone Phone number of the user * @param [force=false] Whether to force re-fetch the peer from the server */ resolvePhoneNumber(phone: string, force?: boolean): Promise; saveMusicToProfile(params: { /** Audio file to save (or its ID) */ audio: InputMediaAudio | InputDocumentId; /** Optionally, document ID after which we should insert the music */ after?: InputDocumentId; /** * Upload progress callback * * @param uploaded Number of bytes uploaded * @param total Total file size */ progressCallback?: (uploaded: number, total: number) => void; }): Promise; unsaveMusicFromProfile(params: { /** ID of the Audio file to unsave */ audio: InputDocumentId; }): Promise; /** * Set an emoji status for the given user/chat * * You can change emoji status of: * - yourself (`self`) * - supergroups or channels with enough boosts which you are an admin of * - for bots – users who gave you the appropriate permissions * **Available**: 👤 users only * */ setEmojiStatus(params: { /** User or chat where the emoji status should be set */ peerId: InputPeerLike; /** Custom emoji ID or `null` to remove the emoji */ emoji: tl.Long | null; /** When true, `emoji` is the ID of the collectible emoji */ isCollectible?: boolean; /** * Date when the emoji status should expire (only if `emoji` is not `null`) */ until?: number | Date; }): Promise; /** * Changes the current default value of the Time-To-Live setting, * applied to all new chats. * * **Available**: 👤 users only * * @param period New TTL period, in seconds (or 0 to disable) */ setGlobalTtl(period: number): Promise; /** * Set or remove current user's birthday. * **Available**: 👤 users only * */ setMyBirthday(birthday: { /** Birthday day */ day: number; /** Birthday month */ month: number; /** Birthday year (optional) */ year?: number; } | null): Promise; /** * Set a new profile photo or video for the current user. * * You can also pass a file ID or an InputPhoto to re-use existing photo. * **Available**: 👤 users only * */ setMyProfilePhoto(params: { /** Media type (photo or video) */ type: 'photo' | 'video'; /** Input media file */ media: InputFileLike | tl.TypeInputPhoto; /** When `type = video`, timestamp in seconds which will be shown as a static preview. */ previewSec?: number; }): Promise; /** * Change username of the current user. * * Note that bots usernames must be changed through * bot support or re-created from scratch. * * **Available**: 👤 users only * * @param username New username (5-32 chars, allowed chars: `a-zA-Z0-9_`), or `null` to remove */ setMyUsername(username: string | null): Promise; /** * Change user status to offline or online once, * which will expire after a while (currently ~5 minutes) * * For continuously sending online/offline status, use {@link setOnline} * * **Available**: 👤 users only * * @param online Whether the user is currently online */ sendOnline(online: boolean): Promise; /** * Change user status to online or offline * * Once called with `true`, mtcute will keep notifying the server * that the user is still online until a further call with `false` is made. * * **Available**: 👤 users only * * @param [online=true] */ setOnline(online?: boolean): Promise; /** * Unblock a user * * **Available**: 👤 users only * * @param id User ID, username or phone number */ unblockUser(id: InputPeerLike): Promise; /** * Update your profile details. * * Only pass fields that you want to change. * * **Available**: 👤 users only * * @param params */ updateProfile(params: { /** * New first name */ firstName?: string; /** * New last name. Pass `''` (empty string) to remove it */ lastName?: string; /** * New bio (max 70 chars). Pass `''` (empty string) to remove it */ bio?: string; }): Promise; } export type { TelegramClientOptions }; export * from './base.js'; export declare class TelegramClient implements ITelegramClient { _client: ITelegramClient; constructor(opts: TelegramClientOptions); }