Skip to main content

GuestChatQuery

Struct GuestChatQuery 

Source
pub struct GuestChatQuery {
    pub query_id: i64,
    pub message: IncomingMessage,
    pub reference_messages: Vec<IncomingMessage>,
    pub qts: i32,
}
Expand description

A guest-chat inline query sent to the bot (updateBotGuestChatQuery).

Fields§

§query_id: i64§message: IncomingMessage§reference_messages: Vec<IncomingMessage>§qts: i32

Implementations§

Source§

impl GuestChatQuery

Source

pub fn answer(&self) -> GuestChatAnswer<'_>

Begin building an answer for this query.

Source

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

The peer that originally triggered this guest-chat query, if Telegram included it in the message (guestchat_via_from).

Present when the bot is acting as an intermediary and Telegram wants it to know the original requester.

Methods from Deref<Target = IncomingMessage>§

Source

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

Get the download location for the media in this message, if any.

Source

pub fn download_location_with_dc(&self) -> Option<(InputFileLocation, i32)>

Like Self::download_location but also returns the file’s DC id.

Source

pub async fn download( &self, dest: impl AsyncWrite + Unpin, ) -> Result<u64, InvocationError>

Download this message’s media to any AsyncWrite sink. Returns bytes written.

Requires the message to have an attached client (i.e. it came from a handler).

§Example
let mut buf = Vec::new();
msg.download(&mut buf).await.unwrap();
Source

pub async fn bytes(&self) -> Result<Vec<u8>, InvocationError>

Download this message’s media into memory and return the raw bytes.

Convenience wrapper over download for small files. For large files prefer download with a tokio::fs::File to avoid memory pressure.

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 fn date_utc(&self) -> Option<DateTime<Utc>>

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.

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

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 from_scheduled(&self) -> bool

true if this message was sent from a scheduled one.

Source

pub fn edit_hide(&self) -> bool

true if the edit date is hidden from recipients.

Source

pub fn media_unread(&self) -> bool

true if the media in this message has not been read yet.

Source

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

ID of the bot that sent this message via inline mode, if any.

Source

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

Signature of the post author in a channel, if set.

Source

pub fn reaction_count(&self) -> i32

Number of reactions on this message, if any.

Source

pub fn restriction_reason(&self) -> Option<&Vec<RestrictionReason>>

Restriction reasons (why this message is unavailable in some regions).

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 fn markdown_text(&self) -> Option<String>

Available on crate feature parsers only.

Reconstruct Markdown from the message text and its formatting entities.

Returns plain text if there are no entities.

Source

pub fn html_text(&self) -> Option<String>

Available on crate feature parsers only.

Reconstruct HTML from the message text and its formatting entities.

Returns plain text if there are no entities.

Source

pub fn action(&self) -> Option<&MessageAction>

Service message action (e.g. “user joined”, “call started”).
Returns None for regular text/media messages.

Source

pub fn photo(&self) -> Option<Photo>

Extract a Photo from the message media, if present.

Shorthand for Photo::from_media(msg.media()?).

Source

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

Extract a Document from the message media, if present.

Shorthand for Document::from_media(msg.media()?).

Source

pub fn chat_id(&self) -> i64

The bare numeric chat ID (positive for users/groups, negative for channels).

Source

pub fn is_private(&self) -> bool

true when the message is in a private (1-on-1) chat.

Source

pub fn is_group(&self) -> bool

true when the message is in a basic group.

Source

pub fn is_channel(&self) -> bool

true when the message is in a channel or supergroup.

Source

pub fn is_any_group(&self) -> bool

true when the message is in any multi-user chat (group or channel).

Source

pub async fn channel_kind(&self) -> Option<ChannelKind>

Look up the crate::ChannelKind of the chat this message is in.

Returns None when the message is not in a channel/supergroup, or when the kind is not yet known (e.g. first message from an unseen channel, or a pre-v6 session with no kind stored).

Requires an embedded client (set via stream_updates()). For messages retrieved via history APIs, use channel_kind_with and pass the client explicitly.

Source

pub async fn channel_kind_with(&self, client: &Client) -> Option<ChannelKind>

Look up the crate::ChannelKind of the chat this message is in, using an explicit client reference.

Source

pub async fn is_megagroup(&self) -> bool

true when the message is in a supergroup (megagroup).

Queries the session cache; returns false when the kind is unknown. See channel_kind for details.

Source

pub async fn is_broadcast(&self) -> bool

true when the message is in a broadcast channel (not a supergroup).

Queries the session cache; returns false when the kind is unknown.

Source

pub async fn is_gigagroup(&self) -> bool

true when the message is in a gigagroup (large broadcast group).

Queries the session cache; returns false when the kind is unknown.

Source

pub fn is_bot_command(&self) -> bool

true when the message text begins with / (a bot command).

Source

pub fn command(&self) -> Option<(&str, &str)>

If the message is a bot command, returns (command, rest) where command is the command name without the / and optional @BotName suffix, and rest is everything after (trimmed).

if let Some((cmd, args)) = msg.command() {
    // cmd = "start", args = "payload"
}
Source

pub fn is_command_named(&self, name: &str) -> bool

true if the message is the named command (case-insensitive, ignoring @bot suffix).

Source

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

Return the arguments portion of a bot command (text after /cmd), trimmed. Returns None if the message is not a command.

Source

pub fn has_media(&self) -> bool

true if the message carries any media attachment.

Source

pub fn has_photo(&self) -> bool

true if the message carries a photo.

Source

pub fn has_document(&self) -> bool

true if the message carries a document (file, video, audio, etc).

Source

pub fn is_forwarded(&self) -> bool

true if this message was forwarded from another chat or user.

Source

pub fn is_reply(&self) -> bool

true if this message is a reply to another message.

Source

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

Alias of grouped_id - the album/grouped-media ID, if this message is part of an album.

Source

pub async fn reply( &self, msg: impl Into<InputMessage>, ) -> Result<IncomingMessage, Error>

Reply to this message (clientless: requires an embedded client).

Returns the sent message so you can chain further operations on it. Reply to this message.

Accepts a plain &str/String or a full InputMessage (with keyboard, formatting, media, etc.). The reply-to header is set automatically.

// plain text
msg.reply("Hello!").await?;

// HTML formatting
msg.reply(InputMessage::html("<b>Bold</b> reply")).await?;

// with keyboard
msg.reply(InputMessage::text("Choose:").reply_markup(kb)).await?;
Source

pub async fn respond( &self, msg: impl Into<InputMessage>, ) -> Result<IncomingMessage, Error>

Send to the same chat without quoting.

Accepts a plain &str/String or a full InputMessage.

Source

pub async fn edit(&self, msg: impl Into<InputMessage>) -> Result<(), Error>

Edit this message.

Accepts a plain &str/String or a full InputMessage (for HTML/Markdown formatting, keyboard changes, etc.).

msg.edit("Updated text").await?;
msg.edit(InputMessage::html("<b>Updated</b>")).await?;
Source

pub async fn delete(&self) -> Result<(), Error>

Delete this message (clientless).

Source

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

Delete this message.

Source

pub async fn mark_read(&self) -> Result<(), Error>

Mark this message (and all before it) as read (clientless).

Source

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

Mark this message (and all before it) as read.

Source

pub async fn pin(&self) -> Result<(), Error>

Pin this message silently (clientless).

Source

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

Pin this message silently.

Source

pub async fn unpin(&self) -> Result<(), Error>

Unpin this message (clientless).

Source

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

Unpin this message.

Source

pub async fn forward_to( &self, destination: impl Into<PeerRef>, ) -> Result<IncomingMessage, Error>

Forward this message to another chat (clientless).

Returns the forwarded message in the destination chat.

Source

pub async fn forward_to_with( &self, client: &Client, destination: impl Into<PeerRef>, ) -> Result<IncomingMessage, Error>

Forward this message to another chat.

Returns the forwarded message in the destination chat.

Source

pub async fn react( &self, reactions: impl Into<InputReactions>, ) -> Result<(), Error>

Send a reaction (clientless).

§Example
use ferogram::reactions::InputReactions;
msg.react(InputReactions::emoticon("👍")).await?;
Source

pub async fn react_with( &self, client: &Client, reactions: impl Into<InputReactions>, ) -> Result<(), Error>

Send a reaction.

Source

pub async fn get_reply(&self) -> Result<Option<IncomingMessage>, Error>

Fetch the message this is a reply to (clientless).

Source

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

Fetch the message this is a reply to.

Source

pub fn effective_sender_id_with(&self, my_id: Option<i64>) -> Option<Peer>

The effective sender peer, resolving the private-chat (DM) case.

sender_id() returns None for DM messages because Telegram’s wire format omits from_id there - with only two participants, the sender is always derivable from out + peer_id, so the server doesn’t bother sending it. This method fills that gap:

  • If from_id is present (groups, channels, or some older DM messages), it’s used as-is.
  • Otherwise, if this is a private chat: an outgoing message was sent by the logged-in account (my_id), and an incoming message was sent by the other party, whose ID is the chat ID itself (peer_id/chat_id()) - a DM’s Peer::User is the other person.

my_id is the logged-in account’s numeric ID - pass an explicit one if this message has no embedded client (e.g. fetched via a history API without stream_updates()); otherwise use effective_sender_id which resolves it automatically from the embedded client’s cache.

Source

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

Like effective_sender_id_with, but resolves my_id automatically from the embedded client’s cache (populated for free at sign-in; see Client::my_id).

Returns None for an outgoing DM if the client hasn’t seen its own User object yet in this session (very rare - only before the first sign-in/get_me() call) - use sender_user_id_async in that case, since it falls back to a one-time get_me() network call.

Source

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

The sender’s bare user-ID, if this is a user message.

Returns None for anonymous channel posts. Resolves the private-chat (DM) case where Telegram omits from_id - see effective_sender_id for details.

Source

pub async fn sender_user_id_async(&self) -> Result<Option<i64>, Error>

Like sender_user_id, guaranteed correct even if the embedded client hasn’t cached its own ID yet: falls back to a one-time get_me() call for an outgoing DM whose sender can’t be resolved from cache alone.

Source

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

The chat/channel-ID the sender belongs to (non-user senders).

Source

pub async fn sender_user(&self) -> Result<Option<User>, Error>

Fetch the sender as a typed User (clientless, async).

Returns None if the sender is not a user, or if the user is not in the local peer cache. Performs a network call if needed - including, for an outgoing DM, a one-time get_me() to resolve “myself” if the client hasn’t cached its own ID yet.

Source

pub async fn click_button_where<F>(&self, predicate: F) -> Result<(), Error>
where F: Fn(&str, &[u8]) -> bool,

Press the first inline callback button matched by predicate.

The closure receives (text: &str, data: &[u8]) for each callback button.

msg.click_button_where(|text, _data| text.contains("Confirm")).await?;
Source

pub fn find_button(&self, filter: ButtonFilter<'_>) -> Option<(usize, usize)>

Find the first inline callback button matching filter and return its (row, col).

Use .is_some() to check existence.

msg.find_button(ButtonFilter::Text("OK"));
msg.find_button(ButtonFilter::Data(b"cb:ping"));
msg.find_button(ButtonFilter::Pos(0, 0));
Source

pub fn find_button_where<F>(&self, predicate: F) -> Option<(usize, usize)>
where F: Fn(&str, &[u8]) -> bool,

Find the first inline callback button satisfying predicate and return (row, col).

The closure receives (text: &str, data: &[u8]).

Source

pub async fn click_button(&self, filter: ButtonFilter<'_>) -> Result<(), Error>

Press the inline button matching filter.

msg.click_button(ButtonFilter::Pos(0, 0)).await?;
msg.click_button(ButtonFilter::Text("OK")).await?;
msg.click_button(ButtonFilter::Data(b"action:buy")).await?;

Trait Implementations§

Source§

impl Clone for GuestChatQuery

Source§

fn clone(&self) -> GuestChatQuery

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for GuestChatQuery

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Deref for GuestChatQuery

Source§

type Target = IncomingMessage

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> 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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + 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: Sized + 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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
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.
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