Struct teloxide::types::Message

source ·
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.

The official docs.

Fields§

§id: MessageId

Unique 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: Chat

Conversation the message belongs to.

§via_bot: Option<User>

Bot through which the message was sent.

§kind: MessageKind

Implementations§

source§

impl Message

Getters for Message fields from telegram docs.

source

pub fn from(&self) -> Option<&User>

Returns the user who sent the message.

source

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

source

pub fn sender_chat(&self) -> Option<&Chat>

source

pub fn chat_id(&self) -> ChatId

👎Deprecated since 0.4.2: use .chat.id field instead
source

pub fn forward(&self) -> Option<&Forward>

source

pub fn forward_date(&self) -> Option<DateTime<Utc>>

source

pub fn forward_from(&self) -> Option<&ForwardedFrom>

source

pub fn forward_from_user(&self) -> Option<&User>

source

pub fn forward_from_chat(&self) -> Option<&Chat>

source

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

source

pub fn forward_from_message_id(&self) -> Option<i32>

source

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

source

pub fn reply_to_message(&self) -> Option<&Message>

source

pub fn edit_date(&self) -> Option<&DateTime<Utc>>

source

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

source

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

source

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.

source

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.

source

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.

source

pub fn audio(&self) -> Option<&Audio>

source

pub fn document(&self) -> Option<&Document>

source

pub fn animation(&self) -> Option<&Animation>

source

pub fn game(&self) -> Option<&Game>

source

pub fn photo(&self) -> Option<&[PhotoSize]>

source

pub fn sticker(&self) -> Option<&Sticker>

source

pub fn video(&self) -> Option<&Video>

source

pub fn voice(&self) -> Option<&Voice>

source

pub fn video_note(&self) -> Option<&VideoNote>

source

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

source

pub fn contact(&self) -> Option<&Contact>

source

pub fn location(&self) -> Option<&Location>

source

pub fn venue(&self) -> Option<&Venue>

source

pub fn poll(&self) -> Option<&Poll>

source

pub fn new_chat_members(&self) -> Option<&[User]>

source

pub fn left_chat_member(&self) -> Option<&User>

source

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

source

pub fn new_chat_photo(&self) -> Option<&[PhotoSize]>

source

pub fn delete_chat_photo(&self) -> Option<True>

source

pub fn group_chat_created(&self) -> Option<True>

source

pub fn super_group_chat_created(&self) -> Option<True>

source

pub fn channel_chat_created(&self) -> Option<True>

source

pub fn chat_migration(&self) -> Option<ChatMigration>

source

pub fn migrate_to_chat_id(&self) -> Option<ChatId>

source

pub fn migrate_from_chat_id(&self) -> Option<ChatId>

source

pub fn pinned_message(&self) -> Option<&Message>

source

pub fn invoice(&self) -> Option<&Invoice>

source

pub fn successful_payment(&self) -> Option<&SuccessfulPayment>

source

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

source

pub fn passport_data(&self) -> Option<&PassportData>

source

pub fn dice(&self) -> Option<&Dice>

source

pub fn proximity_alert_triggered(&self) -> Option<&ProximityAlertTriggered>

source

pub fn reply_markup(&self) -> Option<&InlineKeyboardMarkup>

source

pub fn is_automatic_forward(&self) -> bool

source

pub fn has_protected_content(&self) -> bool

source§

impl Message

source

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

source

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

source

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

source

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

source

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

source

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

source

pub fn parse_entities(&self) -> Option<Vec<MessageEntityRef<'_>, Global>>

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.

source

pub fn parse_caption_entities( &self ) -> Option<Vec<MessageEntityRef<'_>, Global>>

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.

Trait Implementations§

source§

impl Clone for Message

source§

fn clone(&self) -> Message

Returns a copy 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 GetChatId for Message

source§

impl<Out> MessageFilterExt<Out> for Messagewhere Out: Send + Sync + 'static,

source§

fn filter_from() -> Handler<'static, DependencyMap, Out, DpHandlerDescription>

Applies the Message::from filter.
source§

fn filter_animation( ) -> Handler<'static, DependencyMap, Out, DpHandlerDescription>

Applies the Message::animation filter.
source§

fn filter_audio() -> Handler<'static, DependencyMap, Out, DpHandlerDescription>

Applies the Message::audio filter.
source§

fn filter_contact( ) -> Handler<'static, DependencyMap, Out, DpHandlerDescription>

Applies the Message::contact filter.
source§

fn filter_document( ) -> Handler<'static, DependencyMap, Out, DpHandlerDescription>

Applies the Message::document filter.
source§

fn filter_location( ) -> Handler<'static, DependencyMap, Out, DpHandlerDescription>

Applies the Message::location filter.
source§

fn filter_photo() -> Handler<'static, DependencyMap, Out, DpHandlerDescription>

Applies the Message::photo filter.
source§

fn filter_poll() -> Handler<'static, DependencyMap, Out, DpHandlerDescription>

Applies the Message::poll filter.
source§

fn filter_sticker( ) -> Handler<'static, DependencyMap, Out, DpHandlerDescription>

Applies the Message::sticker filter.
source§

fn filter_text() -> Handler<'static, DependencyMap, Out, DpHandlerDescription>

Applies the Message::text filter.
source§

fn filter_reply_to_message( ) -> Handler<'static, DependencyMap, Out, DpHandlerDescription>

Applies the Message::reply_to_message filter.
source§

fn filter_forward_from( ) -> Handler<'static, DependencyMap, Out, DpHandlerDescription>

Applies the Message::forward_from filter.
source§

fn filter_new_chat_members( ) -> Handler<'static, DependencyMap, Out, DpHandlerDescription>

Applies the Message::new_chat_members filter.
source§

fn filter_left_chat_member( ) -> Handler<'static, DependencyMap, Out, DpHandlerDescription>

Applies the Message::left_chat_member filter.
source§

fn filter_pinned() -> Handler<'static, DependencyMap, Out, DpHandlerDescription>

Applies the Message::pinned_message filter.
source§

fn filter_dice() -> Handler<'static, DependencyMap, Out, DpHandlerDescription>

Applies the Message::dice filter.
source§

impl PartialEq<Message> for Message

source§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method 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 Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

const: unstable · source§

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

Mutably borrows from an owned value. Read more
§

impl<T> Erasable for T

§

unsafe fn unerase(this: NonNull<Erased>) -> NonNull<T>

Unerase this erased pointer. Read more
§

const ACK_1_1_0: bool = true

Available on non-enforce_1_1_0_semantics only.
Whether this implementor has acknowledged the 1.1.0 update to unerase’s documented implementation requirements. Read more
§

fn erase(this: NonNull<Self>) -> NonNull<Erased>

Turn this erasable pointer into an erased pointer. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> FromRef<T> for Twhere T: Clone,

§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
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 Twhere U: From<T>,

const: unstable · 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 Twhere T: Clone,

§

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 Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
source§

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

§

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

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V

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