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)

Implements

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 action(): MessageAction
  • Message action. null for non-service messages or for unsupported events.

    For unsupported events, use .raw.action directly.

    Returns MessageAction

  • 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 chat(): Peer
  • Conversation the message belongs to

    Returns Peer

  • get date(): Date
  • Date when the message was sent

    Returns Date

  • get editDate(): null | Date
  • Date when the message was last edited

    Returns null | Date

  • get effectId(): null | Long
  • If this message was sent with a message effect, ID of the effect

    Returns null | Long

  • get entities(): readonly MessageEntity[]
  • Message text/caption entities (may be empty)

    Returns readonly MessageEntity[]

  • get factCheck(): null | FactCheck
  • Information about fact-check added to the message, if any

    Returns null | FactCheck

  • get forward(): null | MessageForwardInfo
  • If this message is a forward, contains info about it.

    Returns null | MessageForwardInfo

  • get forwards(): null | number
  • 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 null | number

  • get groupedId(): null | Long
  • Multiple media messages with the same grouped ID indicate an album or media group

    null for service messages and non-grouped messages

    Returns null | Long

  • get groupedIdUnique(): null | string
  • Same as groupedId, but is globally unique across chats.

    Returns null | string

  • get hasUnreadMedia(): boolean
  • Whether there are unread media attachments in this message

    Returns boolean

  • get hideEditMark(): boolean
  • Whether the message should be considered unedited, even if editDate ≠ null

    Returns boolean

  • get id(): number
  • Unique message identifier inside this chat

    Returns number

  • 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 isChannelPost(): boolean
  • Whether this is a broadcast channel post

    Returns boolean

  • get isContentProtected(): boolean
  • Whether this message has content protection (i.e. disabled forwards)

    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 isMention(): boolean
  • Whether this message contains mention of the current user

    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

  • get isPinned(): boolean
  • Whether the message is pinned in the current chat

    Returns boolean

  • get isService(): boolean
  • Whether this message is a service message

    Returns boolean

  • get isSilent(): boolean
  • Whether this is a silent message (no notification triggered)

    Returns boolean

  • get isTopicMessage(): boolean
  • Whether this message is in a forum topic

    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 markup(): null | ReplyMarkup
  • Reply markup provided with this message, if any.

    Returns null | ReplyMarkup

  • get media(): MessageMedia
  • Message media. null for text-only and service messages and for unsupported media types.

    For unsupported media types, use .raw.media directly.

    Returns MessageMedia

  • get quickReplyShortcutId(): null | number
  • 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 null | number

  • get reactions(): null | MessageReactions
  • Reactions added to this message, if any

    Returns null | MessageReactions

  • get replies(): null | MessageRepliesInfo
  • Information about comments (for channels) or replies (for groups)

    Returns null | MessageRepliesInfo

  • get replyToMessage(): null | RepliedMessageInfo
  • For replies, information about the that is being replied to.

    Mutually exclusive with replyToStory

    Returns null | RepliedMessageInfo

  • get replyToStory(): null | RawMessageReplyStoryHeader
  • For replies, information about the story that is being replied to

    Mutually exclusive with replyToMessage

    Returns null | RawMessageReplyStoryHeader

  • 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 senderBoostCount(): number
  • Number of boosts applied to this chat by the sender

    Returns number

  • get signature(): null | string
  • For channel posts with signatures enabled, name of the post author

    Returns null | string

  • get text(): string
  • Message text or media caption.

    Empty string for service messages (you should handle i18n yourself)

    Returns string

  • get textWithEntities(): TextWithEntities
  • Returns TextWithEntities

  • get ttlPeriod(): null | number
  • TTL period of the message, in seconds.

    Returns null | number

  • get viaBot(): null | User
  • If this message is generated from an inline query, information about the bot which generated it

    Returns null | User

  • get viaBusinessBot(): null | User
  • 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 null | User

  • get videoProcessingPending(): boolean
  • Whether this message has a video that is still being processed

    Returns boolean

  • get views(): null | number
  • For channel posts, number of views

    null for service messages and non-post messages.

    Returns null | number

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 text as a comment to this message

    Parameters

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

    Returns Promise<Message>

  • Delete this message (message group)

    Parameters

    Returns Promise<void>

  • Edit this message

    Parameters

    • params: OmitInputMessageId<
          InputMessageId & {
              businessConnectionId?: string;
              disableWebPreview?: boolean;
              invertMedia?: boolean;
              media?: InputMediaLike | undefined;
              progressCallback?: (uploaded: number, total: number) => void;
              replyMarkup?: ReplyMarkup | undefined;
              scheduleDate?: number | Date;
              shouldDispatch?: true;
              text?: InputText | undefined;
          },
      >

    Returns Promise<Message>

  • Get complete information about chat

    Learn more: Incomplete peers

    Returns Promise<Peer>

  • Get complete information about sender

    Learn more: Incomplete peers

    Returns Promise<Peer>

  • Get all custom emojis contained in this message (message group), if any

    Returns Promise<Sticker[]>

  • If this is a channel post, get its automatic forward in the discussion group

    Returns Promise<null | Message>

  • Get a message that this message is a reply to

    Returns Promise<null | Message>

  • Pin this message

    Parameters

    • Optionalparams: OmitInputMessageId<
          InputMessageId & {
              bothSides?: boolean;
              notify?: boolean;
              shouldDispatch?: true;
          },
      >

    Returns Promise<null | 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>

  • React to this message

    Parameters

    • params: OmitInputMessageId<
          InputMessageId & {
              big?: boolean;
              emoji?: MaybeArray<InputReaction> | null | undefined;
              shouldDispatch?: true;
          },
      >

    Returns Promise<null | 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[]>

  • Send a text message in reply to this message

    Parameters

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

    Returns Promise<Message>

  • Unpin this message

    Returns Promise<void>