mirror of
https://github.com/teloxide/teloxide.git
synced 2025-03-24 23:57:38 +01:00
Clarify verbage from message to query
This commit is contained in:
parent
93c8e00086
commit
f6ad066087
1 changed files with 8 additions and 8 deletions
|
@ -15,10 +15,10 @@ async fn main() {
|
||||||
|
|
||||||
async fn run() {
|
async fn run() {
|
||||||
let bot = Bot::from_env().auto_send();
|
let bot = Bot::from_env().auto_send();
|
||||||
// Create a new dispatcher to handle incoming messages
|
// Create a new dispatcher to handle incoming queries
|
||||||
Dispatcher::new(bot)
|
Dispatcher::new(bot)
|
||||||
.inline_queries_handler(|rx: DispatcherHandlerRx<AutoSend<Bot>, InlineQuery>| {
|
.inline_queries_handler(|rx: DispatcherHandlerRx<AutoSend<Bot>, InlineQuery>| {
|
||||||
UnboundedReceiverStream::new(rx).for_each_concurrent(None, |msg| async move {
|
UnboundedReceiverStream::new(rx).for_each_concurrent(None, |query| async move {
|
||||||
// First, create your actual response
|
// First, create your actual response
|
||||||
let google_search = InlineQueryResultArticle::new(
|
let google_search = InlineQueryResultArticle::new(
|
||||||
// Each item needs a unique ID, as well as the response container for the items.
|
// Each item needs a unique ID, as well as the response container for the items.
|
||||||
|
@ -26,10 +26,10 @@ async fn run() {
|
||||||
"01".to_string(),
|
"01".to_string(),
|
||||||
// What the user will actually see
|
// What the user will actually see
|
||||||
"Google Search",
|
"Google Search",
|
||||||
// What message will send when clicked/tapped
|
// What message will be sent when clicked/tapped
|
||||||
InputMessageContent::Text(InputMessageContentText::new(format!(
|
InputMessageContent::Text(InputMessageContentText::new(format!(
|
||||||
"https://www.google.com/search?q={}",
|
"https://www.google.com/search?q={}",
|
||||||
msg.update.query,
|
query.update.query,
|
||||||
))),
|
))),
|
||||||
);
|
);
|
||||||
// You can also construct them from the struct itself, if you want a little more control.
|
// You can also construct them from the struct itself, if you want a little more control.
|
||||||
|
@ -39,7 +39,7 @@ async fn run() {
|
||||||
id: "02".to_string(), // again, anything -- as long as it's unique in this context
|
id: "02".to_string(), // again, anything -- as long as it's unique in this context
|
||||||
title: "DuckDuckGo Search".to_string(),
|
title: "DuckDuckGo Search".to_string(),
|
||||||
input_message_content: InputMessageContent::Text(InputMessageContentText::new(
|
input_message_content: InputMessageContent::Text(InputMessageContentText::new(
|
||||||
format!("https://duckduckgo.com/?q={}", msg.update.query.to_string()),
|
format!("https://duckduckgo.com/?q={}", query.update.query.to_string()),
|
||||||
)),
|
)),
|
||||||
reply_markup: None,
|
reply_markup: None,
|
||||||
url: Some("https://duckduckgo.com/about".to_string()), // Note: This is the url that will open if they click the thumbnail
|
url: Some("https://duckduckgo.com/about".to_string()), // Note: This is the url that will open if they click the thumbnail
|
||||||
|
@ -67,10 +67,10 @@ async fn run() {
|
||||||
switch_pm_parameter: None,
|
switch_pm_parameter: None,
|
||||||
};
|
};
|
||||||
|
|
||||||
// Send it off! One thing to note -- the ID we use here must be of the message we're responding to.
|
// Send it off! One thing to note -- the ID we use here must be of the query we're responding to.
|
||||||
let response = msg
|
let response = query
|
||||||
.requester
|
.requester
|
||||||
.answer_inline_query(msg.update.id.to_string(), all_results.results)
|
.answer_inline_query(query.update.id.to_string(), all_results.results)
|
||||||
.send()
|
.send()
|
||||||
.await;
|
.await;
|
||||||
if response.is_err() {
|
if response.is_err() {
|
||||||
|
|
Loading…
Add table
Reference in a new issue