aboutsummaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
authorjan <jan@ruken.pw>2016-03-31 19:26:05 (UTC)
committerjan <jan@ruken.pw>2016-03-31 19:26:05 (UTC)
commitac1f32f068a8c1e856b6db00a8058d9bf372a006 (patch)
tree8569d00a99dbe2f973eb934ba750eb5d3e0d96b2 /src/main.rs
initial commit
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/main.rs b/src/main.rs
new file mode 100644
index 0000000..4cca6d1
--- /dev/null
+++ b/src/main.rs
@@ -0,0 +1,23 @@
1extern crate telegram_bot;
2
3use telegram_bot::{Api, ListeningMethod, ListeningAction, MessageType, Update};
4
5fn main() {
6 let api = Api::from_env("TELEGRAM_BOT_TOKEN").unwrap();
7
8 println!("api started: {:?}", api.get_me());
9
10 let mut listener = api.listener(ListeningMethod::LongPoll(None));
11 let res = listener.listen(|u| {
12 if let Some(m) = u.message {
13 let name = m.from.first_name;
14
15 println!("got message from {}", name);
16 };
17 Ok(ListeningAction::Continue)
18 });
19
20 if let Err(e) = res {
21 panic!(e);
22 }
23}