pub struct Message {
pub id: MessageId,
pub thread_id: Option<i32>,
pub date: DateTime<Utc>,
pub chat: Chat,
pub via_bot: Option<User>,
pub kind: MessageKind,
}Expand description
This object represents a message.
Fields§
§id: MessageIdUnique message identifier inside this chat.
thread_id: Option<i32>Unique identifier of a message thread to which the message belongs; for supergroups only.
date: DateTime<Utc>Date the message was sent in Unix time.
chat: ChatConversation the message belongs to.
via_bot: Option<User>Bot through which the message was sent.
kind: MessageKindImplementations§
Source§impl Message
Getters for Message fields from telegram docs.
impl Message
Getters for Message fields from telegram docs.
pub fn sender_chat(&self) -> Option<&Chat>
pub fn chat_id(&self) -> ChatId
.chat.id field insteadpub fn forward(&self) -> Option<&Forward>
pub fn forward_date(&self) -> Option<DateTime<Utc>>
pub fn forward_from(&self) -> Option<&ForwardedFrom>
pub fn forward_from_user(&self) -> Option<&User>
pub fn forward_from_chat(&self) -> Option<&Chat>
pub fn forward_from_sender_name(&self) -> Option<&str>
pub fn forward_from_message_id(&self) -> Option<i32>
pub fn forward_signature(&self) -> Option<&str>
pub fn reply_to_message(&self) -> Option<&Message>
pub fn edit_date(&self) -> Option<&DateTime<Utc>>
pub fn media_group_id(&self) -> Option<&str>
pub fn text(&self) -> Option<&str>
Sourcepub fn entities(&self) -> Option<&[MessageEntity]>
pub fn entities(&self) -> Option<&[MessageEntity]>
Returns message entities that represent text formatting.
Note: you probably want to use parse_entities instead.
This function returns Some(entities) for text messages and
None for all other kinds of messages (including photos with
captions).
See also: caption_entities.
Sourcepub fn caption_entities(&self) -> Option<&[MessageEntity]>
pub fn caption_entities(&self) -> Option<&[MessageEntity]>
Returns message entities that represent text formatting.
Note: you probably want to use parse_caption_entities
instead.
This function returns Some(entities) for media messages and
None for all other kinds of messages (including text messages).
See also: entities.
Sourcepub fn has_media_spoiler(&self) -> bool
pub fn has_media_spoiler(&self) -> bool
Returns true if the message media is covered by a spoiler
animation.
Getter for MediaPhoto::has_media_spoiler,
MediaVideo::has_media_spoiler and
MediaAnimation::has_media_spoiler.
pub fn audio(&self) -> Option<&Audio>
pub fn document(&self) -> Option<&Document>
pub fn animation(&self) -> Option<&Animation>
pub fn game(&self) -> Option<&Game>
pub fn photo(&self) -> Option<&[PhotoSize]>
pub fn sticker(&self) -> Option<&Sticker>
pub fn video(&self) -> Option<&Video>
pub fn voice(&self) -> Option<&Voice>
pub fn video_note(&self) -> Option<&VideoNote>
pub fn caption(&self) -> Option<&str>
pub fn contact(&self) -> Option<&Contact>
pub fn location(&self) -> Option<&Location>
pub fn venue(&self) -> Option<&Venue>
pub fn poll(&self) -> Option<&Poll>
pub fn new_chat_members(&self) -> Option<&[User]>
pub fn left_chat_member(&self) -> Option<&User>
pub fn new_chat_title(&self) -> Option<&str>
pub fn new_chat_photo(&self) -> Option<&[PhotoSize]>
pub fn delete_chat_photo(&self) -> Option<True>
pub fn group_chat_created(&self) -> Option<True>
pub fn super_group_chat_created(&self) -> Option<True>
pub fn channel_chat_created(&self) -> Option<True>
pub fn chat_migration(&self) -> Option<ChatMigration>
pub fn migrate_to_chat_id(&self) -> Option<ChatId>
pub fn migrate_from_chat_id(&self) -> Option<ChatId>
pub fn pinned_message(&self) -> Option<&Message>
pub fn invoice(&self) -> Option<&Invoice>
pub fn successful_payment(&self) -> Option<&SuccessfulPayment>
pub fn connected_website(&self) -> Option<&str>
pub fn passport_data(&self) -> Option<&PassportData>
pub fn dice(&self) -> Option<&Dice>
pub fn proximity_alert_triggered(&self) -> Option<&ProximityAlertTriggered>
pub fn video_chat_participants_invited( &self, ) -> Option<&VideoChatParticipantsInvited>
pub fn reply_markup(&self) -> Option<&InlineKeyboardMarkup>
pub fn is_automatic_forward(&self) -> bool
pub fn has_protected_content(&self) -> bool
Source§impl Message
impl Message
Sourcepub fn url(&self) -> Option<Url>
pub fn url(&self) -> Option<Url>
Produces a direct link to this message.
Note that for private groups the link will only be accessible for group members.
Returns None for private chats (i.e.: DMs) and private groups (not
supergroups).
Sourcepub fn url_of(
chat_id: ChatId,
chat_username: Option<&str>,
message_id: MessageId,
) -> Option<Url>
pub fn url_of( chat_id: ChatId, chat_username: Option<&str>, message_id: MessageId, ) -> Option<Url>
Produces a direct link to a message in a chat.
If you have a Message object, use url instead.
This function should only be used if you have limited information about
the message (chat id, username of the chat, if any and its id).
Note that for private groups the link will only be accessible for group members.
Returns None for private chats (i.e.: DMs) and private groups (not
supergroups).
Sourcepub fn comment_url(&self, comment_id: MessageId) -> Option<Url>
pub fn comment_url(&self, comment_id: MessageId) -> Option<Url>
Produces a direct link to a comment on this post.
Note that for private channels the link will only be accessible for channel members.
Returns None for private chats (i.e.: DMs) and private groups (not
supergroups).
Sourcepub fn comment_url_of(
channel_id: ChatId,
channel_username: Option<&str>,
post_id: MessageId,
comment_id: MessageId,
) -> Option<Url>
pub fn comment_url_of( channel_id: ChatId, channel_username: Option<&str>, post_id: MessageId, comment_id: MessageId, ) -> Option<Url>
Produces a direct link to a comment on a post.
If you have a Message object of the channel post, use comment_url
instead. This function should only be used if you have limited
information about the message (channel id, username of the channel,
if any, post id and comment id).
Note that for private channels the link will only be accessible for channel members.
Returns None for private chats (i.e.: DMs) and private groups (not
supergroups).
Sourcepub fn url_in_thread(&self, thread_starter_msg_id: MessageId) -> Option<Url>
pub fn url_in_thread(&self, thread_starter_msg_id: MessageId) -> Option<Url>
Produces a direct link to this message in a given thread.
“Thread” is a group of messages that reply to each other in a tree-like
structure. thread_starter_msg_id is the id of the first message in
the thread, the root of the tree.
Note that for private groups the link will only be accessible for group members.
Returns None for private chats (i.e.: DMs) and private groups (not
supergroups).
Sourcepub fn url_in_thread_of(
chat_id: ChatId,
chat_username: Option<&str>,
thread_starter_msg_id: MessageId,
message_id: MessageId,
) -> Option<Url>
pub fn url_in_thread_of( chat_id: ChatId, chat_username: Option<&str>, thread_starter_msg_id: MessageId, message_id: MessageId, ) -> Option<Url>
Produces a direct link to a message in a given thread.
If you have a Message object of the channel post, use
url_in_thread instead. This function should only be used if you
have limited information about the message (chat id, username of the
chat, if any, thread starter id and message id).
“Thread” is a group of messages that reply to each other in a tree-like
structure. thread_starter_msg_id is the id of the first message in
the thread, the root of the tree.
Note that for private groups the link will only be accessible for group members.
Returns None for private chats (i.e.: DMs) and private groups (not
supergroups).
Sourcepub fn parse_entities(&self) -> Option<Vec<MessageEntityRef<'_>>>
pub fn parse_entities(&self) -> Option<Vec<MessageEntityRef<'_>>>
Returns message entities that represent text formatting.
This function returns Some(entities) for text messages and
None for all other kinds of messages (including photos with
captions).
See also: parse_caption_entities.
Sourcepub fn parse_caption_entities(&self) -> Option<Vec<MessageEntityRef<'_>>>
pub fn parse_caption_entities(&self) -> Option<Vec<MessageEntityRef<'_>>>
Returns message entities that represent text formatting.
This function returns Some(entities) for media messages and
None for all other kinds of messages (including text messages).
See also: parse_entities.
Sourcepub fn mentioned_users(&self) -> impl Iterator<Item = &User>
pub fn mentioned_users(&self) -> impl Iterator<Item = &User>
Returns all users that are “contained” in this Message structure.
This might be useful to track information about users.
Note that this function may return quite a few users as it scans replies, pinned messages, message entities and more. Also note that this function can return duplicate users.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Message
impl<'de> Deserialize<'de> for Message
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl StructuralPartialEq for Message
Auto Trait Implementations§
impl Freeze for Message
impl RefUnwindSafe for Message
impl Send for Message
impl Sync for Message
impl Unpin for Message
impl UnwindSafe for Message
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Erasable for T
impl<T> Erasable for T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more