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: i32Implementations§
Source§impl GuestChatQuery
impl GuestChatQuery
Sourcepub fn answer(&self) -> GuestChatAnswer<'_>
pub fn answer(&self) -> GuestChatAnswer<'_>
Begin building an answer for this query.
Methods from Deref<Target = IncomingMessage>§
Sourcepub fn download_location(&self) -> Option<InputFileLocation>
pub fn download_location(&self) -> Option<InputFileLocation>
Get the download location for the media in this message, if any.
Sourcepub fn download_location_with_dc(&self) -> Option<(InputFileLocation, i32)>
pub fn download_location_with_dc(&self) -> Option<(InputFileLocation, i32)>
Like Self::download_location but also returns the file’s DC id.
Sourcepub async fn download(
&self,
dest: impl AsyncWrite + Unpin,
) -> Result<u64, InvocationError>
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();Sourcepub async fn bytes(&self) -> Result<Vec<u8>, InvocationError>
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.
Sourcepub fn sender_id(&self) -> Option<&Peer>
pub fn sender_id(&self) -> Option<&Peer>
The sender peer, if available (not set for anonymous channel posts).
Sourcepub fn edit_date(&self) -> Option<i32>
pub fn edit_date(&self) -> Option<i32>
Unix timestamp of the last edit, if the message has been edited.
Sourcepub fn forward_count(&self) -> Option<i32>
pub fn forward_count(&self) -> Option<i32>
Number of times the message has been forwarded (channels only).
Sourcepub fn view_count(&self) -> Option<i32>
pub fn view_count(&self) -> Option<i32>
View count for channel posts.
Sourcepub fn reply_count(&self) -> Option<i32>
pub fn reply_count(&self) -> Option<i32>
Reply count (number of replies in a thread).
Sourcepub fn reply_to_message_id(&self) -> Option<i32>
pub fn reply_to_message_id(&self) -> Option<i32>
ID of the message this one is replying to.
Sourcepub fn date_utc(&self) -> Option<DateTime<Utc>>
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.
Sourcepub fn edit_date_utc(&self) -> Option<DateTime<Utc>>
pub fn edit_date_utc(&self) -> Option<DateTime<Utc>>
The last edit time as a chrono::DateTime<chrono::Utc>, if edited.
Sourcepub fn media(&self) -> Option<&MessageMedia>
pub fn media(&self) -> Option<&MessageMedia>
The media attached to this message, if any.
Sourcepub fn entities(&self) -> Option<&Vec<MessageEntity>>
pub fn entities(&self) -> Option<&Vec<MessageEntity>>
Formatting entities (bold, italic, code, links, etc).
Sourcepub fn grouped_id(&self) -> Option<i64>
pub fn grouped_id(&self) -> Option<i64>
Group ID for album messages (multiple media in one).
Sourcepub fn from_scheduled(&self) -> bool
pub fn from_scheduled(&self) -> bool
true if this message was sent from a scheduled one.
Sourcepub fn media_unread(&self) -> bool
pub fn media_unread(&self) -> bool
true if the media in this message has not been read yet.
Sourcepub fn via_bot_id(&self) -> Option<i64>
pub fn via_bot_id(&self) -> Option<i64>
ID of the bot that sent this message via inline mode, if any.
Signature of the post author in a channel, if set.
Sourcepub fn reaction_count(&self) -> i32
pub fn reaction_count(&self) -> i32
Number of reactions on this message, if any.
Sourcepub fn restriction_reason(&self) -> Option<&Vec<RestrictionReason>>
pub fn restriction_reason(&self) -> Option<&Vec<RestrictionReason>>
Restriction reasons (why this message is unavailable in some regions).
Sourcepub fn reply_markup(&self) -> Option<&ReplyMarkup>
pub fn reply_markup(&self) -> Option<&ReplyMarkup>
Reply markup (inline keyboards, etc).
Sourcepub fn forward_header(&self) -> Option<&MessageFwdHeader>
pub fn forward_header(&self) -> Option<&MessageFwdHeader>
Forward info header, if this message was forwarded.
Sourcepub fn noforwards(&self) -> bool
pub fn noforwards(&self) -> bool
true if forwarding this message is restricted.
Sourcepub fn markdown_text(&self) -> Option<String>
Available on crate feature parsers only.
pub fn markdown_text(&self) -> Option<String>
parsers only.Reconstruct Markdown from the message text and its formatting entities.
Returns plain text if there are no entities.
Sourcepub fn html_text(&self) -> Option<String>
Available on crate feature parsers only.
pub fn html_text(&self) -> Option<String>
parsers only.Reconstruct HTML from the message text and its formatting entities.
Returns plain text if there are no entities.
Sourcepub fn action(&self) -> Option<&MessageAction>
pub fn action(&self) -> Option<&MessageAction>
Service message action (e.g. “user joined”, “call started”).
Returns None for regular text/media messages.
Sourcepub fn photo(&self) -> Option<Photo>
pub fn photo(&self) -> Option<Photo>
Extract a Photo from the message media, if present.
Shorthand for Photo::from_media(msg.media()?).
Sourcepub fn document(&self) -> Option<Document>
pub fn document(&self) -> Option<Document>
Extract a Document from the message media, if present.
Shorthand for Document::from_media(msg.media()?).
Sourcepub fn chat_id(&self) -> i64
pub fn chat_id(&self) -> i64
The bare numeric chat ID (positive for users/groups, negative for channels).
Sourcepub fn is_private(&self) -> bool
pub fn is_private(&self) -> bool
true when the message is in a private (1-on-1) chat.
Sourcepub fn is_channel(&self) -> bool
pub fn is_channel(&self) -> bool
true when the message is in a channel or supergroup.
Sourcepub fn is_any_group(&self) -> bool
pub fn is_any_group(&self) -> bool
true when the message is in any multi-user chat (group or channel).
Sourcepub async fn channel_kind(&self) -> Option<ChannelKind>
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.
Sourcepub async fn channel_kind_with(&self, client: &Client) -> Option<ChannelKind>
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.
Sourcepub async fn is_megagroup(&self) -> bool
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.
Sourcepub async fn is_broadcast(&self) -> bool
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.
Sourcepub async fn is_gigagroup(&self) -> bool
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.
Sourcepub fn is_bot_command(&self) -> bool
pub fn is_bot_command(&self) -> bool
true when the message text begins with / (a bot command).
Sourcepub fn command(&self) -> Option<(&str, &str)>
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"
}Sourcepub fn is_command_named(&self, name: &str) -> bool
pub fn is_command_named(&self, name: &str) -> bool
true if the message is the named command (case-insensitive, ignoring @bot suffix).
Sourcepub fn command_args(&self) -> Option<&str>
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.
Sourcepub fn has_document(&self) -> bool
pub fn has_document(&self) -> bool
true if the message carries a document (file, video, audio, etc).
Sourcepub fn is_forwarded(&self) -> bool
pub fn is_forwarded(&self) -> bool
true if this message was forwarded from another chat or user.
Sourcepub fn album_id(&self) -> Option<i64>
pub fn album_id(&self) -> Option<i64>
Alias of grouped_id - the album/grouped-media ID, if this message is
part of an album.
Sourcepub async fn reply(
&self,
msg: impl Into<InputMessage>,
) -> Result<IncomingMessage, Error>
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?;Sourcepub async fn respond(
&self,
msg: impl Into<InputMessage>,
) -> Result<IncomingMessage, Error>
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.
Sourcepub async fn edit(&self, msg: impl Into<InputMessage>) -> Result<(), Error>
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?;Sourcepub async fn mark_read(&self) -> Result<(), Error>
pub async fn mark_read(&self) -> Result<(), Error>
Mark this message (and all before it) as read (clientless).
Sourcepub async fn mark_read_with(&self, client: &Client) -> Result<(), Error>
pub async fn mark_read_with(&self, client: &Client) -> Result<(), Error>
Mark this message (and all before it) as read.
Sourcepub async fn forward_to(
&self,
destination: impl Into<PeerRef>,
) -> Result<IncomingMessage, Error>
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.
Sourcepub async fn forward_to_with(
&self,
client: &Client,
destination: impl Into<PeerRef>,
) -> Result<IncomingMessage, Error>
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.
Sourcepub async fn react(
&self,
reactions: impl Into<InputReactions>,
) -> Result<(), Error>
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?;Sourcepub async fn react_with(
&self,
client: &Client,
reactions: impl Into<InputReactions>,
) -> Result<(), Error>
pub async fn react_with( &self, client: &Client, reactions: impl Into<InputReactions>, ) -> Result<(), Error>
Send a reaction.
Sourcepub async fn get_reply(&self) -> Result<Option<IncomingMessage>, Error>
pub async fn get_reply(&self) -> Result<Option<IncomingMessage>, Error>
Fetch the message this is a reply to (clientless).
Sourcepub async fn get_reply_with(
&self,
client: &Client,
) -> Result<Option<IncomingMessage>, Error>
pub async fn get_reply_with( &self, client: &Client, ) -> Result<Option<IncomingMessage>, Error>
Fetch the message this is a reply to.
Sourcepub fn effective_sender_id_with(&self, my_id: Option<i64>) -> Option<Peer>
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_idis 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’sPeer::Useris 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.
Sourcepub fn effective_sender_id(&self) -> Option<Peer>
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.
Sourcepub fn sender_user_id(&self) -> Option<i64>
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.
Sourcepub async fn sender_user_id_async(&self) -> Result<Option<i64>, Error>
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.
Sourcepub fn sender_chat_id(&self) -> Option<i64>
pub fn sender_chat_id(&self) -> Option<i64>
The chat/channel-ID the sender belongs to (non-user senders).
Sourcepub async fn sender_user(&self) -> Result<Option<User>, Error>
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.
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?;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));Find the first inline callback button satisfying predicate and return (row, col).
The closure receives (text: &str, data: &[u8]).
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
impl Clone for GuestChatQuery
Source§fn clone(&self) -> GuestChatQuery
fn clone(&self) -> GuestChatQuery
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for GuestChatQuery
impl Debug for GuestChatQuery
Auto Trait Implementations§
impl !RefUnwindSafe for GuestChatQuery
impl !UnwindSafe for GuestChatQuery
impl Freeze for GuestChatQuery
impl Send for GuestChatQuery
impl Sync for GuestChatQuery
impl Unpin for GuestChatQuery
impl UnsafeUnpin for GuestChatQuery
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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