telegramsjs
    Preparing search index...

    Class MessageOrigin

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    authorSignature?: string

    Signature of the original post author

    chat?: Chat

    Channel chat to which the message was originally sent

    createdUnixTime: number

    Date the message was sent originally in Unix time

    id?: string

    Unique message identifier inside this chat. In specific instances (e.g., message containing a video sent to a big chat), the server might automatically schedule a message instead of sending it immediately. In such cases, this field will be 0 and the relevant message will be unusable until it is actually sent

    senderChat?: Chat

    Chat that sent the message originally

    senderUser?: User

    User that sent the message originally

    username?: string

    Name of the user that sent the message originally

    Accessors

    • get createdAt(): Date

      Date the message was sent originally

      Returns Date

    • get createdTimestamp(): number

      Return the timestamp message was sent originally, in milliseconds

      Returns number

    Methods

    • Protected

      Creates a clone of the current instance

      Returns Base

      A clone of the current instance

    • Parameters

      • data: MessageOrigin

        Data about the describes the origin of a message

      Returns MessageOrigin

    • Protected

      Updates the current instance with new data and returns a clone of the updated instance

      Parameters

      • data: Record<string, any>

        The data to update the instance with

      Returns Base

      A clone of the updated instance

    • Use this method to approve a suggested post in a direct messages chat. The bot must have the 'can_post_messages' administrator right in the corresponding channel chat.

      Parameters

      • OptionalsendDate: number

        Point in time (Unix timestamp) when the post is expected to be published; omit if the date has already been specified when the suggested post was created. If specified, then the date must be not more than 2678400 seconds (30 days) in the future.

      Returns Promise<true>

      Returns True on success.

    • Use this method to copy messages of any kind. Service messages, paid media messages, giveaway messages, giveaway winners messages, and invoice messages can't be copied. A quiz poll can be copied only if the value of the field correct_option_id is known to the bot. The method is analogous to the method forwardMessage, but the copied message doesn't have a link to the original message.

      Parameters

      • chatId: string | number

        Unique identifier for the target chat or username of the target channel (in the format @channelusername)

      • Optionaloptions: Omit<
            {
                caption?: string;
                captionEntities?: MessageEntity[];
                chatId: string
                | number;
                directMessagesTopicId?: number;
                disableNotification?: boolean;
                fromChatId: string | number;
                messageId: string | number;
                messageThreadId?: string | number;
                parseMode?: ParseMode;
                protectContent?: boolean;
                replyMarkup?:
                    | InlineKeyboardMarkup
                    | ForceReply
                    | ReplyKeyboardMarkup
                    | ReplyKeyboardRemove;
                replyParameters?: ReplyParameters;
                showCaptionAboveMedia?: boolean;
                suggestedPostParameters?: SuggestedPostParameters;
                videoStartTimestamp?: number;
            },
            "chatId"
            | "messageId"
            | "fromChatId",
        >

        out parameters

      Returns Promise<number>

      Returns the message id of the sent message on success.

    • Use this method to decline a suggested post in a direct messages chat. The bot must have the 'can_manage_direct_messages' administrator right in the corresponding channel chat.

      Parameters

      • Optionalcomment: string

        Comment for the creator of the suggested post; 0-128 characters.

      Returns Promise<true>

      Returns True on success.

    • Use this method to delete a message, including service messages, with the following limitations:

      • A message can only be deleted if it was sent less than 48 hours ago.
      • Service messages about a supergroup, channel, or forum topic creation can't be deleted.
      • A dice message in a private chat can only be deleted if it was sent more than 24 hours ago.
      • Bots can delete outgoing messages in private chats, groups, and supergroups.
      • Bots can delete incoming messages in private chats.
      • Bots granted can_post_messages permissions can delete outgoing messages in channels.
      • If the bot is an administrator of a group, it can delete any message there.
      • If the bot has can_delete_messages administrator right in a supergroup or a channel, it can delete any message there.
      • If the bot has can_manage_direct_messages administrator right in a channel, it can delete any message in the corresponding direct messages chat.

      Returns Promise<true>

      Returns True on success.

    • Use this method to edit text and game messages.

      Parameters

      • text: string

        New text of the message, 1-4096 characters after entities parsing

      • Optionaloptions: Omit<
            {
                businessConnectionId?: string;
                chatId?: string
                | number;
                entities?: MessageEntity[];
                inlineMessageId?: string | number;
                linkPreviewOptions?: LinkPreviewOptions;
                messageId?: string | number;
                parseMode?: ParseMode;
                replyMarkup?: InlineKeyboardMarkup;
                text: string;
            },
            "text"
            | "chatId"
            | "messageId",
        >

        out parameters

      Returns Promise<
          | true
          | Message & {
              content: string;
              editedAt: Date;
              editedTimestamp: number;
              editedUnixTime: number;
          },
      >

      On success, if the edited message is not an inline message, the edited Message is returned, otherwise True is returned. Note that business messages that were not sent by the bot and do not contain an inline keyboard can only be edited within 48 hours from the time they were sent.

    • Use this method to edit captions of messages.

      Parameters

      • Optionalcaption: string

        New caption of the message, 0-1024 characters after entities parsing

      • Optionaloptions: Omit<
            {
                businessConnectionId?: string;
                caption?: string;
                captionEntities?: MessageEntity[];
                chatId?: string
                | number;
                inlineMessageId?: string | number;
                messageId?: string | number;
                parseMode?: ParseMode;
                replyMarkup?: InlineKeyboardMarkup;
                showCaptionAboveMedia?: boolean;
            },
            "caption"
            | "chatId"
            | "messageId",
        >

        out parameters

      Returns Promise<
          | true
          | Message & {
              caption?: string;
              editedAt: Date;
              editedTimestamp: number;
              editedUnixTime: number;
          },
      >

      On success, if the edited message is not an inline message, the edited Message is returned, otherwise True is returned. Note that business messages that were not sent by the bot and do not contain an inline keyboard can only be edited within 48 hours from the time they were sent.

    • Use this method to edit a checklist on behalf of a connected business account.

      Parameters

      • businessConnectionId: string

        Unique identifier of the business connection on behalf of which the message will be sent.

      • checklist: InputChecklist

        An object for the new checklist.

      • Optionaloptions: Omit<
            {
                businessConnectionId: string;
                chatId: string
                | number;
                checklist: InputChecklist;
                messageId: string | number;
                replyMarkup?: InlineKeyboardMarkup;
            },
            "checklist"
            | "chatId"
            | "businessConnectionId"
            | "messageId",
        >

        out parameters.

      Returns Promise<Message & { checklist: Checklist }>

      On success, the edited Message is returned.

    • Use this method to edit live location messages. A location can be edited until its live_period expires or editing is explicitly disabled by a call to stopMessageLiveLocation.

      Parameters

      • latitude: number

        Latitude of new location

      • longitude: number

        Longitude of new location

      • Optionaloptions: Omit<
            {
                businessConnectionId?: string;
                chatId?: string
                | number;
                heading?: number;
                horizontalAccuracy?: number;
                inlineMessageId?: string | number;
                latitude: number;
                livePeriod?: number;
                longitude: number;
                messageId?: string | number;
                proximityAlertRadius?: number;
                replyMarkup?: InlineKeyboardMarkup;
            },
            "chatId"
            | "messageId"
            | "latitude"
            | "longitude",
        >

        out parameters

      Returns Promise<
          | true
          | Message & {
              editedAt: Date;
              editedTimestamp: number;
              editedUnixTime: number;
              location: Location;
          },
      >

      On success, if the edited message is not an inline message, the edited Message is returned, otherwise True is returned.

    • Use this method to edit animation, audio, document, photo, video messages or to add media to text messages. If a message is part of a message album, then it can be edited only to an audio for audio albums, only to a document for document albums and to a photo or a video otherwise. When an inline message is edited, a new file can't be uploaded; use a previously uploaded file via its file_id or specify a URL.

      Parameters

      • media: InputMedia

        An object for a new media content of the message

      • Optionaloptions: Omit<
            {
                businessConnectionId?: string;
                chatId?: string
                | number;
                inlineMessageId?: string | number;
                media: InputMedia;
                messageId?: string | number;
                replyMarkup?: InlineKeyboardMarkup;
            },
            "media"
            | "chatId"
            | "messageId",
        >

        out parameters

      Returns Promise<
          | true
          | Message & {
              editedAt: Date;
              editedTimestamp: number;
              editedUnixTime: number;
          },
      >

      On success, if the edited message is not an inline message, the edited Message is returned, otherwise True is returned. Note that business messages that were not sent by the bot and do not contain an inline keyboard can only be edited within 48 hours from the time they were sent.

    • Use this method to edit only the reply markup of messages.

      Parameters

      • replyMarkup: InlineKeyboardMarkup

        An object for an inline keyboard

      • Optionaloptions: Omit<
            {
                businessConnectionId?: string;
                chatId?: string
                | number;
                inlineMessageId?: string | number;
                messageId?: string | number;
                replyMarkup?: InlineKeyboardMarkup;
            },
            "media"
            | "chatId"
            | "messageId",
        >

        out parameters

      Returns Promise<
          | true
          | Message & {
              editedAt: Date;
              editedTimestamp: number;
              editedUnixTime: number;
          },
      >

      On success, if the edited message is not an inline message, the edited Message is returned, otherwise True is returned. Note that business messages that were not sent by the bot and do not contain an inline keyboard can only be edited within 48 hours from the time they were sent.

    • Use this method to forward messages of any kind. Service messages and messages with protected content can't be forwarded.

      Parameters

      • chatId: string | number

        Unique identifier for the target chat or username of the target channel (in the format @channelusername)

      • Optionaloptions: Omit<
            {
                chatId: string
                | number;
                directMessagesTopicId?: number;
                disableNotification?: boolean;
                fromChatId: string | number;
                messageId: string | number;
                messageThreadId?: string | number;
                protectContent?: boolean;
                suggestedPostParameters?: SuggestedPostParameters;
                videoStartTimestamp?: number;
            },
            "chatId"
            | "messageId"
            | "fromChatId",
        >

        out parameters

      Returns Promise<Message>

      On success, the sent Message is returned.

    • Returns this is MessageOrigin & { authorSignature?: string; chat: Chat; id: string }

    • Use this method to add a message to the list of pinned messages in a chat. In private chats and channel direct messages chats, all non-service messages can be pinned. Conversely, the bot must be an administrator with the 'can_pin_messages' right or the 'can_edit_messages' right to pin messages in groups and channels respectively. Returns True on success.

      Parameters

      • Optionaloptions: { businessConnectionId?: string; notification?: boolean }

        options for pinned message

        • OptionalbusinessConnectionId?: string

          Unique identifier of the business connection on behalf of which the message will be pinned

        • Optionalnotification?: boolean

          Pass True if it is not necessary to send a notification to all chat members about the new pinned message. Notifications are always disabled in channels and private chats

      Returns Promise<true>

      Returns True on success.

    • Use this method to change the chosen reactions on a message. Service messages can't be reacted to. Automatically forwarded messages from a channel to its discussion group have the same available reactions as messages in the channel. In albums, bots must react to the first message.

      Parameters

      • reaction: string | ReactionType | ReactionType[] | ReactionType | ReactionType[]

        A JSON-serialized list of reaction types to set on the message. Currently, as non-premium users, bots can set up to one reaction per message. A custom emoji reaction can be used if it is either already present on the message or explicitly allowed by chat administrators. Paid reactions can't be used by bots

      • OptionalisBig: boolean

        Pass True to set the reaction with a big animation

      Returns Promise<true>

      Returns True on success.

    • Reply to the current message

      Parameters

      • text: string

        Text of the message to be sent, 1-4096 characters after entities parsing

      • Optionaloptions: Omit<
            {
                businessConnectionId?: string;
                chatId: string
                | number;
                directMessagesTopicId?: number;
                disableNotification?: boolean;
                entities?: MessageEntity[];
                linkPreviewOptions?: LinkPreviewOptions;
                messageEffectId?: string;
                messageThreadId?: string | number;
                parseMode?: ParseMode;
                protectContent?: boolean;
                replyMarkup?:
                    | InlineKeyboardMarkup
                    | ForceReply
                    | ReplyKeyboardMarkup
                    | ReplyKeyboardRemove;
                replyParameters?: ReplyParameters;
                suggestedPostParameters?: SuggestedPostParameters;
                text: string;
            },
            "text"
            | "chatId",
        >

        out parameters

      Returns Promise<Message & { content: string }>

      On success, the sent Message is returned.

    • Use this method to stop updating a live location message before live_period expires.

      Parameters

      • Optionaloptions: Omit<
            {
                businessConnectionId?: string;
                chatId?: string
                | number;
                inlineMessageId?: string;
                messageId?: string | number;
                replyMarkup?: InlineKeyboardMarkup;
            },
            "chatId"
            | "messageId",
        >

        out parameters

      Returns Promise<
          | true
          | Message & {
              editedAt: Date;
              editedTimestamp: number;
              editedUnixTime: number;
              location: Location;
          },
      >

      On success, if the message is not an inline message, the edited Message is returned, otherwise True is returned.

    • Flatten an object. Any properties that are collections will get converted to an array of keys.

      Parameters

      • OptionalpropsRecursive: boolean

        Optional. If true, calls toJSON method on nested objects.

      • ...props: Record<string, string | boolean>[]

        Optional. Specific properties to include/exclude, or rename.

      Returns Record<string, any>

      Flattened object.

    • Use this method to remove a message from the list of pinned messages in a chat. In private chats and channel direct messages chats, all messages can be unpinned. Conversely, the bot must be an administrator with the 'can_pin_messages' right or the 'can_edit_messages' right to unpin messages in groups and channels respectively.

      Parameters

      • OptionalbusinessConnectionId: string

        Unique identifier of the business connection on behalf of which the message will be unpinned

      Returns Promise<true>

      Returns True on success.

    • Returns the id instance Chat, User, ChatMember and other

      Returns string | null