inline_bot/
inline_bot.rs

1use telebot::Bot;
2use futures::stream::Stream;
3use std::env;
4
5use erased_serde::Serialize;
6
7use telebot::functions::*;
8use telebot::objects::*;
9
10fn main() {
11    // Create the bot
12    let mut bot = Bot::new(&env::var("TELEGRAM_BOT_KEY").unwrap()).update_interval(200);
13
14    let stream = bot.inline()
15        .and_then(|(bot, query)| {
16            let result: Vec<Box<dyn Serialize + Send>> = vec![
17                Box::new(
18                    InlineQueryResultArticle::new(
19                        "Test".into(),
20                        Box::new(input_message_content::Text::new("This is a test".into())),
21                    ).reply_markup(InlineKeyboardMarkup::new(vec![
22                        vec![
23                            InlineKeyboardButton::new("Wikipedia".into())
24                                .url("http://wikipedia.org"),
25                        ],
26                    ])),
27                ),
28            ];
29
30            bot.answer_inline_query(query.id, result)
31                .is_personal(true)
32                .send()
33        })
34        .for_each(|_| Ok(()));
35
36    // enter the main loop
37    bot.run_with(stream);
38    //tokio::spawn(stream.into_future().map_err(|_| ()));
39
40    //lp.run(stream.for_each(|_| Ok(())).into_future()).unwrap();
41}