Struct grammers_client::types::message::Message [−][src]
pub struct Message { /* fields omitted */ }Represents a Telegram message, which includes text messages, messages with media, and service messages.
This message should be treated as a snapshot in time, that is, if the message is edited while using this object, those changes won’t alter this structure.
Implementations
impl Message[src]
impl Message[src]pub fn outgoing(&self) -> bool[src]
Whether the message is outgoing (i.e. you sent this message to some other chat) or incoming (i.e. someone else sent it to you or the chat).
pub fn mentioned(&self) -> bool[src]
Whether you were mentioned in this message or not.
This includes @username mentions, text mentions, and messages replying to one of your previous messages (even if it contains no mention in the message text).
pub fn media_unread(&self) -> bool[src]
Whether you have read the media in this message or not.
Most commonly, these are voice notes that you have not played yet.
pub fn silent(&self) -> bool[src]
Whether the message should notify people with sound or not.
pub fn post(&self) -> bool[src]
Whether this message is a post in a broadcast channel or not.
pub fn from_scheduled(&self) -> bool[src]
Whether this message was originated from a previously-scheduled message or not.
pub fn edit_hide(&self) -> bool[src]
Whether the edited mark of this message is edited should be hidden (e.g. in GUI clients) or shown.
pub fn pinned(&self) -> bool[src]
Whether this message is currently pinned or not.
pub fn id(&self) -> i32[src]
The ID of this message.
Message identifiers are counters that start at 1 and grow by 1 for each message produced.
Every channel has its own unique message counter. This counter is the same for all users, but unique to each channel.
Every account has another unique message counter which is used for private conversations and small group chats. This means different accounts will likely have different message identifiers for the same message in a private conversation or small group chat. This also implies that the message identifier alone is enough to uniquely identify the message, without the need to know the chat ID.
You cannot use the message ID of User A when running as User B, unless this message
belongs to a megagroup or broadcast channel. Beware of this when using methods like
Client::delete_messages, which cannot validate the chat where the message
should be deleted for those cases.
pub fn sender(&self) -> Option<Chat>[src]
The sender of this message, if any.
pub fn chat(&self) -> Chat[src]
The chat where this message was sent to.
This might be the user you’re talking to for private conversations, or the group or channel where the message was sent.
pub fn forward_header(&self) -> Option<MessageFwdHeader>[src]
If this message was forwarded from a previous message, return the header with information about that forward.
pub fn via_bot_id(&self) -> Option<i32>[src]
If this message was sent @via some inline bot, return the bot’s user identifier.
pub fn reply_header(&self) -> Option<MessageReplyHeader>[src]
If this message is replying to a previous message, return the header with information about that reply.
pub fn date(&self) -> DateTime<Utc>[src]
The date when this message was produced.
pub fn text(&self) -> &str[src]
The message’s text.
For service messages, this will be the empty strings.
If the message has media, this text is the caption commonly displayed underneath it.
pub fn media(&self) -> Option<Media>[src]
The media displayed by this message, if any.
This not only includes photos or videos, but also contacts, polls, documents, locations and many other types.
pub fn reply_markup(&self) -> Option<ReplyMarkup>[src]
If the message has a reply markup (which can happen for messages produced by bots), returns said markup.
pub fn fmt_entities(&self) -> Option<&Vec<MessageEntity>>[src]
The formatting entities used to format this message, such as bold, italic, with their offsets and lengths.
pub fn view_count(&self) -> Option<i32>[src]
How many views does this message have, when applicable.
The same user account can contribute to increment this counter indefinitedly, however there is a server-side cooldown limitting how fast it can happen (several hours).
pub fn forward_count(&self) -> Option<i32>[src]
How many times has this message been forwarded, when applicable.
pub fn reply_count(&self) -> Option<MessageReplies>[src]
How many replies does this message have, when applicable.
pub fn edit_date(&self) -> Option<DateTime<Utc>>[src]
The date when this message was last edited.
pub fn post_author(&self) -> Option<&str>[src]
If this message was sent to a channel, return the name used by the author to post it.
pub fn grouped_id(&self) -> Option<i64>[src]
If this message belongs to a group of messages, return the unique identifier for that group.
This applies to albums of media, such as multiple photos grouped together.
Note that there may be messages sent in between the messages forming a group.
pub fn restriction_reason(&self) -> Option<&Vec<RestrictionReason>>[src]
A list of reasons on why this message is restricted.
The message is not restricted if the return value is None.
pub fn action(&self) -> Option<&MessageAction>[src]
If this message is a service message, return the service action that occured.
pub fn reply_to_message_id(&self) -> Option<i32>[src]
If this message is replying to another message, return the replied message ID.
pub async fn get_reply(&mut self) -> Result<Option<Self>, InvocationError>[src]
Fetch the message that this message is replying to, or None if this message is not a
reply to a previous message.
Shorthand for Client::get_reply_to_message.
pub async fn respond(
&mut self,
message: InputMessage
) -> Result<Self, InvocationError>[src]
&mut self,
message: InputMessage
) -> Result<Self, InvocationError>
Respond to this message by sending a new message in the same chat, but without directly replying to it.
Shorthand for Client::send_message.
pub async fn reply(
&mut self,
message: InputMessage
) -> Result<Self, InvocationError>[src]
&mut self,
message: InputMessage
) -> Result<Self, InvocationError>
Directly reply to this message by sending a new message in the same chat that replies to
it. This methods overrides the reply_to on the InputMessage to point to self.
Shorthand for Client::send_message.
pub async fn forward_to(&mut self, chat: &Chat) -> Result<Self, InvocationError>[src]
Forward this message to another (or the same) chat.
Shorthand for Client::forward_messages. If you need to forward multiple messages
at once, consider using that method instead.
pub async fn edit(
&mut self,
new_message: InputMessage
) -> Result<(), InvocationError>[src]
&mut self,
new_message: InputMessage
) -> Result<(), InvocationError>
Edit this message to change its text or media.
Shorthand for Client::edit_message.
pub async fn delete(&mut self) -> Result<(), InvocationError>[src]
Delete this message for everyone.
Shorthand for Client::delete_messages. If you need to delete multiple messages
at once, consider using that method instead.
pub async fn mark_as_read(&mut self) -> Result<(), InvocationError>[src]
Mark this message and all messages above it as read.
Unlike Client::mark_as_read, this method only will mark the chat as read up to
this message, not the entire chat.
pub async fn pin(&mut self) -> Result<(), InvocationError>[src]
Pin this message in the chat.
Shorthand for Client::pin_message.
pub async fn unpin(&mut self) -> Result<(), InvocationError>[src]
Unpin this message from the chat.
Shorthand for Client::unpin_message.
pub async fn refetch(&mut self) -> Result<(), InvocationError>[src]
Refetch this message, mutating all of its properties in-place.
No changes will be made to the message if it fails to be fetched.
Shorthand for Client::get_messages_by_id.
pub async fn download_media<P: AsRef<Path>>(
&mut self,
path: P
) -> Result<bool, Error>[src]
&mut self,
path: P
) -> Result<bool, Error>
Download the message media in this message if applicable.
Returns true if there was media to download, or false otherwise.
Shorthand for Client::download_media.
pub fn photo(&self) -> Option<Photo>[src]
Get photo attached to the message if any.
Trait Implementations
Auto Trait Implementations
impl !RefUnwindSafe for Message
impl !RefUnwindSafe for Messageimpl !UnwindSafe for Message
impl !UnwindSafe for Message