Message class abstract

This object represents a message.

Implemented types
Available extensions
Annotations
  • @Freezed(copyWith: false)

Constructors

Message.new({@JsonKey(name: "chat") required Chat chat, @JsonKey(name: "message_id") required int messageId, @JsonKey(name: "date") required int date, @JsonKey(name: 'message_thread_id') int? messageThreadId, @JsonKey(name: 'from') User? from, @JsonKey(name: 'sender_chat') Chat? senderChat, @JsonKey(name: 'forward_origin') MessageOrigin? forwardOrigin, @JsonKey(name: 'is_topic_message') bool? isTopicMessage, @JsonKey(name: 'is_automatic_forward') bool? isAutomaticForward, @JsonKey(name: 'reply_to_message') Message? replyToMessage, @JsonKey(name: 'via_bot') User? viaBot, @JsonKey(name: 'edit_date') int? editDate, @JsonKey(name: 'has_protected_content') bool? hasProtectedContent, @JsonKey(name: 'media_group_id') String? mediaGroupId, @JsonKey(name: 'author_signature') String? authorSignature, @JsonKey(name: 'text') String? text, @JsonKey(name: 'entities') List<MessageEntity>? entities, @JsonKey(name: 'animation') Animation? animation, @JsonKey(name: 'audio') Audio? audio, @JsonKey(name: 'document') Document? document, @JsonKey(name: 'photo') List<PhotoSize>? photo, @JsonKey(name: 'sticker') Sticker? sticker, @JsonKey(name: 'video') Video? video, @JsonKey(name: 'video_note') VideoNote? videoNote, @JsonKey(name: 'voice') Voice? voice, @JsonKey(name: 'caption') String? caption, @JsonKey(name: 'caption_entities') List<MessageEntity>? captionEntities, @JsonKey(name: 'contact') Contact? contact, @JsonKey(name: 'dice') Dice? dice, @JsonKey(name: 'game') Game? game, @JsonKey(name: 'poll') Poll? poll, @JsonKey(name: 'venue') Venue? venue, @JsonKey(name: 'location') Location? location, @JsonKey(name: 'new_chat_members') List<User>? newChatMembers, @JsonKey(name: 'left_chat_member') User? leftChatMember, @JsonKey(name: 'new_chat_title') String? newChatTitle, @JsonKey(name: 'new_chat_photo') List<PhotoSize>? newChatPhoto, @JsonKey(name: 'delete_chat_photo') bool? deleteChatPhoto, @JsonKey(name: 'group_chat_created') bool? groupChatCreated, @JsonKey(name: 'supergroup_chat_created') bool? supergroupChatCreated, @JsonKey(name: 'channel_chat_created') bool? channelChatCreated, @JsonKey(name: 'message_auto_delete_timer_changed') MessageAutoDeleteTimerChanged? messageAutoDeleteTimerChanged, @JsonKey(name: 'migrate_to_chat_id') int? migrateToChatId, @JsonKey(name: 'migrate_from_chat_id') int? migrateFromChatId, @JsonKey(name: 'pinned_message') Message? pinnedMessage, @JsonKey(name: 'invoice') Invoice? invoice, @JsonKey(name: 'successful_payment') SuccessfulPayment? successfulPayment, @JsonKey(name: 'connected_website') String? connectedWebsite, @JsonKey(name: 'passport_data') PassportData? passportData, @JsonKey(name: 'proximity_alert_triggered') ProximityAlertTriggered? proximityAlertTriggered, @JsonKey(name: 'forum_topic_created') ForumTopicCreated? forumTopicCreated, @JsonKey(name: 'forum_topic_closed') ForumTopicClosed? forumTopicClosed, @JsonKey(name: 'forum_topic_reopened') ForumTopicReopened? forumTopicReopened, @JsonKey(name: 'video_chat_scheduled') VideoChatScheduled? videoChatScheduled, @JsonKey(name: 'video_chat_started') VideoChatStarted? videoChatStarted, @JsonKey(name: 'video_chat_ended') VideoChatEnded? videoChatEnded, @JsonKey(name: 'video_chat_participants_invited') VideoChatParticipantsInvited? videoChatParticipantsInvited, @JsonKey(name: 'web_app_data') WebAppData? webAppData, @JsonKey(name: 'reply_markup') InlineKeyboardMarkup? replyMarkup, @JsonKey(name: 'users_shared') UsersShared? usersShared, @JsonKey(name: 'chat_shared') ChatShared? chatShared, @JsonKey(name: 'has_media_spoiler') bool? hasMediaSpoiler, @JsonKey(name: 'forum_topic_edited') ForumTopicEdited? forumTopicEdited, @JsonKey(name: 'general_forum_topic_hidden') GeneralForumTopicHidden? generalForumTopicHidden, @JsonKey(name: 'general_forum_topic_unhidden') GeneralForumTopicUnhidden? generalForumTopicUnhidden, @JsonKey(name: 'write_access_allowed') WriteAccessAllowed? writeAccessAllowed, @JsonKey(name: 'story') Story? story, @JsonKey(name: 'external_reply') ExternalReplyInfo? externalReply, @JsonKey(name: 'quote') TextQuote? quote, @JsonKey(name: 'link_preview_options') LinkPreviewOptions? linkPreviewOptions, @JsonKey(name: 'giveaway') Giveaway? giveaway, @JsonKey(name: 'giveaway_created') GiveawayCreated? giveawayCreated, @JsonKey(name: 'giveaway_winners') GiveawayWinners? giveawayWinners, @JsonKey(name: 'giveaway_completed') GiveawayCompleted? giveawayCompleted, @JsonKey(name: 'boost_added') ChatBoostAdded? boostAdded, @JsonKey(name: 'sender_boost_count') int? senderBoostCount, @JsonKey(name: 'reply_to_story') Story? replyToStory, @JsonKey(name: 'business_connection_id') String? businessConnectionId, @JsonKey(name: 'sender_business_bot') User? senderBusinessBot, @JsonKey(name: 'is_from_offline') bool? isFromOffline, @JsonKey(name: 'chat_background_set') ChatBackground? chatBackgroundSet, @JsonKey(name: 'effect_id') String? effectId, @JsonKey(name: 'show_caption_above_media') bool? showCaptionAboveMedia, @JsonKey(name: 'paid_media') PaidMediaInfo? paidMedia, @JsonKey(name: 'refunded_payment') RefundedPayment? refundedPayment})
Creates a Message object.
const
factory
Message.fromJson(Map<String, dynamic> json)
Creates a Message object from JSON object
factory

Properties

animation Animation?
Optional. Message is an animation, information about the animation. For backward compatibility, when this field is set, the document field will also be set
no setterinherited
audio Audio?
Optional. Message is an audio file, information about the file
no setterinherited
authorSignature String?
Optional. Signature of the post author for messages in channels, or the custom title of an anonymous group administrator
no setterinherited
boostAdded ChatBoostAdded?
Optional. Service message: user boosted the chat
no setterinherited
businessConnectionId String?
Optional. 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.
no setterinherited
caption String?
Optional. Caption for the animation, audio, document, photo, video or voice
no setterinherited
captionEntities List<MessageEntity>?
Optional. For messages with a caption, special entities like usernames, URLs, bot commands, etc. that appear in the caption
no setterinherited
channelChatCreated bool?
Optional. 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 reply_to_message if someone replies to a very first message in a channel.
no setterinherited
chat Chat
Chat the message belonged to
no setterinherited
chatBackgroundSet ChatBackground?
Optional. Service message: chat background set
no setterinherited
chatShared ChatShared?
Optional. Service message: a chat was shared with the bot
no setterinherited
connectedWebsite String?
Optional. The domain name of the website on which the user has logged in. More about Telegram Login »
no setterinherited
contact Contact?
Optional. Message is a shared contact, information about the contact
no setterinherited
date int
Date the message was sent in Unix time. It is always a positive number, representing a valid date.
no setterinherited
dateTime DateTime

Available on Message, provided by the MessageExtension extension

Getter for the DateTime object that represents the message sent date
no setter
deleteChatPhoto bool?
Optional. Service message: the chat photo was deleted
no setterinherited
dice Dice?
Optional. Message is a dice with random value
no setterinherited
document Document?
Optional. Message is a general file, information about the file
no setterinherited
editDate int?
Optional. Date the message was last edited in Unix time
no setterinherited
editDateTime DateTime?

Available on Message, provided by the MessageExtension extension

Getter for the DateTime object that represents the message edit date
no setter
editDateTime DateTime

Available on Message, provided by the MessageExt extension

The DateTime representation from date
no setter
effectId String?
Optional. Unique identifier of the message effect added to the message
no setterinherited
entities List<MessageEntity>?
Optional. For text messages, special entities like usernames, URLs, bot commands, etc. that appear in the text
no setterinherited
externalReply ExternalReplyInfo?
Optional. Information about the message that is being replied to, which may come from another chat or forum topic
no setterinherited
forumTopicClosed ForumTopicClosed?
Optional. Service message: forum topic closed
no setterinherited
forumTopicCreated ForumTopicCreated?
Optional. Service message: forum topic created
no setterinherited
forumTopicEdited ForumTopicEdited?
Optional. Service message: forum topic edited
no setterinherited
forumTopicReopened ForumTopicReopened?
Optional. Service message: forum topic reopened
no setterinherited
forwardDateTime DateTime?

Available on Message, provided by the MessageExtension extension

Getter for the DateTime object that represents the message forward date
no setter
forwardOrigin MessageOrigin?
Optional. Information about the original message for forwarded messages
no setterinherited
from User?
Optional. Sender of the message; empty for messages sent to channels. For backward compatibility, the field contains a fake sender user in non-channel chats, if the message was sent on behalf of a chat.
no setterinherited
game Game?
Optional. Message is a game, information about the game. More about games »
no setterinherited
generalForumTopicHidden GeneralForumTopicHidden?
Optional. Service message: the 'General' forum topic hidden
no setterinherited
generalForumTopicUnhidden GeneralForumTopicUnhidden?
Optional. Service message: the 'General' forum topic unhidden
no setterinherited
giveaway Giveaway?
Optional. The message is a scheduled giveaway message
no setterinherited
giveawayCompleted GiveawayCompleted?
Optional. Service message: a giveaway without public winners was completed
no setterinherited
giveawayCreated GiveawayCreated?
Optional. Service message: a scheduled giveaway was created
no setterinherited
giveawayWinners GiveawayWinners?
Optional. A giveaway with public winners was completed
no setterinherited
groupChatCreated bool?
Optional. Service message: the group has been created
no setterinherited
hasEffect bool

Available on Message, provided by the MessageExtension extension

Flag to determine whether a message effect is added to the current message
no setter
hashCode int
The hash code for this object.
no setterinherited
hasMediaSpoiler bool?
Optional. True, if the message media is covered by a spoiler animation
no setterinherited
hasProtectedContent bool?
Optional. True, if the message can't be forwarded
no setterinherited
invoice Invoice?
Optional. Message is an invoice for a payment, information about the invoice. More about payments »
no setterinherited
isAccessible bool

Available on Message, provided by the MessageExt extension

Whether the message is accessible
no setter
isAutomaticForward bool?
Optional. True, if the message is a channel post that was automatically forwarded to the connected discussion group
no setterinherited
isCommand bool

Available on Message, provided by the MessageExtension extension

Returns true if the message is a command
no setter
isFromOffline bool?
Optional. 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
no setterinherited
isInaccessible bool

Available on Message, provided by the MessageExt extension

Whether the message is inaccessible
no setter
isTopicMessage bool?
Optional. True, if the message is sent to a forum topic
no setterinherited
leftChatMember User?
Optional. A member was removed from the group, information about them (this member may be the bot itself)
no setterinherited
linkPreviewOptions LinkPreviewOptions?
Optional. Options used for link preview generation for the message, if it is a text message and link preview options were changed
no setterinherited
location Location?
Optional. Message is a shared location, information about the location
no setterinherited
mediaGroupId String?
Optional. The unique identifier of a media message group this message belongs to
no setterinherited
messageAutoDeleteTimerChanged MessageAutoDeleteTimerChanged?
Optional. Service message: auto-delete timer settings changed in the chat
no setterinherited
messageId int
Unique message identifier inside the chat
no setterinherited
messageThreadId int?
Optional. Unique identifier of a message thread to which the message belongs; for supergroups only
no setterinherited
migrateFromChatId int?
Optional. The supergroup has been migrated from a group with the specified identifier. This number may have more than 32 significant bits and some programming languages may have difficulty/silent defects in interpreting it. But it has at most 52 significant bits, so a signed 64-bit integer or double-precision float type are safe for storing this identifier.
no setterinherited
migrateToChatId int?
Optional. The group has been migrated to a supergroup with the specified identifier. This number may have more than 32 significant bits and some programming languages may have difficulty/silent defects in interpreting it. But it has at most 52 significant bits, so a signed 64-bit integer or double-precision float type are safe for storing this identifier.
no setterinherited
newChatMembers List<User>?
Optional. New members that were added to the group or supergroup and information about them (the bot itself may be one of these members)
no setterinherited
newChatPhoto List<PhotoSize>?
Optional. A chat photo was change to this value
no setterinherited
newChatTitle String?
Optional. A chat title was changed to this value
no setterinherited
paidMedia PaidMediaInfo?
Optional. Message contains paid media; information about the paid media
no setterinherited
passportData PassportData?
Optional. Telegram Passport data
no setterinherited
photo List<PhotoSize>?
Optional. Message is a photo, available sizes of the photo
no setterinherited
pinnedMessage Message?
Optional. Specified message was pinned. Note that the Message object in this field will not contain further reply_to_message fields even if it is itself a reply.
no setterinherited
poll Poll?
Optional. Message is a native poll, information about the poll
no setterinherited
proximityAlertTriggered ProximityAlertTriggered?
Optional. Service message. A user in the chat triggered another user's proximity alert while sharing Live Location.
no setterinherited
quote TextQuote?
Optional. For replies that quote part of the original message, the quoted part of the message
no setterinherited
refundedPayment RefundedPayment?
Optional. Message is a service message about a refunded payment, information about the payment. More about payments »
no setterinherited
replyMarkup → InlineKeyboardMarkup?
Optional. Inline keyboard attached to the message. login_url buttons are represented as ordinary url buttons.
no setterinherited
replyToMessage Message?
Optional. For replies, the original message. Note that the Message object in this field will not contain further reply_to_message fields even if it itself is a reply.
no setterinherited
replyToStory Story?
Optional. For replies to a story, the original story
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
senderBoostCount int?
Optional. If the sender of the message boosted the chat, the number of boosts added by the user
no setterinherited
senderBusinessBot User?
Optional. 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.
no setterinherited
senderChat Chat?
Optional. Sender of the message, sent on behalf of a chat. For example, the channel itself for channel posts, the supergroup itself for messages from anonymous group administrators, the linked channel for messages automatically forwarded to the discussion group. For backward compatibility, the field from contains a fake sender user in non-channel chats, if the message was sent on behalf of a chat.
no setterinherited
showCaptionAboveMedia bool?
Optional. True, if the caption must be shown above the message media
no setterinherited
sticker Sticker?
Optional. Message is a sticker, information about the sticker
no setterinherited
story Story?
Optional. Message is a forwarded story
no setterinherited
successfulPayment SuccessfulPayment?
Optional. Message is a service message about a successful payment, information about the payment. More about payments »
no setterinherited
supergroupChatCreated bool?
Optional. 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 reply_to_message if someone replies to a very first message in a directly created supergroup.
no setterinherited
text String?
Optional. For text messages, the actual UTF-8 text of the message
no setterinherited
usersShared UsersShared?
Optional. Service message: a user was shared with the bot
no setterinherited
venue Venue?
Optional. Message is a venue, information about the venue. For backward compatibility, when this field is set, the location field will also be set
no setterinherited
viaBot User?
Optional. Bot through which the message was sent
no setterinherited
video Video?
Optional. Message is a video, information about the video
no setterinherited
videoChatEnded VideoChatEnded?
Optional. Service message: video chat ended
no setterinherited
videoChatParticipantsInvited VideoChatParticipantsInvited?
Optional. Service message: new participants invited to a video chat
no setterinherited
videoChatScheduled VideoChatScheduled?
Optional. Service message: video chat scheduled
no setterinherited
videoChatStarted VideoChatStarted?
Optional. Service message: video chat started
no setterinherited
videoNote VideoNote?
Optional. Message is a video note, information about the video message
no setterinherited
voice Voice?
Optional. Message is a voice message, information about the file
no setterinherited
webAppData WebAppData?
Optional. Service message: data sent by a Web App
no setterinherited
writeAccessAllowed WriteAccessAllowed?
Optional. Service message: the user allowed the bot added to the attachment menu to write messages
no setterinherited

Methods

getEntityText(MessageEntityType type) String?

Available on Message, provided by the MessageExtension extension

Returns the text where the given MessageEntityType is found
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toJson() Map<String, dynamic>
Serializes this Message to a JSON map.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited