Remove unused dispatcher variable, Bot to AutoSend
-use teloxide::{Bot, payloads::AnswerInlineQuery, prelude::*, types::{InlineQueryResult, InlineQueryResultArticle, InputMessageContent, InputMessageContentText}};
+use teloxide::{
+ payloads::AnswerInlineQuery,
+ prelude::*,
+ types::{
+ InlineQueryResult, InlineQueryResultArticle, InputMessageContent, InputMessageContentText,
+ },
+ Bot,
+};
use tokio_stream::wrappers::UnboundedReceiverStream;
#[tokio::main]
@@ -7,10 +14,10 @@ async fn main() {
}
async fn run() {
- let bot = Bot::from_env();
+ let bot = Bot::from_env().auto_send();
// Create a new dispatcher to handle incoming messages
- let dp = Dispatcher::new(bot);
- dp.inline_queries_handler(|rx: DispatcherHandlerRx<Bot, InlineQuery>| {
+ Dispatcher::new(bot)
+ .inline_queries_handler(|rx: DispatcherHandlerRx<AutoSend<Bot>, InlineQuery>| {
UnboundedReceiverStream::new(rx).for_each_concurrent(None, |msg| async move {
// First, create your actual response
let google_search = InlineQueryResultArticle::new(
@@ -49,7 +56,10 @@ async fn run() {
// https://docs.rs/teloxide/0.5.1/teloxide/payloads/struct.AnswerInlineQuery.html
let all_results = AnswerInlineQuery {
inline_query_id: "03".to_string(), // again, anything -- as long as it's unique in this context
- results: vec![InlineQueryResult::Article(google_search), InlineQueryResult::Article(ddg_search)],
+ results: vec![
+ InlineQueryResult::Article(google_search),
+ InlineQueryResult::Article(ddg_search),
+ ],
cache_time: None,
is_personal: None,
next_offset: None,
