Skip to main content

IncomingMessage

Struct IncomingMessage 

Source
pub struct IncomingMessage {
    pub raw: Message,
}
Expand description

A new or edited message.

Fields§

§raw: Message

The underlying TL message object.

Implementations§

Source§

impl IncomingMessage

Source

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

The message text (or caption for media messages).

Source

pub fn id(&self) -> i32

Unique message ID within the chat.

Source

pub fn peer_id(&self) -> Option<&Peer>

The peer (chat) this message belongs to.

Source

pub fn sender_id(&self) -> Option<&Peer>

The sender peer, if available (not set for anonymous channel posts).

Source

pub fn outgoing(&self) -> bool

true if the message was sent by the logged-in account.

Source

pub fn date(&self) -> i32

Unix timestamp when the message was sent.

Source

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

Unix timestamp of the last edit, if the message has been edited.

Source

pub fn mentioned(&self) -> bool

true if the logged-in user was mentioned in this message.

Source

pub fn silent(&self) -> bool

true if the message was sent silently (no notification).

Source

pub fn post(&self) -> bool

true if this is a channel post (no sender).

Source

pub fn pinned(&self) -> bool

true if this message is currently pinned.

Source

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

Number of times the message has been forwarded (channels only).

Source

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

View count for channel posts.

Source

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

Reply count (number of replies in a thread).

Source

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

ID of the message this one is replying to.

Source

pub async fn reply_to_message( &self, client: &Client, ) -> Result<Option<IncomingMessage>, Error>

Fetch the message that this one is replying to.

Returns None if this message is not a reply or if the peer is unknown. Unlike reply_to_message_id this actually performs an API call to retrieve the full message object.

Source

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

The message’s send time as a chrono::DateTime<chrono::Utc>.

This is a typed wrapper around the raw date() Unix timestamp.

Source

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

The last edit time as a chrono::DateTime<chrono::Utc>, if edited.

Source

pub fn media(&self) -> Option<&MessageMedia>

The media attached to this message, if any.

Source

pub fn entities(&self) -> Option<&Vec<MessageEntity>>

Formatting entities (bold, italic, code, links, etc).

Source

pub fn grouped_id(&self) -> Option<i64>

Group ID for album messages (multiple media in one).

Source

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

Reply markup (inline keyboards, etc).

Source

pub fn forward_header(&self) -> Option<&MessageFwdHeader>

Forward info header, if this message was forwarded.

Source

pub fn noforwards(&self) -> bool

true if forwarding this message is restricted.

Source

pub async fn reply( &self, client: &mut Client, text: impl Into<String>, ) -> Result<(), Error>

Reply to this message with plain text.

Source§

impl IncomingMessage

Source

pub fn download_location(&self) -> Option<InputFileLocation>

Get the [InputFileLocation] for the media in this message, if any.

Returns None for messages without downloadable media.

Trait Implementations§

Source§

impl Clone for IncomingMessage

Source§

fn clone(&self) -> IncomingMessage

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 IncomingMessage

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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, 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> Same for T

Source§

type Output = T

Should always be Self
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.