1extern crate futures;
2extern crate telegram_bot_fork;
3extern crate tokio;
4
5use std::env;
6
7use futures::{future::lazy, Stream};
8
9use telegram_bot_fork::*;
10
11fn main() {
12 tokio::runtime::current_thread::Runtime::new()
13 .unwrap()
14 .block_on(lazy(|| {
15 let token = env::var("TELEGRAM_BOT_TOKEN").unwrap();
16 let api = Api::new(token).unwrap();
17
18 let stream = api.stream().then(|mb_update| {
20 let res: Result<Result<Update, Error>, ()> = Ok(mb_update);
21 res
22 });
23
24 stream.for_each(|mb_update| {
26 println!("{:?}", mb_update);
27
28 Ok(())
29 })
30 }))
31 .unwrap();
32}