pub struct InlineQueryResultArticle {
pub id: String,
pub title: String,
pub input_message_content: InputMessageContent,
pub reply_markup: Option<InlineKeyboardMarkup>,
pub url: Option<Url>,
pub description: Option<String>,
pub thumbnail_url: Option<Url>,
pub thumbnail_width: Option<u32>,
pub thumbnail_height: Option<u32>,
}Expand description
Represents a link to an article or web page.
Fields§
§id: StringUnique identifier for this result, 1-64 Bytes.
title: StringTitle of the result.
input_message_content: InputMessageContentContent of the message to be sent.
reply_markup: Option<InlineKeyboardMarkup>Inline keyboard attached to the message.
url: Option<Url>URL of the result.
description: Option<String>Short description of the result.
thumbnail_url: Option<Url>Url of the thumbnail for the result.
thumbnail_width: Option<u32>Thumbnail width.
thumbnail_height: Option<u32>Thumbnail height.
Implementations§
Source§impl InlineQueryResultArticle
impl InlineQueryResultArticle
Sourcepub fn new<S1, S2>(
id: S1,
title: S2,
input_message_content: InputMessageContent,
) -> InlineQueryResultArticle
pub fn new<S1, S2>( id: S1, title: S2, input_message_content: InputMessageContent, ) -> InlineQueryResultArticle
Examples found in repository?
examples/buttons.rs (lines 93-97)
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 18-30)
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 id<S>(self, val: S) -> InlineQueryResultArticle
pub fn title<S>(self, val: S) -> InlineQueryResultArticle
pub fn input_message_content( self, val: InputMessageContent, ) -> InlineQueryResultArticle
Sourcepub fn reply_markup(self, val: InlineKeyboardMarkup) -> InlineQueryResultArticle
pub fn reply_markup(self, val: InlineKeyboardMarkup) -> InlineQueryResultArticle
Examples found in repository?
examples/buttons.rs (line 98)
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}Sourcepub fn url(self, val: Url) -> InlineQueryResultArticle
pub fn url(self, val: Url) -> InlineQueryResultArticle
Examples found in repository?
examples/inline.rs (line 45)
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}Sourcepub fn description<S>(self, val: S) -> InlineQueryResultArticle
pub fn description<S>(self, val: S) -> InlineQueryResultArticle
Examples found in repository?
examples/inline.rs (line 43)
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}Sourcepub fn thumbnail_url(self, val: Url) -> InlineQueryResultArticle
pub fn thumbnail_url(self, val: Url) -> InlineQueryResultArticle
Examples found in repository?
examples/inline.rs (line 44)
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 thumbnail_width(self, val: u32) -> InlineQueryResultArticle
pub fn thumbnail_height(self, val: u32) -> InlineQueryResultArticle
Trait Implementations§
Source§impl Clone for InlineQueryResultArticle
impl Clone for InlineQueryResultArticle
Source§fn clone(&self) -> InlineQueryResultArticle
fn clone(&self) -> InlineQueryResultArticle
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 InlineQueryResultArticle
impl Debug for InlineQueryResultArticle
Source§impl<'de> Deserialize<'de> for InlineQueryResultArticle
impl<'de> Deserialize<'de> for InlineQueryResultArticle
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<InlineQueryResultArticle, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<InlineQueryResultArticle, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl From<InlineQueryResultArticle> for InlineQueryResult
impl From<InlineQueryResultArticle> for InlineQueryResult
Source§fn from(value: InlineQueryResultArticle) -> InlineQueryResult
fn from(value: InlineQueryResultArticle) -> InlineQueryResult
Converts to this type from the input type.
Source§impl PartialEq for InlineQueryResultArticle
impl PartialEq for InlineQueryResultArticle
Source§impl Serialize for InlineQueryResultArticle
impl Serialize for InlineQueryResultArticle
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 InlineQueryResultArticle
Auto Trait Implementations§
impl Freeze for InlineQueryResultArticle
impl RefUnwindSafe for InlineQueryResultArticle
impl Send for InlineQueryResultArticle
impl Sync for InlineQueryResultArticle
impl Unpin for InlineQueryResultArticle
impl UnwindSafe for InlineQueryResultArticle
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