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 full)

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 canBeForwarded(): boolean
  • Whether this message can be forwarded

    false for service mesasges and private restricted chats/chanenls

    Returns boolean

  • 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 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(): 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 sender(): Peer
  • Message sender.

    Usually is a User, but can be a Chat 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 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

Methods

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

    Parameters

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

    Returns Promise<Message[]>

  • Send a media group as a comment to this message

    Parameters

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

    Returns Promise<Message[]>

  • 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>

  • 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)[];
      }

    Returns Promise<Message[]>

  • Send a media group in reply to this message

    Parameters

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

    Returns Promise<Message[]>