Advertisement
Guest User

Halp

a guest
Jul 29th, 2016
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Rust 0.57 KB | None | 0 0
  1. extern crate telegram_bot;
  2. extern crate crossbeam;
  3.  
  4. use telegram_bot::*;
  5.  
  6. fn main() {
  7.     let bot_token = "104108634:AAHrTUCQurNh9l2tVajbxFPtLzTueGwrs3M";
  8.     let api = Api::from_token(bot_token).unwrap();
  9.  
  10.     let mut listener = api.listener(ListeningMethod::LongPoll(None));
  11.  
  12.     let res = listener.listen(|u| {
  13.         potato(api);
  14.         Ok(ListeningAction::Continue)
  15.     });
  16.  
  17.     if let Err(e) = res {
  18.         println!("An error occured: {}", e);
  19.     }
  20. }
  21.  
  22. fn potato(api: Api) {
  23.     crossbeam::scope(|scope| {
  24.         scope.spawn(move || {
  25.             println!("getMe: {:?}", api.get_me());
  26.         });
  27.     });
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement