reply/
reply.rs

1use telebot::Bot;
2use futures::stream::Stream;
3use std::env;
4
5// import all available functions
6use telebot::functions::*;
7
8fn main() {
9    // Create the bot
10    let mut bot = Bot::new(&env::var("TELEGRAM_BOT_KEY").unwrap()).update_interval(200);
11
12    // Register a reply command which answers a message
13    let handle = bot.new_cmd("/reply")
14        .and_then(|(bot, msg)| {
15            let mut text = msg.text.unwrap().clone();
16            if text.is_empty() {
17                text = "<empty>".into();
18            }
19
20            bot.message(msg.chat.id, text).send()
21        })
22        .for_each(|_| Ok(()));
23
24    bot.run_with(handle);
25}
26