/** * 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 MaybePromise } from "../1_utilities.js"; import { Api } from "../2_tl.js"; import { type ChecklistChanged } from "./0_checklist_changed.js"; import { type Contact } from "./0_contact.js"; import { type Dice } from "./0_dice.js"; import { type Invoice } from "./0_invoice.js"; import { type Location } from "./0_location.js"; import { type RefundedPayment } from "./0_refunded_payment.js"; import { type SelfDestructOption } from "./0_self_destruct_option.js"; import { type Voice } from "./0_voice.js"; import { type Animation } from "./1_animation.js"; import { type Audio } from "./1_audio.js"; import { type ChatP, type PeerGetter } from "./1_chat_p.js"; import { type Document } from "./1_document.js"; import { type Giveaway } from "./1_giveaway.js"; import { type MessageReaction } from "./1_message_reaction.js"; import { type Photo } from "./1_photo.js"; import { type Sticker, type StickerSetNameGetter } from "./1_sticker.js"; import { type Venue } from "./1_venue.js"; import { type VideoNote } from "./1_video_note.js"; import { type Video } from "./1_video.js"; import { type MessageEntity } from "./2_message_entity.js"; import { type ReplyMarkup } from "./2_reply_markup.js"; import { type SuccessfulPayment } from "./2_successful_payment.js"; import { type User } from "./2_user.js"; import { type ChecklistItem } from "./3_checklist_item.js"; import { type ForwardHeader } from "./3_forward_header.js"; import { type Game } from "./3_game.js"; import { type PollOption } from "./3_poll_option.js"; import { type ReplyQuote } from "./3_reply_quote.js"; import { type Checklist } from "./4_checklist.js"; import { type Poll } from "./4_poll.js"; import { type GiftNonUpgradedInformation } from "./5_gift_non_upgraded_information.js"; import { type GiftUpgradedInformation } from "./5_gift_upgraded_information.js"; import { type LinkPreview } from "./5_link_preview.js"; /** * Properties shared between all message types. * @unlisted */ export interface _MessageBase { /** Whether the message is outgoing (sent by the current user). */ isOutgoing: boolean; /** The identifier of the message. */ id: number; /** The identifier of the message's thread. */ threadId?: number; /** The sender of the message. */ from: ChatP; /** The point in time when the message was sent. */ date: number; /** The chat where the message was sent to. */ chat: ChatP; /** A link to the message. */ link?: string; /** Information on the original message. */ forwardFrom?: ForwardHeader; /** Whether the message was sent in a topic thread. */ isTopicMessage: boolean; /** Whether the message is an automatic forward. */ isAutomaticForward?: boolean; /** The message that is being replied to. Not always available even if a message is being replied to. */ replyToMessage?: Message; /** The identifier of the message that is being replied to. */ replyToMessageId?: number; /** The reactions of the message. */ reactions?: MessageReaction[]; /** The part of the message that is being replied to. */ replyQuote?: ReplyQuote; /** The inline bot that was used to send this message. */ viaBot?: User; /** The point in time when the message's last edit was made. */ editDate?: number; /** Whether the contents of the message is protected. */ hasProtectedContent?: boolean; /** The identifier of the message's media group. */ mediaGroupId?: string; /** The signature of the message. */ authorSignature?: string; /** The member tag of the sender of the message. */ tag?: string; /** The number of times the message was viewed. */ views?: number; /** The number of times the message was forwarded. */ forwards?: number; /** The message's reply markup. */ replyMarkup?: ReplyMarkup; /** The identifier of a business connection that the message was sent in. */ businessConnectionId?: string; /** The number of the boosts made by the sender of the message. */ senderBoostCount?: number; /** The identifier of the business connection through which the message was sent. */ viaBusinessBot?: User; /** The identifier of the message effect that has been attached to the message. */ effectId?: string; /** Whether the message is scheduled. */ isScheduled?: boolean; /** The message's self-destruct preference. */ selfDestruct?: SelfDestructOption; /** If this message is a guest message, the user or chat that triggered it. */ for?: ChatP; } /** * Properties shared between media message types. * @unlisted */ export interface _MessageMediaBase extends _MessageBase { /** The media's caption. */ caption?: string; /** The entities of the media's caption. */ captionEntities?: MessageEntity[]; /** Whether the media is a spoiler. */ isSpoiler?: boolean; } /** * A text message. * @unlisted */ export interface MessageText extends _MessageBase { type: "text"; /** The text included in the message. */ text: string; /** The text's entities. */ entities: MessageEntity[]; /** The message's link preview. */ linkPreview?: LinkPreview; } /** * A message with a link preview only. * @unlisted */ export interface MessageLink extends _MessageBase { type: "link"; linkPreview: LinkPreview; } /** @unlisted */ export interface MessagePhoto extends _MessageMediaBase { type: "photo"; /** The photo included in the message. */ photo: Photo; } /** @unlisted */ export interface MessageLivePhoto extends _MessageMediaBase { type: "livePhoto"; /** The photo included in the message. */ photo: Photo; /** The video included in the message. */ video: Video; } /** * A document message. * @unlisted */ export interface MessageDocument extends _MessageMediaBase { type: "document"; /** The document included in the message. */ document: Document; } /** * A video message. * @unlisted */ export interface MessageVideo extends _MessageMediaBase { type: "video"; /** The video included in the message. */ video: Video; } /** * A sticker message. * @unlisted */ export interface MessageSticker extends _MessageBase { type: "sticker"; /** The sticker included in the message. */ sticker: Sticker; } /** * An animation message. Animations are GIFs or H.264/MPEG-4 AVC videos without sound. * @unlisted */ export interface MessageAnimation extends _MessageMediaBase { type: "animation"; /** The animation included in the message. */ animation: Animation; } /** * A voice message. * @unlisted */ export interface MessageVoice extends _MessageMediaBase { type: "voice"; /** The voice included in the message. */ voice: Voice; } /** * An audio message. * @unlisted */ export interface MessageAudio extends _MessageMediaBase { type: "audio"; /** The audio included in the message. */ audio: Audio; } /** * A dice message. * @unlisted */ export interface MessageDice extends _MessageBase { type: "dice"; /** The dice included in the message. */ dice: Dice; } /** * A video note message. * @unlisted */ export interface MessageVideoNote extends _MessageBase { type: "videoNote"; /** The video note included in the message. */ videoNote: VideoNote; } /** * A contact message. * @unlisted */ export interface MessageContact extends _MessageBase { type: "contact"; /** The contact included in the message. */ contact: Contact; } /** * A game message. * @unlisted */ export interface MessageGame extends _MessageBase { type: "game"; /** The game included in the message. */ game: Game; } /** * A poll message. * @unlisted */ export interface MessagePoll extends _MessageBase { type: "poll"; /** The poll included in the message. */ poll: Poll; } /** * A checklist message. * @unlisted */ export interface MessageChecklist extends _MessageBase { type: "checklist"; /** The checklist included in the message. */ checklist: Checklist; } /** * An invoice message. * @unlisted */ export interface MessageInvoice extends _MessageBase { type: "invoice"; /** The invoice included in the message. */ invoice: Invoice; } /** * A venue message. * @unlisted */ export interface MessageVenue extends _MessageBase { type: "venue"; /** The venue included in the message. */ venue: Venue; } /** * A location message. * @unlisted */ export interface MessageLocation extends _MessageBase { type: "location"; /** The location included in the message. */ location: Location; } /** * A message that is received when new members join a chat. * @unlisted */ export interface MessageNewChatMembers extends _MessageBase { type: "newChatMembers"; /** The new members of the chat. */ newChatMembers: User[]; } /** * A message that is received when a member leaves a chat. * @unlisted */ export interface MessageLeftChatMember extends _MessageBase { type: "leftChatMember"; /** The member who left the chat. */ leftChatMember: User; } /** * A message that is received when a chat's title is changed. * @unlisted */ export interface MessageNewChatTitle extends _MessageBase { type: "newChatTitle"; /** The new title of the chat. */ newChatTitle: string; } /** * A message that is received when a chat's photo is changed. * @unlisted */ export interface MessageNewChatPhoto extends _MessageBase { type: "newChatPhoto"; /** The new photo of the chat */ newChatPhoto: Photo; } /** * A message that is received when a chat's photo is removed. * @unlisted */ export interface MessageDeletedChatPhoto extends _MessageBase { type: "deletedChatPhoto"; } /** * A message that is received by user accounts when a group is created. * While bots don't receive them, they are able to see them if someone replies to them. * @unlisted */ export interface MessageGroupCreated extends _MessageBase { type: "groupCreated"; /** The initial members of the group. */ newChatMembers: User[]; } /** * A message that is received by user accounts when a supergroup is created. * While bots don't receive them, they are able to see them if someone replies to them. * @unlisted */ export interface MessageSupergroupCreated extends _MessageBase { type: "supergroupCreated"; } /** * A message that is received by user accounts when a channel is created. * While bots don't receive them, they are able to see them if someone replies to them. * @unlisted */ export interface MessageChannelCreated extends _MessageBase { type: "channelCreated"; } /** * A message that is received when a chat's auto-delete timer is changed. * @unlisted */ export interface MessageAutoDeleteTimerChanged extends _MessageBase { type: "newAutoDeleteTime"; /** The new auto-delete time in seconds. */ newAutoDeleteTime: number; } /** * A message that is received when a supergroup is created as a result of a group migration. * @unlisted */ export interface MessageChatMigratedTo extends _MessageBase { type: "chatMigratedTo"; /** The supergroup's ID. */ chatMigratedTo: number; } /** * A message that is received when a group is migrated to a supergroup. * @unlisted */ export interface MessageChatMigratedFrom extends _MessageBase { type: "chatMigratedFrom"; /** The group's ID. */ chatMigratedFrom: number; } /** * A message that is received when a message is pinned in a chat. * @unlisted */ export interface MessagePinnedMessage extends _MessageBase { type: "pinnedMessage"; /** The message that was pinned. */ pinnedMessage: Message; } /** * A message that is received when a bot account receives a shared user. * @unlisted */ export interface MessageUserShared extends _MessageBase { type: "userShared"; userShared: { requestId: number; userId: number; }; } /** * A message that is received when a bot is allowed to message a user. * @unlisted */ export interface MessageWriteAccessAllowed extends _MessageBase { type: "writeAccessAllowed"; writeAccessAllowed: { miniAppName?: string; }; } /** * A message that is received when a new topic is created in a forum. * @unlisted */ export interface MessageForumTopicCreated extends _MessageBase { type: "forumTopicCreated"; /** Information on the created forum topic. */ forumTopicCreated: { name: string; color: number; customEmojiId?: string; }; } /** * A message that is received when a topic is edited in a forum. * @unlisted */ export interface MessageForumTopicEdited extends _MessageBase { type: "forumTopicEdited"; forumTopicEdited: { name: string; customEmojiId?: string; }; } /** * A message that is received when a topic is closed in a forum. * @unlisted */ export interface MessageForumTopicClosed extends _MessageBase { type: "forumTopicClosed"; } /** * A message that is received when a topic is reopened in a forum. * @unlisted */ export interface MessageForumTopicReopened extends _MessageBase { type: "forumTopicReopened"; } /** * A message that is received when a video chat is scheduled in a chat. * @unlisted */ export interface MessageVideoChatScheduled extends _MessageBase { type: "videoChatScheduled"; /** Information on the scheduled video chat. */ videoChatScheduled: { startDate: number; }; } /** * A message that is received when a video chat is started in a chat. * @unlisted */ export interface MessageVideoChatStarted extends _MessageBase { type: "videoChatStarted"; } /** * A message that is received when a video chat is ended in a chat. * @unlisted */ export interface MessageVideoChatEnded extends _MessageBase { type: "videoChatEnded"; /** Information on the ended video chat. */ videoChatEnded: { duration: number; }; } /** * A message that is received when a giveaway is started in a chat. * @unlisted */ export interface MessageGiveaway extends _MessageBase { type: "giveaway"; /** Information on the giveaway. */ giveaway: Giveaway; } /** * An unsupported message. * @unlisted */ export interface MessageUnsupported extends _MessageBase { type: "unsupported"; } /** * A payment was successfully received. Bot-only. * @unlisted */ export interface MessageSuccessfulPayment extends _MessageBase { type: "successfulPayment"; /** Information on the successful payment. */ successfulPayment: SuccessfulPayment; } /** * A payment was successfully refunded. Bot-only. * @unlisted */ export interface MessageRefundedPayment extends _MessageBase { type: "refundedPayment"; /** Information on the refunded payment. */ refundedPayment: RefundedPayment; } /** * A checklist was changed. * @unlisted */ export interface MessageChecklistChanged extends _MessageBase { type: "checklistChanged"; /** The checklist's changes. */ checklistChanged: ChecklistChanged; } /** * A checklist was extended. * @unlisted */ export interface MessageChecklistExtended extends _MessageBase { type: "checklistExtended"; /** The checklist's new items. */ checklistExtended: ChecklistItem[]; } /** * An action related to a non-upgraded gift. * @unlisted */ export interface MessageGiftNonUpgraded extends _MessageBase { type: "giftNonUpgraded"; /** Information on the non-upgraded gift. */ giftNonUpgraded: GiftNonUpgradedInformation; } /** * An action related an upgraded gift. * @unlisted */ export interface MessageGiftUpgraded extends _MessageBase { type: "giftUpgraded"; /** Information on the upgraded gift. */ giftUpgraded: GiftUpgradedInformation; } /** * An option was added to a poll. * @unlisted */ export interface MessagePollOptionAdded extends _MessageBase { type: "pollOptionAdded"; /** The option that was added. */ pollOptionAdded: PollOption; } /** * An option was removed from a poll. * @unlisted */ export interface MessagePollOptionRemoved extends _MessageBase { type: "pollOptionRemoved"; /** The option that was added. */ pollOptionRemoved: PollOption; } /** @unlisted */ export interface MessageTypes { text: MessageText; link: MessageLink; photo: MessagePhoto; livePhoto: MessageLivePhoto; document: MessageDocument; video: MessageVideo; sticker: MessageSticker; animation: MessageAnimation; voice: MessageVoice; audio: MessageAudio; dice: MessageDice; videoNote: MessageVideoNote; contact: MessageContact; game: MessageGame; poll: MessagePoll; checklist: MessageChecklist; invoice: MessageInvoice; venue: MessageVenue; location: MessageLocation; newChatMembers: MessageNewChatMembers; leftChatMember: MessageLeftChatMember; newChatTitle: MessageNewChatTitle; newChatPhoto: MessageNewChatPhoto; deletedChatPhoto: MessageDeletedChatPhoto; groupCreated: MessageGroupCreated; supergroupCreated: MessageSupergroupCreated; channelCreated: MessageChannelCreated; newAutoDeleteTime: MessageAutoDeleteTimerChanged; chatMigratedTo: MessageChatMigratedTo; chatMigratedFrom: MessageChatMigratedFrom; pinnedMessage: MessagePinnedMessage; userShared: MessageUserShared; writeAccessAllowed: MessageWriteAccessAllowed; forumTopicCreated: MessageForumTopicCreated; forumTopicEdited: MessageForumTopicEdited; forumTopicClosed: MessageForumTopicClosed; forumTopicReopened: MessageForumTopicReopened; videoChatScheduled: MessageVideoChatScheduled; videoChatStarted: MessageVideoChatStarted; videoChatEnded: MessageVideoChatEnded; giveaway: MessageGiveaway; unsupported: MessageUnsupported; successfulPayment: MessageSuccessfulPayment; refundedPayment: MessageRefundedPayment; checklistChanged: MessageChecklistChanged; checklistExtended: MessageChecklistExtended; giftNonUpgraded: MessageGiftNonUpgraded; giftUpgraded: MessageGiftUpgraded; pollOptionAdded: MessagePollOptionAdded; pollOptionRemoved: MessagePollOptionRemoved; } export declare const messageTypes: (keyof MessageTypes)[]; export declare function assertMessageType(message: Message, type: T): MessageTypes[T]; /** Any type of message. */ export type Message = MessageText | MessageLink | MessagePhoto | MessageLivePhoto | MessageDocument | MessageVideo | MessageSticker | MessageAnimation | MessageVoice | MessageAudio | MessageDice | MessageVideoNote | MessageContact | MessageGame | MessagePoll | MessageChecklist | MessageInvoice | MessageVenue | MessageLocation | MessageNewChatMembers | MessageLeftChatMember | MessageNewChatTitle | MessageNewChatPhoto | MessageDeletedChatPhoto | MessageGroupCreated | MessageSupergroupCreated | MessageChannelCreated | MessageAutoDeleteTimerChanged | MessageChatMigratedTo | MessageChatMigratedFrom | MessagePinnedMessage | MessageUserShared | MessageWriteAccessAllowed | MessageForumTopicCreated | MessageForumTopicEdited | MessageForumTopicClosed | MessageForumTopicReopened | MessageVideoChatScheduled | MessageVideoChatStarted | MessageVideoChatEnded | MessageGiveaway | MessageUnsupported | MessageSuccessfulPayment | MessageRefundedPayment | MessageChecklistChanged | MessageChecklistExtended | MessageGiftNonUpgraded | MessageGiftUpgraded | MessagePollOptionAdded | MessagePollOptionRemoved; /** @unlisted */ export interface MessageGetter { (chatId: number, messageId: number): MaybePromise; } type Message_MessageGetter = MessageGetter | null; export declare function constructMessage(message_: Api.Message, getPeer: PeerGetter, getMessage: Message_MessageGetter, getStickerSetName: StickerSetNameGetter, getReply_?: boolean, business?: { connectionId: string; replyToMessage?: Api.Message; }, poll?: Api.poll, pollResults?: Api.pollResults): Promise; export {}; //# sourceMappingURL=6_message.d.ts.map