From 2c2a7ffc07ca32dffffb4f3e5ca54b9619c3cfdb Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Sun, 31 Jul 2022 08:41:42 +0200 Subject: [PATCH] Create inline bot skeleton --- src/main.rs | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/src/main.rs b/src/main.rs index afeeb3c..86997db 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,5 +1,23 @@ +use teloxide::prelude::*; +use teloxide::types::*; +use log::*; + mod data; -fn main() { - println!("Hello, world!"); + +#[tokio::main] +async fn main() { + pretty_env_logger::init(); + info!("patched-porobot is starting..."); + + let bot = Bot::from_env().auto_send(); + + let handler = Update::filter_inline_query().branch(dptree::endpoint(|query: InlineQuery, bot: AutoSend| async move { + let result = InlineQueryResult::Article(InlineQueryResultArticle::new("test", "Test", InputMessageContent::Text(InputMessageContentText::new("Qui รจ dove metterei la mia carta, se solo ne avessi una!")))); + + let response = bot.answer_inline_query(&query.id, vec![result]).await; + respond(()) + })); + + Dispatcher::builder(bot, handler).enable_ctrlc_handler().build().dispatch().await; }