GramIO API Reference / @gramio/contexts/dist / Message
Class: Message
Defined in: contexts/index.d.ts:3305
This object represents a message.
Extended by
BoostAddedContextChatBackgroundSetContextChatOwnerChangedContextChatOwnerLeftContextChatSharedContextChecklistTasksAddedContextChecklistTasksDoneContextCommunityChatAddedContextCommunityChatJoinedContextCommunityChatRemovedContextDeleteChatPhotoContextDirectMessagePriceChangedContextForumTopicClosedContextForumTopicCreatedContextForumTopicEditedContextForumTopicReopenedContextGeneralForumTopicHiddenContextGeneralForumTopicUnhiddenContextGiftContextGiftUpgradeSentContextGiveawayCompletedContextGiveawayCreatedContextGiveawayWinnersContextGroupChatCreatedContextInvoiceContextLeftChatMemberContextLocationContextManagedBotCreatedContextMessageAutoDeleteTimerChangedContextMessageContextMigrateFromChatIdContextMigrateToChatIdContextNewChatMembersContextNewChatPhotoContextNewChatTitleContextPaidMessagePriceChangedContextPassportDataContextPinnedMessageContextPollOptionAddedContextPollOptionDeletedContextProximityAlertTriggeredContextRefundedPaymentContextSuccessfulPaymentContextSuggestedPostApprovalFailedContextSuggestedPostApprovedContextSuggestedPostDeclinedContextSuggestedPostPaidContextSuggestedPostRefundedContextUniqueGiftContextUsersSharedContextVideoChatEndedContextVideoChatParticipantsInvitedContextVideoChatScheduledContextVideoChatStartedContextWebAppDataContextWriteAccessAllowedContext
Constructors
Constructor
new Message(
payload):Message
Defined in: contexts/index.d.ts:3307
Parameters
| Parameter | Type |
|---|---|
payload | TelegramMessage |
Returns
Message
Properties
| Property | Type | Defined in |
|---|---|---|
payload | TelegramMessage | contexts/index.d.ts:3306 |
Accessors
[toStringTag]
Get Signature
get [toStringTag]():
string
Defined in: contexts/index.d.ts:3309
Returns
string
animation
Get Signature
get animation():
AnimationAttachment
Defined in: contexts/index.d.ts:3410
Message is an animation, information about the animation. For backward compatibility, when this field is set, the document field will also be set
Returns
audio
Get Signature
get audio():
AudioAttachment
Defined in: contexts/index.d.ts:3412
Message is an audio file, information about the file
Returns
authorSignature
Get Signature
get authorSignature():
string
Defined in: contexts/index.d.ts:3381
Signature of the post author for messages in channels, or the custom title of an anonymous group administrator
Returns
string
businessConnectionId
Get Signature
get businessConnectionId():
string
Defined in: contexts/index.d.ts:3339
Unique identifier of the business connection from which the message was received. If non-empty, the message belongs to a chat of the corresponding business account that is independent from any potential bot chat which might share the same identifier.
Returns
string
caption
Get Signature
get caption():
string
Defined in: contexts/index.d.ts:3436
Caption for the animation, audio, document, photo, video or voice, 0-1024 characters
Returns
string
captionEntities
Get Signature
get captionEntities():
MessageEntity[]
Defined in: contexts/index.d.ts:3441
For messages with a caption, special entities like usernames, URLs, bot commands, etc. that appear in the caption
Returns
channelChatCreated
Get Signature
get channelChatCreated():
true
Defined in: contexts/index.d.ts:3512
Service message: the channel has been created. This field can't be received in a message coming through updates, because bot can't be a member of a channel when it is created. It can only be found in replyMessage if someone replies to a very first message in a channel.
Returns
true
chat
Get Signature
get chat():
Chat
Defined in: contexts/index.d.ts:3341
Conversation the message belongs to
Returns
chatBackgroundSet
Get Signature
get chatBackgroundSet():
ChatBackground
Defined in: contexts/index.d.ts:3563
Service message: chat background set
Returns
chatBoostAdded
Get Signature
get chatBoostAdded():
ChatBoostAdded
Defined in: contexts/index.d.ts:3561
Service message: chat boost added
Returns
chatOwnerChanged
Get Signature
get chatOwnerChanged():
ChatOwnerChanged
Defined in: contexts/index.d.ts:3487
Service message: chat owner has changed
Returns
chatOwnerLeft
Get Signature
get chatOwnerLeft():
ChatOwnerLeft
Defined in: contexts/index.d.ts:3485
Service message: chat owner has left
Returns
chatShared
Get Signature
get chatShared():
ChatShared
Defined in: contexts/index.d.ts:3545
Service message: a chat was shared with the bot
Returns
checklist
Get Signature
get checklist():
Checklist
Defined in: contexts/index.d.ts:3356
Returns
checklistTasksAdded
Get Signature
get checklistTasksAdded():
ChecklistTasksAdded
Defined in: contexts/index.d.ts:3568
Service message: checklist tasks added
Returns
checklistTasksDone
Get Signature
get checklistTasksDone():
ChecklistTasksDone
Defined in: contexts/index.d.ts:3565
Service message: checklist tasks done
Returns
communityChatAdded
Get Signature
get communityChatAdded():
CommunityChatAdded
Defined in: contexts/index.d.ts:3625
Service message: a chat was added to a community
Returns
communityChatJoined
Get Signature
get communityChatJoined():
CommunityChatJoined
Defined in: contexts/index.d.ts:3627
Service message: a chat joined a community
Returns
communityChatRemoved
Get Signature
get communityChatRemoved():
CommunityChatRemoved
Defined in: contexts/index.d.ts:3629
Service message: a chat was removed from a community
Returns
connectedWebsite
Get Signature
get connectedWebsite():
string
Defined in: contexts/index.d.ts:3471
The domain name of the website on which the user has logged in.
Returns
string
contact
Get Signature
get contact():
Contact
Defined in: contexts/index.d.ts:3449
Message is a shared contact, information about the contact
Returns
createdAt
Get Signature
get createdAt():
number
Defined in: contexts/index.d.ts:3332
Date the message was sent in Unix time
Returns
number
deleteChatPhoto
Get Signature
get deleteChatPhoto():
true
Defined in: contexts/index.d.ts:3493
Service message: the chat photo was deleted
Returns
true
dice
Get Signature
get dice():
Dice
Defined in: contexts/index.d.ts:3451
Message is a dice with random value from 1 to 6
Returns
directMessagePriceChanged
Get Signature
get directMessagePriceChanged():
DirectMessagePriceChanged
Defined in: contexts/index.d.ts:3570
Service message: direct message price changed
Returns
directMessagesTopic
Get Signature
get directMessagesTopic():
DirectMessagesTopic
Defined in: contexts/index.d.ts:3315
Optional. Information about the direct messages chat topic that contains the message
Returns
document
Get Signature
get document():
DocumentAttachment
Defined in: contexts/index.d.ts:3414
Message is a general file, information about the file
Returns
effectId
Get Signature
get effectId():
string
Defined in: contexts/index.d.ts:3403
Unique identifier of the message effect added to the message
Returns
string
entities
Get Signature
get entities():
MessageEntity[]
Defined in: contexts/index.d.ts:3397
For text messages, special entities like usernames, URLs, bot commands, etc. that appear in the text
Returns
ephemeralMessageId
Get Signature
get ephemeralMessageId():
number
Defined in: contexts/index.d.ts:3623
Unique message identifier of this ephemeral message inside the chat. Use it with editEphemeralMessage* / deleteEphemeralMessage and as ReplyParameters.ephemeral_message_id. Present only for ephemeral messages.
Returns
number
externalReply
Get Signature
get externalReply():
ExternalReplyInfo
Defined in: contexts/index.d.ts:3358
Information about the message that is being replied to, which may come from another chat or forum topic
Returns
forumTopicClosed
Get Signature
get forumTopicClosed():
ForumTopicClosed
Defined in: contexts/index.d.ts:3586
Service message: forum topic closed
Returns
forumTopicCreated
Get Signature
get forumTopicCreated():
ForumTopicCreated
Defined in: contexts/index.d.ts:3582
Service message: forum topic created
Returns
forumTopicEdited
Get Signature
get forumTopicEdited():
ForumTopicEdited
Defined in: contexts/index.d.ts:3584
Service message: forum topic edited
Returns
forumTopicReopened
Get Signature
get forumTopicReopened():
ForumTopicReopened
Defined in: contexts/index.d.ts:3588
Service message: forum topic reopened
Returns
forwardOrigin
Get Signature
get forwardOrigin():
MessageOriginUser|MessageOriginChat|MessageOriginChannel|MessageOriginHiddenUser
Defined in: contexts/index.d.ts:3343
Information about the original message for forwarded messages
Returns
MessageOriginUser | MessageOriginChat | MessageOriginChannel | MessageOriginHiddenUser
from
Get Signature
get from():
User
Defined in: contexts/index.d.ts:3317
Sender, empty for messages sent to channels
Returns
game
Get Signature
get game():
Game
Defined in: contexts/index.d.ts:3453
Message is a game, information about the game
Returns
generalForumTopicHidden
Get Signature
get generalForumTopicHidden():
GeneralForumTopicHidden
Defined in: contexts/index.d.ts:3590
Service message: the 'General' forum topic hidden
Returns
generalForumTopicUnhidden
Get Signature
get generalForumTopicUnhidden():
GeneralForumTopicUnhidden
Defined in: contexts/index.d.ts:3592
Service message: the 'General' forum topic unhidden
Returns
gift
Get Signature
get gift():
GiftInfo
Defined in: contexts/index.d.ts:3547
Service message: a gift was sent to the chat
Returns
giftUpgradeSent
Get Signature
get giftUpgradeSent():
GiftInfo
Defined in: contexts/index.d.ts:3549
Service message: upgrade of a gift was purchased after the gift was sent
Returns
giveaway
Get Signature
get giveaway():
Giveaway
Defined in: contexts/index.d.ts:3594
The message is a scheduled giveaway message
Returns
giveawayCompleted
Get Signature
get giveawayCompleted():
GiveawayCompleted
Defined in: contexts/index.d.ts:3598
Service message: a giveaway without public winners was completed
Returns
giveawayCreated
Get Signature
get giveawayCreated():
GiveawayCreated
Defined in: contexts/index.d.ts:3596
Service message: a scheduled giveaway was created
Returns
giveawayWinners
Get Signature
get giveawayWinners():
GiveawayWinners
Defined in: contexts/index.d.ts:3600
A giveaway with public winners was completed
Returns
groupChatCreated
Get Signature
get groupChatCreated():
true
Defined in: contexts/index.d.ts:3495
Service message: the group has been created
Returns
true
guestBotCallerChat
Get Signature
get guestBotCallerChat():
Chat
Defined in: contexts/index.d.ts:3366
Optional. For a message sent by a guest bot, this is the chat whose original message triggered the bot's response
Returns
guestBotCallerUser
Get Signature
get guestBotCallerUser():
User
Defined in: contexts/index.d.ts:3364
Optional. For a message sent by a guest bot, this is the user whose original message triggered the bot's response
Returns
guestQueryId
Get Signature
get guestQueryId():
string
Defined in: contexts/index.d.ts:3337
Optional. The unique identifier for the guest query. Use this identifier with the method answerGuestQuery to send a response message. If non-empty, the message belongs to the chat where the guest bot was summoned, which may not coincide with other existing bot chats sharing the same identifier.
Returns
string
id
Get Signature
get id():
number
Defined in: contexts/index.d.ts:3311
Unique message identifier inside this chat
Returns
number
invoice
Get Signature
get invoice():
Invoice
Defined in: contexts/index.d.ts:3536
Message is an invoice for a payment, information about the invoice
Returns
leftChatMember
Get Signature
get leftChatMember():
User
Defined in: contexts/index.d.ts:3483
A member was removed from the group, information about them (this member may be the bot itself)
Returns
linkPreviewOptions
Get Signature
get linkPreviewOptions():
LinkPreviewOptions
Defined in: contexts/index.d.ts:3399
Options used for link preview generation for the message, if it is a text message and link preview options were changed
Returns
livePhoto
Get Signature
get livePhoto():
LivePhotoAttachment
Defined in: contexts/index.d.ts:3419
Message is a live photo, information about the live photo. For backward compatibility, when this field is set, the photo field will also be set
Returns
location
Get Signature
get location():
Location
Defined in: contexts/index.d.ts:3463
Message is a shared location, information about the location
Returns
managedBotCreated
Get Signature
get managedBotCreated():
ManagedBotCreated
Defined in: contexts/index.d.ts:3612
Service message: user created a bot that will be managed by the current bot
Returns
mediaGroupId
Get Signature
get mediaGroupId():
string
Defined in: contexts/index.d.ts:3376
The unique identifier of a media message group this message belongs to
Returns
string
messageAutoDeleteTimerChanged
Get Signature
get messageAutoDeleteTimerChanged():
MessageAutoDeleteTimerChanged
Defined in: contexts/index.d.ts:3505
Service message: auto-delete timer settings changed in the chat
Returns
migrateFromChatId
Get Signature
get migrateFromChatId():
number
Defined in: contexts/index.d.ts:3528
The supergroup has been migrated from a group with the specified identifier. This number may be greater than 32 bits and some programming languages may have difficulty/silent defects in interpreting it. But it is smaller than 52 bits, so a signed 64 bit integer or double-precision float type are safe for storing this identifier.
Returns
number
migrateToChatId
Get Signature
get migrateToChatId():
number
Defined in: contexts/index.d.ts:3520
The group has been migrated to a supergroup with the specified identifier. This number may be greater than 32 bits and some programming languages may have difficulty/silent defects in interpreting it. But it is smaller than 52 bits, so a signed 64 bit integer or double-precision float type are safe for storing this identifier.
Returns
number
newChatMembers
Get Signature
get newChatMembers():
User[]
Defined in: contexts/index.d.ts:3478
New members that were added to the group or supergroup and information about them (the bot itself may be one of these members)
Returns
User[]
newChatPhoto
Get Signature
get newChatPhoto():
PhotoSize[]
Defined in: contexts/index.d.ts:3491
A chat photo was change to this value
Returns
newChatTitle
Get Signature
get newChatTitle():
string
Defined in: contexts/index.d.ts:3489
A chat title was changed to this value
Returns
string
paidStarCount
Get Signature
get paidStarCount():
number
Defined in: contexts/index.d.ts:3385
Optional. The number of Telegram Stars that were paid by the sender of the message to send it
Returns
number
passportData
Get Signature
get passportData():
PassportData
Defined in: contexts/index.d.ts:3473
Telegram Passport data
Returns
photo
Get Signature
get photo():
PhotoSize[]
Defined in: contexts/index.d.ts:3421
Message is a photo, available sizes of the photo
Returns
pinnedMessage
Get Signature
get pinnedMessage():
Omit<Message,"replyMessage"> |InaccessibleMessage
Defined in: contexts/index.d.ts:3534
Specified message was pinned. Note that the Message object in this field will not contain further replyMessage fields even if it is itself a reply.
Returns
Omit<Message, "replyMessage"> | InaccessibleMessage
poll
Get Signature
get poll():
Poll
Defined in: contexts/index.d.ts:3455
Message is a native poll, information about the poll
Returns
pollOptionAdded
Get Signature
get pollOptionAdded():
PollOptionAdded
Defined in: contexts/index.d.ts:3631
Service message: answer option was added to a poll
Returns
pollOptionDeleted
Get Signature
get pollOptionDeleted():
PollOptionDeleted
Defined in: contexts/index.d.ts:3633
Service message: answer option was deleted from a poll
Returns
proximityAlertTriggered
Get Signature
get proximityAlertTriggered():
ProximityAlertTriggered
Defined in: contexts/index.d.ts:3557
Service message. A user in the chat triggered another user's proximity alert while sharing Live Location.
Returns
quote
Get Signature
get quote():
TextQuote
Defined in: contexts/index.d.ts:3360
For replies that quote part of the original message, the quoted part of the message
Returns
receiverUser
Get Signature
get receiverUser():
User
Defined in: contexts/index.d.ts:3617
The only user who can see this ephemeral message, along with the bot. Present only for ephemeral messages.
Returns
replyMarkup
Get Signature
get replyMarkup():
InlineKeyboardMarkup
Defined in: contexts/index.d.ts:3469
Inline keyboard attached to the message.
login_url buttons are represented as ordinary url buttons.
Returns
replyMessage
Get Signature
get replyMessage():
Omit<Message,"replyMessage">
Defined in: contexts/index.d.ts:3349
For replies, the original message
Returns
Omit<Message, "replyMessage">
replyStory
Get Signature
get replyStory():
Story
Defined in: contexts/index.d.ts:3351
For replies to a story, the original story
Returns
replyToChecklistTaskId
Get Signature
get replyToChecklistTaskId():
number
Defined in: contexts/index.d.ts:3353
Optional. Identifier of the specific checklist task that is being replied to
Returns
number
replyToPollOptionId
Get Signature
get replyToPollOptionId():
string
Defined in: contexts/index.d.ts:3355
Optional. Persistent identifier of the specific poll option that is being replied to
Returns
string
richMessage
Get Signature
get richMessage():
RichMessage
Defined in: contexts/index.d.ts:3405
Message is a rich formatted message
Returns
senderBoostCount
Get Signature
get senderBoostCount():
number
Defined in: contexts/index.d.ts:3326
If the sender of the message boosted the chat, the number of boosts added by the user
Returns
number
senderBusinessBot
Get Signature
get senderBusinessBot():
User
Defined in: contexts/index.d.ts:3328
The bot that actually sent the message on behalf of the business account. Available only for outgoing messages sent on behalf of the connected business account.
Returns
senderChat
Get Signature
get senderChat():
Chat
Defined in: contexts/index.d.ts:3324
Sender of the message, sent on behalf of a chat. The channel itself for channel messages. The supergroup itself for messages from anonymous group administrators. The linked channel for messages automatically forwarded to the discussion group
Returns
senderTag
Get Signature
get senderTag():
string
Defined in: contexts/index.d.ts:3330
Tag or custom title of the sender of the message; for supergroups only
Returns
string
sticker
Get Signature
get sticker():
StickerAttachment
Defined in: contexts/index.d.ts:3423
Message is a sticker, information about the sticker
Returns
story
Get Signature
get story():
StoryAttachment
Defined in: contexts/index.d.ts:3425
Message is a forwarded story
Returns
successfulPayment
Get Signature
get successfulPayment():
SuccessfulPayment
Defined in: contexts/index.d.ts:3541
Message is a service message about a successful payment, information about the payment.
Returns
suggestedPostApprovalFailed
Get Signature
get suggestedPostApprovalFailed():
SuggestedPostApprovalFailed
Defined in: contexts/index.d.ts:3574
Service message: approval of a suggested post has failed
Returns
suggestedPostApproved
Get Signature
get suggestedPostApproved():
SuggestedPostApproved
Defined in: contexts/index.d.ts:3572
Service message: a suggested post was approved
Returns
suggestedPostDeclined
Get Signature
get suggestedPostDeclined():
SuggestedPostDeclined
Defined in: contexts/index.d.ts:3576
Service message: a suggested post was declined
Returns
suggestedPostInfo
Get Signature
get suggestedPostInfo():
SuggestedPostInfo
Defined in: contexts/index.d.ts:3401
Optional. Information about suggested post parameters if the message is a suggested post
Returns
suggestedPostPaid
Get Signature
get suggestedPostPaid():
SuggestedPostPaid
Defined in: contexts/index.d.ts:3578
Service message: payment for a suggested post was received
Returns
suggestedPostRefunded
Get Signature
get suggestedPostRefunded():
SuggestedPostRefunded
Defined in: contexts/index.d.ts:3580
Service message: payment for a suggested post was refunded
Returns
supergroupChatCreated
Get Signature
get supergroupChatCreated():
true
Defined in: contexts/index.d.ts:3503
Service message: the supergroup has been created. This field can't be received in a message coming through updates, because bot can't be a member of a supergroup when it is created. It can only be found in replyMessage if someone replies to a very first message in a directly created supergroup.
Returns
true
text
Get Signature
get text():
string
Defined in: contexts/index.d.ts:3392
For text messages, the actual UTF-8 text of the message, 0-4096 characters.
Falls back to the flattened rich message text when the message has no plain text, so text-based handlers keep working on rich messages.
Returns
string
threadId
Get Signature
get threadId():
number
Defined in: contexts/index.d.ts:3313
Unique identifier of a message thread to which the message belongs; for supergroups only
Returns
number
uniqueGift
Get Signature
get uniqueGift():
UniqueGiftInfo
Defined in: contexts/index.d.ts:3551
Service message: a unique gift was sent to the chat
Returns
updatedAt
Get Signature
get updatedAt():
number
Defined in: contexts/index.d.ts:3368
Date the message was last edited in Unix time
Returns
number
usersShared
Get Signature
get usersShared():
UsersShared
Defined in: contexts/index.d.ts:3543
Service message: a user was shared with the bot
Returns
venue
Get Signature
get venue():
Venue
Defined in: contexts/index.d.ts:3461
Message is a venue, information about the venue. For backward compatibility, when this field is set, the location field will also be set
Returns
viaBot
Get Signature
get viaBot():
User
Defined in: contexts/index.d.ts:3362
Bot through which the message was sent
Returns
video
Get Signature
get video():
VideoAttachment
Defined in: contexts/index.d.ts:3427
Message is a video, information about the video
Returns
videoChatEnded
Get Signature
get videoChatEnded():
VideoChatEnded
Defined in: contexts/index.d.ts:3606
Service message: video chat ended
Returns
videoChatParticipantsInvited
Get Signature
get videoChatParticipantsInvited():
VideoChatParticipantsInvited
Defined in: contexts/index.d.ts:3608
Service message: new participants invited to a video chat
Returns
videoChatScheduled
Get Signature
get videoChatScheduled():
VideoChatScheduled
Defined in: contexts/index.d.ts:3602
Service message: video chat scheduled
Returns
videoChatStarted
Get Signature
get videoChatStarted():
VideoChatStarted
Defined in: contexts/index.d.ts:3604
Service message: video chat started
Returns
videoNote
Get Signature
get videoNote():
VideoNoteAttachment
Defined in: contexts/index.d.ts:3429
Message is a video note, information about the video message
Returns
voice
Get Signature
get voice():
VoiceAttachment
Defined in: contexts/index.d.ts:3431
Message is a voice message, information about the file
Returns
webAppData
Get Signature
get webAppData():
WebAppData
Defined in: contexts/index.d.ts:3610
Service message: data sent by a Web App
Returns
writeAccessAllowed
Get Signature
get writeAccessAllowed():
WriteAccessAllowed
Defined in: contexts/index.d.ts:3559
Service message: the user allowed the bot added to the attachment menu to write messages
Returns
Methods
hasMediaSpoiler()
hasMediaSpoiler():
true
Defined in: contexts/index.d.ts:3447
true, if the message media is covered by a spoiler animation
Returns
true
hasProtectedContent()
hasProtectedContent():
true
Defined in: contexts/index.d.ts:3370
true, if the message can't be forwarded
Returns
true
isAutomaticForward()
isAutomaticForward():
true
Defined in: contexts/index.d.ts:3347
true, if the message is a channel post that was automatically forwarded to the connected discussion group
Returns
true
isFromOffline()
isFromOffline():
true
Defined in: contexts/index.d.ts:3372
true, True, if the message was sent by an implicit action, for example, as an away or a greeting business message, or as a scheduled message
Returns
true
isPaidPost()
isPaidPost():
true
Defined in: contexts/index.d.ts:3374
Optional. True, if the message is a paid post
Returns
true
isShowCaptionAboveMedia()
isShowCaptionAboveMedia():
boolean
Defined in: contexts/index.d.ts:3445
True, if the caption must be shown above the message media
Returns
boolean
isTopicMessage()
isTopicMessage():
boolean
Defined in: contexts/index.d.ts:3345
true, if the message is sent to a forum topic
Returns
boolean