Struct Message

Source
pub struct Message {
Show 27 fields pub chat: Chat, pub date: Integer, pub edit_date: Option<Integer>, pub has_protected_content: bool, pub id: Integer, pub is_automatic_forward: bool, pub sender: MessageSender, pub author_signature: Option<String>, pub business_connection_id: Option<String>, pub effect_id: Option<String>, pub external_reply: Option<ExternalReplyInfo>, pub forward_origin: Option<MessageOrigin>, pub has_media_spoiler: Option<bool>, pub is_from_offline: Option<bool>, pub is_topic_message: Option<bool>, pub link_preview_options: Option<LinkPreviewOptions>, pub media_group_id: Option<String>, pub message_thread_id: Option<Integer>, pub paid_star_count: Option<Integer>, pub quote: Option<TextQuote>, pub reply_markup: Option<InlineKeyboardMarkup>, pub reply_to: Option<ReplyTo>, pub sender_boost_count: Option<Integer>, pub sender_business_bot: Option<User>, pub show_caption_above_media: Option<bool>, pub via_bot: Option<User>, pub data: MessageData,
}
Expand description

Represents a message.

Fields§

§chat: Chat

Chat the message belongs to.

§date: Integer

Date the message was sent in Unix time.

§edit_date: Option<Integer>

Date the message was last edited in Unix time.

§has_protected_content: bool

Indicates whether the message can’t be forwarded.

§id: Integer

Unique message identifier inside the chat.

§is_automatic_forward: bool

Indicates whether the message is a channel post that was automatically forwarded to the connected discussion group.

§sender: MessageSender

Sender of the message.

§author_signature: Option<String>

Author signature.

§business_connection_id: Option<String>

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

If non-empty, the message belongs to a chat of the corresponding business account that is independent from any potential bot chat which might share the same identifier.

§effect_id: Option<String>

Unique identifier of the message effect added to the message.

§external_reply: Option<ExternalReplyInfo>

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

§forward_origin: Option<MessageOrigin>

formation about the original message for forwarded messages.

§has_media_spoiler: Option<bool>

Indicates whether the message media is covered by a spoiler animation.

§is_from_offline: Option<bool>

Whether the message was sent by an implicit action.

For example, as an away or a greeting business message, or as a scheduled message.

§is_topic_message: Option<bool>

Indicates whether the message is sent to a forum topic.

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

§media_group_id: Option<String>

Unique identifier of a media message group this message belongs to.

§message_thread_id: Option<Integer>

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

§paid_star_count: Option<Integer>

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

§quote: Option<TextQuote>

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

§reply_markup: Option<InlineKeyboardMarkup>

Inline keyboard attached to the message.

§reply_to: Option<ReplyTo>

For replies, the original message or story.

§sender_boost_count: Option<Integer>

Number of boosts added by the user.

Contains a value only if the sender of the message boosted the chat.

§sender_business_bot: Option<User>

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

Available only for outgoing messages sent on behalf of the connected business account.

§show_caption_above_media: Option<bool>

Whether the caption must be shown above the message media.

§via_bot: Option<User>

Bot through which the message was sent.

§data: MessageData

Contains message data.

Implementations§

Source§

impl Message

Source

pub fn new<A, B>( id: Integer, date: Integer, chat: A, data: MessageData, sender: B, ) -> Self
where A: Into<Chat>, B: Into<MessageSender>,

Creates a new Message.

§Arguments
  • id - Unique message identifier inside the chat.
  • date - Date the message was sent in Unix time.
  • chat - Chat the message belongs to.
  • data - Data of the message.
  • sender - Sender of the message.
Source

pub fn is_edited(&self) -> bool

Returns true if the message has edited and false otherwise.

Source

pub fn get_text(&self) -> Option<&Text>

Returns a text of the message (includes caption).

Source

pub fn with_chat<T>(self, value: T) -> Self
where T: Into<Chat>,

Sets a new chat.

§Arguments
  • value - Chat.
Source

pub fn with_data(self, value: MessageData) -> Self

Sets a new data.

§Arguments
  • value - Data of the message.
Source

pub fn with_date(self, value: Integer) -> Self

Sets a new date.

§Arguments
  • value - Date; Unix timestamp.
Source

pub fn with_edit_date(self, value: Integer) -> Self

Sets a new edit date.

§Arguments
  • value - Edit date; Unix timestamp.
Source

pub fn with_effect_id<T>(self, value: T) -> Self
where T: Into<String>,

Sets a new effect ID.

§Arguments
  • value - Unique identifier of the message effect.
Source

pub fn with_has_protected_content(self, value: bool) -> Self

Sets a new value for the has_protected_content flag.

§Arguments
  • value - Indicates whether messages from the chat can’t be forwarded to other chats.
Source

pub fn with_id(self, value: Integer) -> Self

Sets a new ID.

§Arguments
  • value - Unique identifier inside a chat.
Source

pub fn with_is_automatic_forward(self, value: bool) -> Self

Sets a new value for the is_automatic_forward flag.

§Arguments
  • value - Indicates whether the message was automatically forwarded.
Source

pub fn with_sender<T>(self, value: T) -> Self
where T: Into<MessageSender>,

Sets a new sender.

§Arguments
  • value - Sender.
Source

pub fn with_author_signature<T>(self, value: T) -> Self
where T: Into<String>,

Sets a new author signature.

§Arguments
  • value - Author signature.
Source

pub fn with_business_connection_id<T>(self, value: T) -> Self
where T: Into<String>,

Sets a new business connection ID.

§Arguments
  • value - Unique identifier of the business connection from which the message was received.
Source

pub fn with_external_reply(self, value: ExternalReplyInfo) -> Self

Sets a new external reply.

§Arguments
  • value - Information about the message that is being replied to, which may come from another chat or forum topic.
Source

pub fn with_forward_origin(self, value: MessageOrigin) -> Self

Sets a new forward origin.

§Arguments
  • value - Information about the message origin.
Source

pub fn with_has_media_spoiler(self, value: bool) -> Self

Sets a new value for the has_media_spoiler flag.

§Arguments
  • value - Indicates whether the message has a media spoiler.
Source

pub fn with_is_from_offline(self, value: bool) -> Self

Sets a new value for the is_from_offline flag.

§Arguments
  • value - Indicates whether the message was sent by an implicit action.
Source

pub fn with_is_topic_message(self, value: bool) -> Self

Sets a new value for the is_topic_message flag.

§Arguments
  • value - Indicates whether the message is a topic message.

Sets a new link preview options.

§Arguments
  • value - New options.
Source

pub fn with_media_group_id<T>(self, value: T) -> Self
where T: Into<String>,

Sets a new media group ID.

§Arguments
  • value - Media group ID.
Source

pub fn with_message_thread_id(self, value: Integer) -> Self

Sets a new message thread ID.

§Arguments
  • value - Unique identifier of the target message thread; supergroups only.
Source

pub fn with_paid_star_count(self, value: Integer) -> Self

Sets a new paid star count

§Arguments
  • value - The number of Telegram Stars that were paid by the sender of the message to send it.
Source

pub fn with_quote(self, value: TextQuote) -> Self

Sets a new quote

§Arguments
  • value - The quoted part of the original message.
Source

pub fn with_reply_markup<T>(self, value: T) -> Self

Sets a new reply markup.

§Arguments
  • value - Reply markup.
Source

pub fn with_reply_to<T>(self, value: T) -> Self
where T: Into<ReplyTo>,

Sets a new original message or story for the reply.

§Arguments
  • value - For replies, the original message or story.
Source

pub fn with_sender_boost_count(self, value: Integer) -> Self

Sets a new sender boost count.

§Arguments
  • value - Number of boosts added by the user.
Source

pub fn with_sender_business_bot(self, value: User) -> Self

Sets a new bot.

§Arguments
  • value - The bot that actually sent the message on behalf of the business account.
Source

pub fn with_show_caption_above_media(self, value: bool) -> Self

Sets a new value for the show_caption_above_media flag.

§Arguments
  • value - Whether the caption must be shown above the message media.
Source

pub fn with_via_bot(self, value: User) -> Self

Sets a new bot.

§Arguments
  • value - Bot through which the message was sent.

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 From<Message> for ReplyTo

Source§

fn from(value: Message) -> Self

Converts to this type from the input type.
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::Ok, __S::Error>
where __S: Serializer,

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

impl TryFrom<Message> for Command

Source§

type Error = CommandError

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

fn try_from(message: Message) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Update> for Message

Source§

type Error = UnexpectedUpdate

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

fn try_from(value: Update) -> Result<Self, Self::Error>

Performs the conversion.
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> FromRef<T> for T
where T: Clone,

Source§

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 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>,

Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<A, B, T> HttpServerConnExec<A, B> for T
where B: Body,