pub struct InputMessageContentText {
pub message_text: String,
pub parse_mode: Option<ParseMode>,
pub entities: Option<Vec<MessageEntity>>,
pub link_preview_options: Option<LinkPreviewOptions>,
}Expand description
Represents the content of a text message to be sent as the result of an inline query.
Fields§
§message_text: StringText of the message to be sent, 1-4096 characters.
parse_mode: Option<ParseMode>Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption.
entities: Option<Vec<MessageEntity>>List of special entities that appear in message text, which can be
specified instead of parse_mode.
link_preview_options: Option<LinkPreviewOptions>Link preview generation options for the message
Implementations§
Source§impl InputMessageContentText
impl InputMessageContentText
Sourcepub fn new<S>(message_text: S) -> InputMessageContentText
pub fn new<S>(message_text: S) -> InputMessageContentText
Examples found in repository?
examples/buttons.rs (line 96)
89async fn inline_query_handler(
90 bot: Bot,
91 q: InlineQuery,
92) -> Result<(), Box<dyn Error + Send + Sync>> {
93 let choose_debian_version = InlineQueryResultArticle::new(
94 "0",
95 "Chose debian version",
96 InputMessageContent::Text(InputMessageContentText::new("Debian versions:")),
97 )
98 .reply_markup(make_keyboard());
99
100 bot.answer_inline_query(q.id, vec![choose_debian_version.into()]).await?;
101
102 Ok(())
103}More examples
examples/inline.rs (lines 26-29)
9async fn main() {
10 pretty_env_logger::init();
11 log::info!("Starting inline bot...");
12
13 let bot = Bot::from_env();
14
15 let handler = Update::filter_inline_query().branch(dptree::endpoint(
16 |bot: Bot, q: InlineQuery| async move {
17 // First, create your actual response
18 let google_search = InlineQueryResultArticle::new(
19 // Each item needs a unique ID, as well as the response container for the
20 // items. These can be whatever, as long as they don't
21 // conflict.
22 "01".to_string(),
23 // What the user will actually see
24 "Google Search",
25 // What message will be sent when clicked/tapped
26 InputMessageContent::Text(InputMessageContentText::new(format!(
27 "https://www.google.com/search?q={}",
28 q.query,
29 ))),
30 );
31 // While constructing them from the struct itself is possible, it is preferred
32 // to use the builder pattern if you wish to add more
33 // information to your result. Please refer to the documentation
34 // for more detailed information about each field. https://docs.rs/teloxide/latest/teloxide/types/struct.InlineQueryResultArticle.html
35 let ddg_search = InlineQueryResultArticle::new(
36 "02".to_string(),
37 "DuckDuckGo Search".to_string(),
38 InputMessageContent::Text(InputMessageContentText::new(format!(
39 "https://duckduckgo.com/?q={}",
40 q.query
41 ))),
42 )
43 .description("DuckDuckGo Search")
44 .thumbnail_url("https://duckduckgo.com/assets/logo_header.v108.png".parse().unwrap())
45 .url("https://duckduckgo.com/about".parse().unwrap()); // Note: This is the url that will open if they click the thumbnail
46
47 let results = vec![
48 InlineQueryResult::Article(google_search),
49 InlineQueryResult::Article(ddg_search),
50 ];
51
52 // Send it off! One thing to note -- the ID we use here must be of the query
53 // we're responding to.
54 let response = bot.answer_inline_query(q.id.clone(), results).send().await;
55 if let Err(err) = response {
56 log::error!("Error in handler: {err:?}");
57 }
58 respond(())
59 },
60 ));
61
62 Dispatcher::builder(bot, handler).enable_ctrlc_handler().build().dispatch().await;
63}pub fn message_text<S>(self, val: S) -> InputMessageContentText
pub fn parse_mode(self, val: ParseMode) -> InputMessageContentText
pub fn entities<C>(self, val: C) -> InputMessageContentTextwhere
C: IntoIterator<Item = MessageEntity>,
pub fn link_preview_options( self, val: LinkPreviewOptions, ) -> InputMessageContentText
Trait Implementations§
Source§impl Clone for InputMessageContentText
impl Clone for InputMessageContentText
Source§fn clone(&self) -> InputMessageContentText
fn clone(&self) -> InputMessageContentText
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for InputMessageContentText
impl Debug for InputMessageContentText
Source§impl<'de> Deserialize<'de> for InputMessageContentText
impl<'de> Deserialize<'de> for InputMessageContentText
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<InputMessageContentText, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<InputMessageContentText, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl PartialEq for InputMessageContentText
impl PartialEq for InputMessageContentText
Source§impl Serialize for InputMessageContentText
impl Serialize for InputMessageContentText
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Serialize this value into the given Serde serializer. Read more
impl StructuralPartialEq for InputMessageContentText
Auto Trait Implementations§
impl Freeze for InputMessageContentText
impl RefUnwindSafe for InputMessageContentText
impl Send for InputMessageContentText
impl Sync for InputMessageContentText
impl Unpin for InputMessageContentText
impl UnwindSafe for InputMessageContentText
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Erasable for T
impl<T> Erasable for T
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>
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 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>
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