Documentation - v0.27.1
    Preparing search index...

    Context of a message-related update.

    This is a subclass of Message, so all fields of the message are available.

    For message groups, own fields are related to the last message in the group. To access all messages, use MessageContext#messages.

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    _name: "new_message" = ...
    _peers: PeersIndex
    isMessageGroup: boolean

    Whether this update is about a message group

    isScheduled: boolean = false

    Whether the message is scheduled. If it is, then its date is set to future.

    messages: MessageContext[]

    List of messages in the message group.

    For other updates, this is a list with a single element (this).

    Raw TL object.

    Accessors

    • get canBeForwarded(): boolean

      Whether this message can be forwarded

      false for service mesasges and private restricted chats/chanenls

      Returns boolean

    • get canBeReacted(): boolean

      Whether reactions are possible on this message

      Note: for non-service message this is always true, regardless if the message can actually be reacted to.

      Returns boolean

    • get forwards(): number | null

      For channel posts, number of forwards

      null for service messages and non-post messages, or if the current user is not an admin in the channel

      Returns number | null

    • get invertMedia(): boolean

      If set, any eventual webpage preview should be shown on top of the message instead of at the bottom.

      Returns boolean

    • get isAutomaticForward(): boolean

      Whether the message is a channel post that was automatically forwarded to the connected discussion group

      Returns boolean

    • get isForwardedPremiumMedia(): boolean

      Whether this is a premium media (e.g. >2gb file or fullscreen sticker) that was forwarded without author by a non-premium user

      Returns boolean

    • get isFromOffline(): boolean

      Whether the message was sent by an implicit action, for example, as an away or a greeting business message, or as a scheduled message

      Returns boolean

    • get isFromScheduled(): boolean

      Whether this message was automatically sent from a scheduled message.

      Note: for messages sent by other users, this is always false.

      Returns boolean

    • get isOutgoing(): boolean

      Whether the message is incoming or outgoing:

      • Messages received from other chats are incoming (outgoing = false)
      • Messages sent by you to other chats are outgoing (outgoing = true)
      • Messages to yourself (i.e. Saved Messages) are incoming (outgoing = false)

      Returns boolean

    • Generated permalink to this message, only for groups and channels

      Returns string

      MtArgumentError In case the chat does not support message links

    • get quickReplyShortcutId(): number | null

      If non-null, this message is not actually sent, and is instead inside a group of "quick reply" messages under the given shortcut ID

      Returns number | null

    • get scheduleRepeatPeriod(): number | null

      If this message is a scheduled message, the repeat period in seconds

      Returns number | null

    • get sender(): Peer

      Message sender.

      Usually is a User, but can be a Peer in case the message was sent by an anonymous admin, anonymous premium user, or if the message is a forwarded channel post.

      If the message was sent by an anonymous admin, sender will equal to chat.

      If the message is a forwarded channel post, sender is the channel itself.

      Returns Peer

    • get suggestedPaid(): "stars" | "ton" | null

      If this message was a paid suggested post, the type of payment (either stars or ton)

      Returns "stars" | "ton" | null

    • get viaBusinessBot(): User | null

      If this message was sent by a business bot on behalf of sender, information about the business bot.

      Note: only available to the business account and the bot itself.

      Returns User | null

    Methods

    • Send a media to the same chat (and topic, if applicable) as a given message

      Parameters

      • ...params: [
            media: string
            | InputMediaLike,
            params?: CommonSendParams & {
                caption?: InputText;
                invert?: boolean;
                progressCallback?: (uploaded: number, total: number) => void;
                replyMarkup?: ReplyMarkup;
            },
        ]

      Returns Promise<Message>

    • Send a media group to the same chat (and topic, if applicable) as a given message

      Parameters

      • ...params: [
            medias: (string | InputMediaLike)[],
            params?: CommonSendParams & {
                invertMedia?: boolean;
                progressCallback?: (
                    index: number,
                    uploaded: number,
                    total: number,
                ) => void;
            },
        ]

      Returns Promise<Message[]>

    • Send a text message to the same chat (and topic, if applicable) as a given message

      Parameters

      • ...params: [
            text: InputText,
            params?: CommonSendParams & {
                disableWebPreview?: boolean;
                invertMedia?: boolean;
                replyMarkup?: ReplyMarkup;
            },
        ]

      Returns Promise<Message>

    • Send a media as a comment to this message

      Parameters

      • ...params: [
            media: string
            | InputMediaLike,
            params?: CommonSendParams & {
                caption?: InputText;
                invert?: boolean;
                progressCallback?: (uploaded: number, total: number) => void;
                replyMarkup?: ReplyMarkup;
            },
        ]

      Returns Promise<Message>

    • Send a media group as a comment to this message

      Parameters

      • ...params: [
            medias: (string | InputMediaLike)[],
            params?: CommonSendParams & {
                invertMedia?: boolean;
                progressCallback?: (
                    index: number,
                    uploaded: number,
                    total: number,
                ) => void;
            },
        ]

      Returns Promise<Message[]>

    • Send a media in reply to this message

      Parameters

      • params: Omit<
            CommonSendParams & {
                caption?: InputText;
                invert?: boolean;
                progressCallback?: (uploaded: number, total: number) => void;
                replyMarkup?: ReplyMarkup;
            },
            "quoteText"
            | "quoteEntities",
        > & { end: number; start: number; toChatId?: InputPeerLike } & {
            media: string | InputMediaLike;
        }
        • end: number

          Index of the last character to quote (exclusive)

        • start: number

          Index of the first character to quote (inclusive)

        • OptionaltoChatId?: InputPeerLike

          Destination chat ID, username, phone, "me" or "self"

          message.chat

      Returns Promise<Message>

    • Send a media group in reply to this message

      Parameters

      • params: Omit<
            CommonSendParams & {
                invertMedia?: boolean;
                progressCallback?: (
                    index: number,
                    uploaded: number,
                    total: number,
                ) => void;
            },
            "quoteText"
            | "quoteEntities",
        > & { end: number; start: number; toChatId?: InputPeerLike } & {
            medias: (string | InputMediaLike)[];
        }
        • end: number

          Index of the last character to quote (exclusive)

        • start: number

          Index of the first character to quote (inclusive)

        • OptionaltoChatId?: InputPeerLike

          Destination chat ID, username, phone, "me" or "self"

          message.chat

      Returns Promise<Message[]>

    • Send a text message in reply to this message

      Parameters

      • params: Omit<
            CommonSendParams & {
                disableWebPreview?: boolean;
                invertMedia?: boolean;
                replyMarkup?: ReplyMarkup;
            },
            "quoteText"
            | "quoteEntities",
        > & { end: number; start: number; toChatId?: InputPeerLike } & {
            text: InputText;
        }
        • end: number

          Index of the last character to quote (exclusive)

        • start: number

          Index of the first character to quote (inclusive)

        • OptionaltoChatId?: InputPeerLike

          Destination chat ID, username, phone, "me" or "self"

          message.chat

      Returns Promise<Message>

    • Send a media in reply to this message

      Parameters

      • ...params: [
            media: string
            | InputMediaLike,
            params?: CommonSendParams & {
                caption?: InputText;
                invert?: boolean;
                progressCallback?: (uploaded: number, total: number) => void;
                replyMarkup?: ReplyMarkup;
            },
        ]

      Returns Promise<Message>

    • Send a media group in reply to this message

      Parameters

      • ...params: [
            medias: (string | InputMediaLike)[],
            params?: CommonSendParams & {
                invertMedia?: boolean;
                progressCallback?: (
                    index: number,
                    uploaded: number,
                    total: number,
                ) => void;
            },
        ]

      Returns Promise<Message[]>