Skip to main content

Message

Struct Message 

Source
#[non_exhaustive]
pub struct Message {
Show 110 fields pub message_id: i64, pub date: i64, pub chat: Chat, pub from_user: Option<User>, pub sender_chat: Option<Chat>, pub sender_boost_count: Option<i32>, pub sender_business_bot: Option<User>, pub business_connection_id: Option<String>, pub message_thread_id: Option<i64>, pub is_topic_message: bool, pub forward_origin: Option<MessageOrigin>, pub is_automatic_forward: bool, pub reply_to_message: Option<Box<Message>>, pub external_reply: Option<Box<ExternalReplyInfo>>, pub quote: Option<TextQuote>, pub reply_to_story: Option<Story>, pub via_bot: Option<User>, pub edit_date: Option<i64>, pub has_protected_content: bool, pub is_from_offline: bool, pub is_paid_post: bool, pub media_group_id: Option<String>, pub author_signature: Option<String>, pub sender_tag: Option<String>, pub text: Option<String>, pub entities: Option<Vec<MessageEntity>>, pub link_preview_options: Option<LinkPreviewOptions>, pub effect_id: Option<String>, pub animation: Option<Animation>, pub audio: Option<Audio>, pub document: Option<Document>, pub paid_media: Option<PaidMediaInfo>, pub photo: Option<Vec<PhotoSize>>, pub sticker: Option<Sticker>, pub story: Option<Story>, pub video: Option<Video>, pub video_note: Option<VideoNote>, pub voice: Option<Voice>, pub caption: Option<String>, pub caption_entities: Option<Vec<MessageEntity>>, pub show_caption_above_media: bool, pub has_media_spoiler: bool, pub contact: Option<Contact>, pub dice: Option<Dice>, pub game: Option<Box<Game>>, pub poll: Option<Box<Poll>>, pub venue: Option<Box<Venue>>, pub location: Option<Location>, pub new_chat_members: Option<Vec<User>>, pub left_chat_member: Option<User>, pub new_chat_title: Option<String>, pub new_chat_photo: Option<Vec<PhotoSize>>, pub delete_chat_photo: bool, pub group_chat_created: bool, pub supergroup_chat_created: bool, pub channel_chat_created: bool, pub message_auto_delete_timer_changed: Option<MessageAutoDeleteTimerChanged>, pub migrate_to_chat_id: Option<i64>, pub migrate_from_chat_id: Option<i64>, pub pinned_message: Option<Box<Message>>, pub invoice: Option<Box<Invoice>>, pub successful_payment: Option<Box<SuccessfulPayment>>, pub refunded_payment: Option<Box<RefundedPayment>>, pub paid_message_price_changed: Option<PaidMessagePriceChanged>, pub paid_star_count: Option<i32>, pub connected_website: Option<String>, pub write_access_allowed: Option<WriteAccessAllowed>, pub passport_data: Option<Box<PassportData>>, pub proximity_alert_triggered: Option<ProximityAlertTriggered>, pub boost_added: Option<ChatBoostAdded>, pub chat_background_set: Option<ChatBackground>, pub forum_topic_created: Option<ForumTopicCreated>, pub forum_topic_edited: Option<ForumTopicEdited>, pub forum_topic_closed: Option<ForumTopicClosed>, pub forum_topic_reopened: Option<ForumTopicReopened>, pub general_forum_topic_hidden: Option<GeneralForumTopicHidden>, pub general_forum_topic_unhidden: Option<GeneralForumTopicUnhidden>, pub giveaway_created: Option<GiveawayCreated>, pub giveaway: Option<Box<Giveaway>>, pub giveaway_winners: Option<Box<GiveawayWinners>>, pub giveaway_completed: Option<Box<GiveawayCompleted>>, pub video_chat_scheduled: Option<VideoChatScheduled>, pub video_chat_started: Option<VideoChatStarted>, pub video_chat_ended: Option<VideoChatEnded>, pub video_chat_participants_invited: Option<VideoChatParticipantsInvited>, pub web_app_data: Option<WebAppData>, pub reply_markup: Option<InlineKeyboardMarkup>, pub users_shared: Option<UsersShared>, pub chat_shared: Option<ChatShared>, pub gift: Option<GiftInfo>, pub unique_gift: Option<UniqueGiftInfo>, pub gift_upgrade_sent: Option<GiftInfo>, pub checklist: Option<Checklist>, pub checklist_tasks_done: Option<ChecklistTasksDone>, pub checklist_tasks_added: Option<ChecklistTasksAdded>, pub reply_to_checklist_task_id: Option<i64>, pub direct_message_price_changed: Option<DirectMessagePriceChanged>, pub direct_messages_topic: Option<DirectMessagesTopic>, pub suggested_post_declined: Option<SuggestedPostDeclined>, pub suggested_post_paid: Option<SuggestedPostPaid>, pub suggested_post_refunded: Option<SuggestedPostRefunded>, pub suggested_post_info: Option<SuggestedPostInfo>, pub suggested_post_approved: Option<SuggestedPostApproved>, pub suggested_post_approval_failed: Option<SuggestedPostApprovalFailed>, pub chat_owner_changed: Option<ChatOwnerChanged>, pub chat_owner_left: Option<ChatOwnerLeft>, pub managed_bot_created: Option<ManagedBotCreated>, pub poll_option_added: Option<PollOptionAdded>, pub poll_option_deleted: Option<PollOptionDeleted>, pub reply_to_poll_option_id: Option<String>,
}
Expand description

This object represents a message.

Corresponds to the Bot API Message object.

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§message_id: i64

Unique message identifier inside this chat.

§date: i64

Date the message was sent in Unix time.

§chat: Chat

Conversation the message belongs to.

§from_user: Option<User>

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.

Renamed from Python’s from (reserved keyword).

§sender_chat: Option<Chat>

Sender of the message when sent on behalf of a chat.

§sender_boost_count: Option<i32>

If the sender of the message boosted the chat, the number of boosts added by the user.

§sender_business_bot: Option<User>

Bot through which the message was sent.

§business_connection_id: Option<String>

Unique identifier of the business connection from which the message was received.

§message_thread_id: Option<i64>

Unique identifier of a message thread to which the message belongs; for supergroups only.

§is_topic_message: bool

true if the message is sent to a forum topic.

§forward_origin: Option<MessageOrigin>

Information about the original message for forwarded messages.

§is_automatic_forward: bool

true if the message is a channel post that was automatically forwarded to the connected discussion group.

§reply_to_message: Option<Box<Message>>

For replies in the same chat and message thread, the original message. Note: The Message object in this field will not contain further reply_to_message fields even if it itself is a reply.

§external_reply: Option<Box<ExternalReplyInfo>>

Information about the message that is being replied to, which may come from another chat or forum topic.

§quote: Option<TextQuote>

For replies that quote part of the original message, the quoted part of the message.

§reply_to_story: Option<Story>

For replies to a story, the original story.

§via_bot: Option<User>

Bot that originated the query if the message is a response to an inline query.

§edit_date: Option<i64>

Date the message was last edited in Unix time.

§has_protected_content: bool

true if the message can’t be forwarded.

§is_from_offline: bool

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.

§is_paid_post: bool

true if the message is a paid post.

§media_group_id: Option<String>

The unique identifier of a media message group this message belongs to.

§author_signature: Option<String>

Signature of the post author for messages in channels, or the custom title of an anonymous group administrator.

§sender_tag: Option<String>

Tag of the user who posted the message if it is anonymous.

§text: Option<String>

For text messages, the actual UTF-8 text of the message.

§entities: Option<Vec<MessageEntity>>

For text messages, special entities like usernames, URLs, bot commands etc. that appear in the text.

§link_preview_options: Option<LinkPreviewOptions>

Options used for link preview generation for the message, if it is a text message and link preview options were changed.

§effect_id: Option<String>

Unique identifier of the message effect added to the message.

§animation: Option<Animation>

Message is an animation, information about the animation.

§audio: Option<Audio>

Message is an audio file, information about the file.

§document: Option<Document>

Message is a general file, information about the file.

§paid_media: Option<PaidMediaInfo>

Message contains paid media; information about the paid media.

§photo: Option<Vec<PhotoSize>>

Message is a photo, available sizes of the photo.

§sticker: Option<Sticker>

Message is a sticker, information about the sticker.

§story: Option<Story>

Message is a forwarded story.

§video: Option<Video>

Message is a video, information about the video.

§video_note: Option<VideoNote>

Message is a video note, information about the video message.

§voice: Option<Voice>

Message is a voice message, information about the file.

§caption: Option<String>

Caption for the animation, audio, document, paid media, photo, video or voice.

§caption_entities: Option<Vec<MessageEntity>>

For messages with a caption, special entities like usernames, URLs, bot commands etc. that appear in the caption.

§show_caption_above_media: bool

true if the caption must be shown above the message media.

§has_media_spoiler: bool

true if the message media is covered by a spoiler animation.

§contact: Option<Contact>

Message is a shared contact, information about the contact.

§dice: Option<Dice>

Message is a dice with random value.

§game: Option<Box<Game>>

Message is a game, information about the game.

§poll: Option<Box<Poll>>

Message is a native poll, information about the poll.

§venue: Option<Box<Venue>>

Message is a venue, information about the venue.

§location: Option<Location>

Message is a shared location, information about the location.

§new_chat_members: Option<Vec<User>>

New members that were added to the group or supergroup.

§left_chat_member: Option<User>

A member was removed from the group.

§new_chat_title: Option<String>

A chat title was changed to this value.

§new_chat_photo: Option<Vec<PhotoSize>>

A chat photo was changed to this value.

§delete_chat_photo: bool

Service message: the chat photo was deleted.

§group_chat_created: bool

Service message: the group has been created.

§supergroup_chat_created: bool

Service message: the supergroup has been created.

§channel_chat_created: bool

Service message: the channel has been created.

§message_auto_delete_timer_changed: Option<MessageAutoDeleteTimerChanged>

Service message: auto-delete timer settings changed in the chat.

§migrate_to_chat_id: Option<i64>

The group has been migrated to a supergroup with the specified identifier.

§migrate_from_chat_id: Option<i64>

The supergroup has been migrated from a group with the specified identifier.

§pinned_message: Option<Box<Message>>

Specified message was pinned.

§invoice: Option<Box<Invoice>>

Message is an invoice for a payment, information about the invoice.

§successful_payment: Option<Box<SuccessfulPayment>>

Message is a service message about a successful payment.

§refunded_payment: Option<Box<RefundedPayment>>

Message is a service message about a refunded payment.

§paid_message_price_changed: Option<PaidMessagePriceChanged>

Message is a service message about the paid message price changing.

§paid_star_count: Option<i32>

The number of Telegram Stars that were paid by the sender of the message to send it.

§connected_website: Option<String>

Service message: the user is connected to a website via the connected website feature.

§write_access_allowed: Option<WriteAccessAllowed>

Write access was allowed.

§passport_data: Option<Box<PassportData>>

Telegram Passport data.

§proximity_alert_triggered: Option<ProximityAlertTriggered>

Service message: a user in the chat triggered another user’s proximity alert while sharing Live Location.

§boost_added: Option<ChatBoostAdded>

Service message: user boosted the chat.

§chat_background_set: Option<ChatBackground>

Service message: chat background set.

§forum_topic_created: Option<ForumTopicCreated>

Service message: forum topic created.

§forum_topic_edited: Option<ForumTopicEdited>

Service message: forum topic edited.

§forum_topic_closed: Option<ForumTopicClosed>

Service message: forum topic closed.

§forum_topic_reopened: Option<ForumTopicReopened>

Service message: forum topic reopened.

§general_forum_topic_hidden: Option<GeneralForumTopicHidden>

Service message: the General forum topic hidden.

§general_forum_topic_unhidden: Option<GeneralForumTopicUnhidden>

Service message: the General forum topic unhidden.

§giveaway_created: Option<GiveawayCreated>

Service message: a scheduled giveaway was created.

§giveaway: Option<Box<Giveaway>>

The message is a scheduled giveaway message.

§giveaway_winners: Option<Box<GiveawayWinners>>

A giveaway with public winners was completed.

§giveaway_completed: Option<Box<GiveawayCompleted>>

Service message: a giveaway without public winners was completed.

§video_chat_scheduled: Option<VideoChatScheduled>

Service message: video chat scheduled.

§video_chat_started: Option<VideoChatStarted>

Service message: video chat started.

§video_chat_ended: Option<VideoChatEnded>

Service message: video chat ended.

§video_chat_participants_invited: Option<VideoChatParticipantsInvited>

Service message: new participants invited to a video chat.

§web_app_data: Option<WebAppData>

Service message: data sent by a Web App.

§reply_markup: Option<InlineKeyboardMarkup>

Inline keyboard attached to the message.

§users_shared: Option<UsersShared>

Service message: users were shared with the bot.

§chat_shared: Option<ChatShared>

Service message: a chat was shared with the bot.

§gift: Option<GiftInfo>

Message is a gift.

§unique_gift: Option<UniqueGiftInfo>

A unique gift was sent or received.

§gift_upgrade_sent: Option<GiftInfo>

Service message: a gift was upgraded and the original gift was sent to the receiver.

§checklist: Option<Checklist>

Message contains a checklist.

§checklist_tasks_done: Option<ChecklistTasksDone>

Service message: checklist tasks were done.

§checklist_tasks_added: Option<ChecklistTasksAdded>

Service message: checklist tasks were added.

§reply_to_checklist_task_id: Option<i64>

Identifier of the checklist task the message is a reply to.

§direct_message_price_changed: Option<DirectMessagePriceChanged>

Service message: direct message price changed.

§direct_messages_topic: Option<DirectMessagesTopic>

Service message: the topic of a direct messages chat.

§suggested_post_declined: Option<SuggestedPostDeclined>

Service message: a suggested post was declined.

§suggested_post_paid: Option<SuggestedPostPaid>

Service message: a suggested post was paid.

§suggested_post_refunded: Option<SuggestedPostRefunded>

Service message: a suggested post was refunded.

§suggested_post_info: Option<SuggestedPostInfo>

Information about a suggested post in the channel.

§suggested_post_approved: Option<SuggestedPostApproved>

Service message: a suggested post was approved.

§suggested_post_approval_failed: Option<SuggestedPostApprovalFailed>

Service message: a suggested post approval failed.

§chat_owner_changed: Option<ChatOwnerChanged>

Service message: chat owner changed.

§chat_owner_left: Option<ChatOwnerLeft>

Service message: chat owner left.

§managed_bot_created: Option<ManagedBotCreated>

Service message: user created a bot that will be managed by the current bot.

Added in Bot API 9.6.

§poll_option_added: Option<PollOptionAdded>

Service message: answer option was added to a poll.

Added in Bot API 9.6.

§poll_option_deleted: Option<PollOptionDeleted>

Service message: answer option was deleted from a poll.

Added in Bot API 9.6.

§reply_to_poll_option_id: Option<String>

Persistent identifier of the poll option the message is a reply to.

Added in Bot API 9.6.

Trait Implementations§

Source§

impl Clone for Message

Source§

fn clone(&self) -> Message

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Message

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for Message

Source§

fn deserialize<__D>( __deserializer: __D, ) -> Result<Message, <__D as Deserializer<'de>>::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for Message

Source§

fn eq(&self, other: &Message) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for Message

Source§

fn serialize<__S>( &self, __serializer: __S, ) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for Message

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,