Struct tgbot::types::Message

source ·
pub struct Message {
Show 24 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 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 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 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.

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

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

§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_has_protected_content(self, value: bool) -> Self

Sets a new value for a 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 an 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 a 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 an 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 an 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_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_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 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

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

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::Ok, __S::Error>
where __S: Serializer,

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

impl TryFrom<Message> for Command

§

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

§

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> 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> IntoEither for T

source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
source§

impl<T> ToOwned for T
where 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 T
where U: Into<T>,

§

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

§

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<A, B, T> HttpServerConnExec<A, B> for T
where B: Body,