Created
October 18, 2017 12:17
-
-
Save DarkMentat/889f27afcd15270901f4cccf3f5b0017 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extern crate telegram_bot; | |
use super::git_watcher::GitWatcher; | |
use telegram_bot::*; | |
use std::time::*; | |
use futures::Future; | |
use futures::Stream; | |
use futures::stream::*; | |
use tokio_core::reactor::Handle; | |
use tokio_timer::*; | |
pub struct TelegramGitWatcherBot{ | |
pub git_watcher: GitWatcher, | |
pub tg_api: Api | |
} | |
impl TelegramGitWatcherBot{ | |
pub fn start(&self, handle: Handle) { | |
let tg = self.tg_api.stream() | |
.for_each(|upd| { self.log_tg(); Ok(()) }) | |
.map_err(|_| ()); | |
let timer = Timer::default() | |
.interval(Duration::new(15, 0)) | |
.for_each(|_| { self.log_timer(); Ok(()) }) | |
.map_err(|_| ()); | |
handle.spawn(tg); | |
handle.spawn(timer); | |
} | |
fn log_tg(&self){ | |
println!("telegram update!"); | |
} | |
fn log_timer(&self){ | |
println!("timer tick!"); | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment