blob: 4cca6d1ac94ddee0567386c97ff18a32a9593833 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
extern crate telegram_bot;
use telegram_bot::{Api, ListeningMethod, ListeningAction, MessageType, Update};
fn main() {
let api = Api::from_env("TELEGRAM_BOT_TOKEN").unwrap();
println!("api started: {:?}", api.get_me());
let mut listener = api.listener(ListeningMethod::LongPoll(None));
let res = listener.listen(|u| {
if let Some(m) = u.message {
let name = m.from.first_name;
println!("got message from {}", name);
};
Ok(ListeningAction::Continue)
});
if let Err(e) = res {
panic!(e);
}
}
|