Skip to main content

InlineQueryResultArticle

Struct InlineQueryResultArticle 

Source
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.

The official docs.

Fields§

§id: String

Unique identifier for this result, 1-64 Bytes.

§title: String

Title of the result.

§input_message_content: InputMessageContent

Content 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

Source

pub fn new<S1, S2>( id: S1, title: S2, input_message_content: InputMessageContent, ) -> InlineQueryResultArticle
where S1: Into<String>, S2: Into<String>,

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
Hide additional 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}
Source

pub fn id<S>(self, val: S) -> InlineQueryResultArticle
where S: Into<String>,

Source

pub fn title<S>(self, val: S) -> InlineQueryResultArticle
where S: Into<String>,

Source

pub fn input_message_content( self, val: InputMessageContent, ) -> InlineQueryResultArticle

Source

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}
Source

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}
Source

pub fn description<S>(self, val: S) -> InlineQueryResultArticle
where S: Into<String>,

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}
Source

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}
Source

pub fn thumbnail_width(self, val: u32) -> InlineQueryResultArticle

Source

pub fn thumbnail_height(self, val: u32) -> InlineQueryResultArticle

Trait Implementations§

Source§

impl Clone for InlineQueryResultArticle

Source§

fn clone(&self) -> InlineQueryResultArticle

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 InlineQueryResultArticle

Source§

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

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

impl<'de> Deserialize<'de> for InlineQueryResultArticle

Source§

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

Source§

fn from(value: InlineQueryResultArticle) -> InlineQueryResult

Converts to this type from the input type.
Source§

impl PartialEq for InlineQueryResultArticle

Source§

fn eq(&self, other: &InlineQueryResultArticle) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for InlineQueryResultArticle

Source§

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
Source§

impl StructuralPartialEq for InlineQueryResultArticle

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> Erasable for T

Source§

const ACK_1_1_0: bool = true

Available on non-enforce_1_1_0_semantics only.
Whether this implementor has acknowledged the 1.1.0 update to unerase’s documented implementation requirements. Read more
Source§

unsafe fn unerase(this: NonNull<Erased>) -> NonNull<T>

Unerase this erased pointer. Read more
Source§

fn erase(this: NonNull<Self>) -> NonNull<Erased>

Turn this erasable pointer into an erased pointer. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromRef<T> for T
where T: Clone,

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
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: 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: 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> 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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

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
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,