/**
* MTKruto - Cross-runtime JavaScript library for building Telegram clients
* Copyright (C) 2023-2026 Roj
*
* This file is part of MTKruto.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
import { type Storage } from "../2_storage.js";
import { Api, Mtproto } from "../2_tl.js";
import { type DC } from "../3_transport.js";
import { type AlbumStoryList, type Animation, type AppSupport, type Audio, type AuthorizationSession, type AvailableReactions, type Birthday, type BlockedUserList, type BotAccessSettings, type BotCommand, type BotTokenCheckResult, type BusinessAwayMessageSchedule, type BusinessConnection, type CallbackQueryAnswer, type CallbackQueryQuestion, type Chat, type ChatActionType, type ChatJoinResult, type ChatListItem, type ChatMember, type ChatP, type ChatPChannel, type ChatPGroup, type ChatPPrivate, type ChatPSupergroup, type ChatSettings, type ClaimedGifts, type CodeCheckResult, type Community, type CommunityP, type ConnectedWebsite, type Country, type EmojiStatus, type FailedInvitation, type FileSource, type Gift, type GiftCollection, type GiftPrivacy, type ID, type InactiveChat, type InlineQueryAnswer, type InlineQueryResult, type InputBusinessRecipients, type InputChecklistItem, type InputEmojiStatus, type InputGift, type InputMedia, type InputPollOption, type InputPrivacyRule, type InputRichText, type InputSticker, type InputStoryContent, type InviteLink, type JoinRequest, type LeftChannelList, type LinkPreview, type LiveStreamChannel, type Message, type MessageAnimation, type MessageAudio, type MessageChecklist, type MessageContact, type MessageCounters, type MessageDice, type MessageDocument, type MessageInvoice, type MessageList, type MessageLivePhoto, type MessageLocation, type MessagePhoto, type MessagePoll, type MessageReactionList, type MessageRichText, type MessageSticker, type MessageText, type MessageVenue, type MessageVideo, type MessageVideoNote, type MessageViewer, type MessageVoice, type MiniAppInfo, type NetworkStatistics, type NewChatPrivacy, type NotificationSettings, type ParseMode, type PasswordCheckResult, type Poll, type PollVoterList, type PremiumSubscriptionDuration, type PriceTag, type PrivacyRule, type PrivacySettingKey, type ProfilePhotoList, type Reaction, type RecentActionsEntry, type ReportReason, type ReportResult, type ResolvedInviteLink, type RichText, type SavedChats, type SavedNotificationSound, type SecretChat, type SlowModeDuration, type StarAmount, type StarTransactionList, type Sticker, type StickerSet, type StickerSetP, type Story, type StoryAlbum, type SummarizedText, type TextToTranslate, type Timezone, type TonTransactionList, type Topic, type TopicList, type TopicListItem, type TranslatedText, type Translation, type User, type VideoChat, type VideoChatActive, type VideoChatScheduled, type VoiceTranscription } from "../3_types.js";
import { Migrate } from "../4_errors.js";
import type { AddBotToAttachmentsMenuParams, AddChatMemberParams, AddChatToCommunityParams, AddContactParams, AddMusicToProfileParams, AddReactionParams, AddSavedNotificationSoundParams, AddStickerToStickerSetParams, AllowUnpaidMessagesFromUserParams, AnswerCallbackQueryParams, AnswerInlineQueryParams, AnswerPreCheckoutQueryParams, ApproveJoinRequestsParams, BanChatMemberParams, BoostChatParams, CheckUsernameParams, CreateChannelParams, CreateCommunityParams, CreateGroupParams, CreateInviteLinkParams, CreateStickerSetParams, CreateStoryParams, CreateSupergroupParams, CreateTopicParams, DeclineJoinRequestsParams, DeleteAccountParams, DeleteMessageParams, DeleteMessagesParams, DeleteMyCommandsParams, DisallowUnpaidMessagesFromUserParams, DownloadLiveStreamSegmentParams, DownloadParams, EditInlineMessageCaptionParams, EditInlineMessageMediaParams, EditInlineMessageRichTextParams, EditInlineMessageTextParams, EditMessageCaptionParams, EditMessageLiveLocationParams, EditMessageMediaParams, EditMessageReplyMarkupParams, EditMessageRichTextParams, EditMessageTextParams, EditStoryParams, EditTopicParams, EnableSignaturesParams, EndSecretChatParams, EndTakeoutSessionParams, ForwardMessagesParams, GetAdministeredChatsParams, GetBlockedUsersParams, GetChatMembersParams, GetChatsParams, GetClaimedGiftsParams, GetCommonChatsParams, GetCreatedInviteLinksParams, GetHistoryParams, GetJoinRequestsParams, GetLeftChannelsParams, GetLinkPreviewParams, GetMessageReactionsParams, GetMyCommandsParams, GetMyDescriptionParams, GetMyNameParams, GetMyShortDescriptionParams, GetPollVotersParams, GetProfileMusicParams, GetProfilePhotosParams, GetRecentActionsParams, GetSavedChatsParams, GetSavedMessagesParams, GetStarTransactionsParams, GetStoriesInAlbumParams, GetTonTransactionsParams, GetTopicsParams, GetTranslationsParams, GiftPremiumSubscriptionParams, InvokeParams, JoinVideoChatParams, MarkAllMentionsAsReadParams, OpenChatParams, OpenMiniAppParams, PinMessageParams, PromoteChatMemberParams, RemoveProfilePhotoParams, ReplaceStickerInStickerSetParams, ReportChatParams, ReportEphemeralMessageParams, ReportStoryParams, ResolveUsernameParams, SaveDraftParams, SaveRichTextDraftParams, ScheduleVideoChatParams, SearchMessagesParams, SendAnimationParams, SendAudioParams, SendChatActionParams, SendChecklistParams, SendContactParams, SendDiceParams, SendDocumentParams, SendGiftParams, SendInlineQueryParams, SendInvoiceParams, SendLivePhotoParams, SendLocationParams, SendMediaGroupParams, SendMessageDraftParams, SendMessageParams, SendPhotoParams, SendPollParams, SendRichTextDraftParams, SendRichTextParams, SendSecretAnimationParams, SendSecretAudioParams, SendSecretContactParams, SendSecretDocumentParams, SendSecretLocationParams, SendSecretMessageParams, SendSecretPhotoParams, SendSecretStickerParams, SendSecretVenueParams, SendSecretVideoNoteParams, SendSecretVideoParams, SendSecretVoiceParams, SendStickerParams, SendVenueParams, SendVideoNoteParams, SendVideoParams, SendVoiceParams, SetBirthdayParams, SetBusinessAwayMessageParams, SetBusinessIntroParams, SetChatMemberRightsParams, SetChatMemberTagParams, SetChatPhotoParams, SetContactNoteParams, SetEmojiStatusParams, SetLocationParams, SetManagedBotAccessSettingsParams, SetMyCommandsParams, SetMyDescriptionParams, SetMyNameParams, SetMyShortDescriptionParams, SetNameColorParams, SetNotificationSettingsParams, SetPersonalChannelParams, SetProfileColorParams, SetReactionsParams, SetStickerSetThumbnailParams, SetWorkingHoursParams, SignInParams, SignUpParams, StartBotParams, StartTakeoutSessionParams, StartVideoChatParams, StopPollParams, SummarizeTextParams, TranslateTextParams, UnpinMessageParams, UnpinMessagesParams, UpdateChecklistParams, UpdateProfileParams, UpdateProfilePhotoParams, UpdateProfileVideoParams } from "./0_params.js";
import { StorageOperations } from "./0_storage_operations.js";
import type { ClientGeneric } from "./1_client_generic.js";
import type { ClientPlainParams } from "./1_client_plain.js";
import { type InvokeErrorHandler } from "./1_invoke_middleware.js";
import { BotInfoManager } from "./2_bot_info_manager.js";
import { BusinessConnectionManager } from "./2_business_connection_manager.js";
import { CommunityManager } from "./2_community_manager.js";
import { FileManager } from "./2_file_manager.js";
import { GiftCollectionManager } from "./2_gift_collection_manager.js";
import { ManagedBotManager } from "./2_managed_bot_manager.js";
import { NetworkStatisticsManager } from "./2_network_statistics_manager.js";
import { PaymentManager } from "./2_payment_manager.js";
import { ReactionManager } from "./2_reaction_manager.js";
import { StoryAlbumManager } from "./2_story_album_manager.js";
import { TakeoutManager } from "./2_takeout_manager.js";
import { TranslationsManager } from "./2_translations_manager.js";
import { UpdateManager } from "./2_update_manager.js";
import { AccountManager } from "./3_account_manager.js";
import { MessageManager } from "./3_message_manager.js";
import { SecretChatManager } from "./3_secret_chat_manager.js";
import { StickerSetManager } from "./3_sticker_set_manager.js";
import { VideoChatManager } from "./3_video_chat_manager.js";
import { CallbackQueryManager } from "./4_callback_query_manager.js";
import { ChatListManager } from "./4_chat_list_manager.js";
import { ChatManager } from "./4_chat_manager.js";
import { ChecklistManager } from "./4_checklist_manager.js";
import { ContactManager } from "./4_contact_manager.js";
import type { Context } from "./4_context.js";
import { ForumManager } from "./4_forum_manager.js";
import { GiftManager } from "./4_gift_manager.js";
import { InlineQueryManager } from "./4_inline_query_manager.js";
import { LinkPreviewManager } from "./4_link_preview_manager.js";
import { PollManager } from "./4_poll_manager.js";
import { StoryManager } from "./4_story_manager.js";
import { Composer } from "./5_composer.js";
export { restartAuth } from "./2_sign_in.js";
export declare const handleMigrationError: unique symbol;
declare const getPeer: unique symbol;
declare const mustGetPeer: unique symbol;
export interface ClientParams extends ClientPlainParams {
/** The storage provider to use. Defaults to memory storage. */
storage?: Storage;
/** App's API ID from [my.telegram.org/apps](https://my.telegram.org/apps). Required if no account was previously authorized. */
apiId?: number;
/** App's API hash from [my.telegram.org/apps](https://my.telegram.org/apps). Required if no account was previously authorized. */
apiHash?: string;
/** A parse mode to use when the `parseMode` parameter is not specified when sending or editing messages. Defaults to `ParseMode.None`. */
parseMode?: ParseMode;
/** The app_version parameter to be passed to initConnection. It is recommended that this parameter is changed if users are authorized. Defaults to _MTKruto_. */
appVersion?: string;
/** The device_model parameter to be passed to initConnection. The default varies by the current runtime. */
deviceModel?: string;
/** The client's language to be used for fetching translations. Defaults to the runtime's language or `"en"`. */
language?: string;
/** The client's platform to be used for fetching translations. Defaults to an empty string. */
platform?: string;
/** The system_lang_code parameter to be passed to initConnection. Defaults to the runtime's language or `"en"`. */
systemLangCode?: string;
/** The system_version parameter to be passed to initConnection. The default varies by the current runtime. */
systemVersion?: string;
/** Whether to use default handlers. Defaults to `true`. */
defaultHandlers?: boolean;
/** Whether outgoing messages should be sent as high-level updates. Outgoing bot business messages will never be sent. Defaults to `false`. */
outgoingMessages?: boolean;
/** Whether to guarantee that order-sensitive updates are delivered at least once before delivering the next ones. Useful mainly for clients providing a user interface à la Telegram Desktop. Defaults to `false`. */
guaranteeUpdateDelivery?: boolean;
/** Whether to ignore updates received while the client was not running. Defaults to `true` for bots and `false` for users. */
dropPendingUpdates?: boolean;
/**
* Whether to persist cache to the provided storage, and not memory. Defaults to `false`.
*
* Explicitly setting this option to `true` is highly recommended if:
*
* - User accounts are authorized.
* - Less memory usage is demanded.
* - The client does not usually have a large uptime.
*
* When the provided storage takes advantage of memory, nothing changes, even if set to `true`.
*/
persistCache?: boolean;
/** Whether to disable receiving updates. UpdateConnectionState and UpdateAuthorizationState will always be received. Defaults to `false`. */
disableUpdates?: boolean;
/** An auth string to automatically import. Can be overridden by a later importAuthString call. */
authString?: string;
/** The first DC to connect to. This is commonly used to decide whether to connect to test or production servers. It is not necessarily the DC that the client will directly connect to or is currently connected to. Defaults to the default initial DC. */
initialDc?: DC;
/** Whether perfect forward secrecy should be enabled. Defaults to `false`. */
isPerfectForwardSecrecyEnabled?: boolean;
}
export interface ClientManagers {
botInfoManager: BotInfoManager;
communityManager: CommunityManager;
businessConnectionManager: BusinessConnectionManager;
fileManager: FileManager;
giftCollectionManager: GiftCollectionManager;
managedBotManager: ManagedBotManager;
networkStatisticsManager: NetworkStatisticsManager;
paymentManager: PaymentManager;
reactionManager: ReactionManager;
storyAlbumManager: StoryAlbumManager;
takeoutManager: TakeoutManager;
translationsManager: TranslationsManager;
updateManager: UpdateManager;
accountManager: AccountManager;
messageManager: MessageManager;
secretChatManager: SecretChatManager;
stickerSetManager: StickerSetManager;
videoChatManager: VideoChatManager;
callbackQueryManager: CallbackQueryManager;
chatListManager: ChatListManager;
chatManager: ChatManager;
checklistManager: ChecklistManager;
contactManager: ContactManager;
forumManager: ForumManager;
giftManager: GiftManager;
inlineQueryManager: InlineQueryManager;
linkPreviewManager: LinkPreviewManager;
pollManager: PollManager;
storyManager: StoryManager;
}
/** An MTKruto client. */
export declare class Client extends Composer implements ClientGeneric {
#private;
get managers(): ClientManagers;
readonly storage: StorageOperations;
readonly messageStorage: StorageOperations;
readonly appVersion: string;
readonly deviceModel: string;
readonly language: string;
readonly platform: string;
readonly systemLangCode: string;
readonly systemVersion: string;
/** Constructs the client. */
constructor(params?: ClientParams);
get isConnected(): boolean;
get isDisconnected(): boolean;
[handleMigrationError](err: Migrate): Promise;
private [getPeer];
private [getPeer];
private [getPeer];
private [getPeer];
private [mustGetPeer];
private [mustGetPeer];
private [mustGetPeer];
private [mustGetPeer];
/**
* Connect the client.
*
* @method cn
*/
connect(): Promise;
/**
* Disconnect the client.
*
* @method cn
*/
disconnect(): Promise;
/**
* Start the client. Same as calling {@link Client.connect} followed by {@link Client.signIn}.
*
* @method cn
*/
start(params?: SignInParams): Promise;
/**
* Check whether a bot token is valid.
*
* @param botToken The bot token to check
* @returns The result of the check.
* @method au
*/
checkBotToken(botToken: string): Promise;
/**
* Check if a code entered by the user was the same as the verification code.
*
* @param code A code entered by the user.
* @method au
*/
checkCode(code: string): Promise;
/**
* Check whether a password entered by the user is the same as the account's password.
*
* @param password The password to check.
* @returns The result of the check.
* @method au
*/
checkPassword(password: string): Promise;
/**
* Export the auth string for the current authorization session.
*
* @method au
*/
exportAuthString(): Promise;
/**
* Import an auth string.
*
* @param authString The auth string to import.
* @method au
*/
importAuthString(authString: string): Promise;
/**
* Send a user verification code.
*
* @param phoneNumber The phone number to send the code to.
* @method au
*/
sendCode(phoneNumber: string): Promise;
/**
* Signs in using the provided parameters if not already signed in.
* If no parameters are provided, the credentials will be prompted in runtime.
*
* Notes:
* 1. Requires the `apiId` and `apiHash` parameters to be passed when constructing the client.
* 2. Reconnects the client to the appropriate DC in case of MIGRATE_X errors.
*
* @method au
*/
signIn(params?: SignInParams): Promise;
/**
* Sign out.
*
* @method au
*/
signOut(): Promise;
/**
* Sign up.
*
* @method au
* @param firstName The first name to use for the account that is to be created.
* @returns The user identifier of the new account.
*/
signUp(firstName: string, params?: SignUpParams): Promise;
/**
* Invoke a low-level function.
*
* @param function_ The function to invoke.
* @method ll
*/
invoke: {
? Api.ReturnType : T["_"] extends keyof Api.Functions ? Api.ReturnType extends never ? Api.ReturnType : never : never>(function_: T, params?: InvokeParams): Promise;
use: (handler: InvokeErrorHandler>) => void;
};
/**
* Get a channel or a supergroup's inputChannel. Useful when calling API functions directly.
*
* @param id The identifier of the channel or the supergroup.
* @method ll
*/
getInputChannel(id: ID): Promise;
/**
* Get a chat's inputPeer. Useful when calling API functions directly.
*
* @param id The identifier of a chat.
* @method ll
*/
getInputPeer(id: ID): Promise;
/**
* Get a user's inputUser. Useful when calling API functions directly.
*
* @param id The identifier of the user.
* @method ll
*/
getInputUser(id: ID): Promise;
/**
* Add a bot to the attachments menu. User-only.
*
* @method ac
* @param botId The identifier of the bot to add to the attachments menu.
*/
addBotToAttachmentsMenu(botId: ID, params?: AddBotToAttachmentsMenuParams): Promise;
/**
* Add music to profile. User-only.
*
* @method ac
* @param fileId The identifier of the audio file to add to profile.
*/
addMusicToProfile(fileId: string, params?: AddMusicToProfileParams): Promise;
/**
* Add a saved notification sound. User-only.
*
* @method ac
* @param sound The sound file to add.
*/
addSavedNotificationSound(sound: FileSource, params?: AddSavedNotificationSoundParams): Promise;
/**
* Allow a bot to set custom emoji status. User-only.
*
* @param botId The user identifier of the bot.
* @method ac
*/
allowBotToSetCustomEmojiStatus(botId: ID): Promise;
/**
* Allow unpaid messages from a user. User-only.
*
* @method ac
* @param userId The identifier of the user.
*/
allowUnpaidMessagesFromUser(userId: ID, params?: AllowUnpaidMessagesFromUserParams): Promise;
/**
* Block a user. User-only.
*
* @method ac
* @param userId The identifier of the user to block.
*/
blockUser(userId: ID): Promise;
/**
* Check the availability of a username. User-only.
*
* @method ac
* @param username The username to check.
* @returns Whether the username is available.
*/
checkUsername(username: string, params?: CheckUsernameParams): Promise;
/**
* Clear recent emoji statuses. User-only.
*
* @method ac
*/
clearRecentEmojiStatuses(): Promise;
/**
* Delete the current account. User-only.
*
* @method ac
* @param reason The reason for the deletion.
*/
deleteAccount(reason: string, params?: DeleteAccountParams): Promise;
/**
* Disable sponsored messages on the current user. User-only.
*
* @method ac
*/
disableSponsoredMessages(): Promise;
/**
* Disallow a bot to set custom emoji status. User-only.
*
* @param botId The user identifier of the bot.
* @method ac
*/
disallowBotToSetCustomEmojiStatus(botId: ID): Promise;
/**
* Disallow unpaid messages from a user. User-only.
*
* @method ac
* @param userId The identifier of the user.
*/
disallowUnpaidMessagesFromUser(userId: ID, params?: DisallowUnpaidMessagesFromUserParams): Promise;
/**
* Disconnect a connected website. User-only.
*
* @method ac
* @param id The identifier of a connected website.
*/
disconnectConnectedWebsite(id: string): Promise;
/**
* Disconnect all connected websites. User-only.
*
* @method ac
*/
disconnectConnectedWebsites(): Promise;
/**
* Enable sponsored messages on the current user. User-only.
*
* @method ac
*/
enableSponsoredMessages(): Promise;
/**
* Get the current account's TTL. User-only.
*
* @method ac
* @returns The current account's TTL in days.
*/
getAccountTtl(): Promise;
/**
* Get application configuration. User-only.
*
* @method ac
*/
getApplicationConfiguration(): Promise;
/**
* Get app support. User-only.
*
* @method ac
*/
getAppSupport(): Promise;
/**
* Get app support name. User-only.
*
* @method ac
*/
getAppSupportName(): Promise;
/**
* Get whether new chats from unknown users are archived and muted. User-only.
*
* @method ac
* @returns Whether new chats from unknown users are archived and muted.
*/
getArchiveAndMuteNewChatsFromUnknownUsers(): Promise;
/**
* Get the authorization sessions. User-only.
*
* @method ac
*/
getAuthorizationSessions(): Promise;
/**
* Get blocked users. User-only.
*
* @method ac
*/
getBlockedUsers(params?: GetBlockedUsersParams): Promise;
/**
* Get a business connection. Bot-only.
*
* @method ac
* @param id The identifier of the business connection.
* @cache
*/
getBusinessConnection(id: string): Promise;
/**
* Get connected websites. User-only.
*
* @method ac
*/
getConnectedWebsites(): Promise;
/**
* Get countries. User-only.
*
* @method ac
*/
getCountries(languageCode: string): Promise;
/**
* Get the country code for the current user based on its IP address. User-only.
*
* @method ac
*/
getCountryCode(): Promise;
/**
* Get gift privacy setting. User-only.
*
* @method ac
* @returns The current gift privacy setting.
*/
getGiftPrivacy(): Promise;
/**
* Get information on the currently authorized user.
*
* @method ac
* @returns Information on the currently authorized user.
*/
getMe(): Promise;
/**
* Get new chat privacy setting. User-only.
*
* @method ac
* @returns The current new chat privacy setting.
*/
getNewChatPrivacy(): Promise;
/**
* Get owned bots. User-only.
*
* @method ac
*/
getOwnedBots(): Promise;
/**
* Get the user account password's hint.
*
* @method ac
*/
getPasswordHint(): Promise;
/**
* Get a privacy setting. User-only.
*
* @param key The key of the privacy setting.
* @method ac
*/
getPrivacySetting(key: PrivacySettingKey): Promise;
/**
* Get a user's profile music. User-only.
*
* @method ac
* @param userId The identifier of the user whose profile music should be fetched.
*/
getProfileMusic(userId: ID, params?: GetProfileMusicParams): Promise