Skip to main content

Message

Struct Message 

Source
pub struct Message {
Show 71 fields pub message_id: i64, pub message_thread_id: Option<i64>, pub from: Option<User>, pub sender_chat: Option<Chat>, pub sender_boost_count: Option<u32>, pub sender_business_bot: Option<User>, pub date: i64, pub business_connection_id: Option<String>, pub chat: Chat, pub forward_origin: Option<MessageOrigin>, pub is_topic_message: Option<bool>, pub is_automatic_forward: Option<bool>, pub reply_to_message: Option<Box<Message>>, pub external_reply: Option<ExternalReplyInfo>, pub quote: Option<TextQuote>, pub reply_to_story: Option<Value>, pub via_bot: Option<User>, pub edit_date: Option<i64>, pub has_protected_content: Option<bool>, pub is_from_offline: Option<bool>, pub media_group_id: Option<String>, pub author_signature: 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<Value>, pub photo: Option<Vec<PhotoSize>>, pub sticker: Option<Sticker>, pub story: Option<Value>, 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: Option<bool>, pub has_media_spoiler: Option<bool>, pub contact: Option<Contact>, pub dice: Option<Dice>, pub game: Option<Value>, pub poll: Option<Poll>, pub venue: Option<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: Option<bool>, pub group_chat_created: Option<bool>, pub supergroup_chat_created: Option<bool>, pub channel_chat_created: Option<bool>, pub message_auto_delete_timer_changed: Option<Value>, pub migrate_to_chat_id: Option<i64>, pub migrate_from_chat_id: Option<i64>, pub pinned_message: Option<Box<Message>>, pub reply_markup: Option<InlineKeyboardMarkup>, pub invoice: Option<Value>, pub successful_payment: Option<Value>, pub refunded_payment: Option<Value>, pub web_app_data: Option<WebAppData>, pub forum_topic_created: Option<Value>, pub forum_topic_edited: Option<Value>, pub forum_topic_closed: Option<Value>, pub forum_topic_reopened: Option<Value>, pub general_forum_topic_hidden: Option<Value>, pub general_forum_topic_unhidden: Option<Value>, pub direct_messages_topic_id: Option<i64>, pub suggested_post: Option<Value>,
}
Expand description

A Telegram message.

Only fields that were actually sent will be Some. Consult the official Bot API documentation for field availability rules.

Fields§

§message_id: i64

Unique message identifier inside this chat.

§message_thread_id: Option<i64>

Optional — unique identifier of a message thread to which the message belongs.

§from: Option<User>

Sender of the message, empty for messages sent to channels.

§sender_chat: Option<Chat>

Sender of the message; empty for messages sent to channels or on behalf of a chat.

§sender_boost_count: Option<u32>

For supergroup messages — boost count of the sender.

§sender_business_bot: Option<User>

The bot that actually sent the message on behalf of the business account.

§date: i64

Date the message was sent , as a Unix timestamp.

§business_connection_id: Option<String>

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

§chat: Chat

Conversation the message belongs to.

§forward_origin: Option<MessageOrigin>

Information about the original message for forwarded messages.

§is_topic_message: Option<bool>

true if the message is sent to a forum topic.

§is_automatic_forward: Option<bool>

true if the message is a channel post 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.

§external_reply: Option<ExternalReplyInfo>

Information about the message that is being replied to by the current message.

§quote: Option<TextQuote>

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

§reply_to_story: Option<Value>

For replies to a story, the original story.

§via_bot: Option<User>

Bot through which the message was sent.

§edit_date: Option<i64>

Date the message was last edited, as a Unix timestamp.

§has_protected_content: Option<bool>

true if the message can’t be forwarded.

§is_from_offline: Option<bool>

true if the message was sent by an implicit action.

§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.

§text: Option<String>

Actual UTF-8 text of the message (0–4096 characters).

§entities: Option<Vec<MessageEntity>>

Special entities like usernames, URLs, bot commands, etc.

§link_preview_options: Option<LinkPreviewOptions>

Options used for link preview generation.

§effect_id: Option<String>

Unique identifier of the message effect added to the message.

§animation: Option<Animation>

Animation attached to the message.

§audio: Option<Audio>

Audio file attached to the message.

§document: Option<Document>

Document attached to the message.

§paid_media: Option<Value>

Paid media attached to the message.

§photo: Option<Vec<PhotoSize>>

Photo attached to the message (array of sizes).

§sticker: Option<Sticker>

Sticker attached to the message.

§story: Option<Value>

Story attached to the message.

§video: Option<Video>

Video attached to the message.

§video_note: Option<VideoNote>

Video note attached to the message.

§voice: Option<Voice>

Voice note attached to the message.

§caption: Option<String>

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

§caption_entities: Option<Vec<MessageEntity>>

Special entities in the caption.

§show_caption_above_media: Option<bool>

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

§has_media_spoiler: Option<bool>

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

§contact: Option<Contact>

Contact shared in the message.

§dice: Option<Dice>

Dice result in the message.

§game: Option<Value>

Game in the message.

§poll: Option<Poll>

Poll in the message.

§venue: Option<Venue>

Venue in the message.

§location: Option<Location>

Location in the message.

§new_chat_members: Option<Vec<User>>

New members that joined the group.

§left_chat_member: Option<User>

A member that left the group.

§new_chat_title: Option<String>

New chat title (service message).

§new_chat_photo: Option<Vec<PhotoSize>>

New chat photo (service message).

§delete_chat_photo: Option<bool>

true if the chat photo was deleted (service message).

§group_chat_created: Option<bool>

true if the group was created (service message).

§supergroup_chat_created: Option<bool>

true if the supergroup was created (service message).

§channel_chat_created: Option<bool>

true if the channel was created (service message).

§message_auto_delete_timer_changed: Option<Value>

Auto-delete timer changed (service message).

§migrate_to_chat_id: Option<i64>

The group has been migrated to a supergroup with this ID.

§migrate_from_chat_id: Option<i64>

The supergroup has been migrated from a group with this ID.

§pinned_message: Option<Box<Message>>

The pinned message (service message).

§reply_markup: Option<InlineKeyboardMarkup>

Inline keyboard attached to the message.

§invoice: Option<Value>

Invoice for a payment (service message).

§successful_payment: Option<Value>

Successful payment information (service message).

§refunded_payment: Option<Value>

Refunded payment information (service message).

§web_app_data: Option<WebAppData>

Data from the Web App.

§forum_topic_created: Option<Value>

Forum topic created (service message).

§forum_topic_edited: Option<Value>

Forum topic edited (service message).

§forum_topic_closed: Option<Value>

Forum topic closed (service message).

§forum_topic_reopened: Option<Value>

Forum topic reopened (service message).

§general_forum_topic_hidden: Option<Value>

General forum topic hidden (service message).

§general_forum_topic_unhidden: Option<Value>

General forum topic unhidden (service message).

§direct_messages_topic_id: Option<i64>

Direct messages topic identifier.

§suggested_post: Option<Value>

Suggested post information.

Implementations§

Source§

impl Message

Source

pub fn effective_text(&self) -> Option<&str>

Returns the effective text of the message — text or caption.

Source

pub fn is_command(&self) -> bool

Returns true if the message is a command (text starts with /).

Source

pub fn command(&self) -> Option<&str>

Extracts the command string (e.g. "start" from /start@bot), if present.

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

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

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

Source§

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

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

impl Serialize for Message

Source§

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

Serialize this value into the given Serde serializer. Read more

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, 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> 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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,