Skip to content

Commit

Permalink
add update time as env var
Browse files Browse the repository at this point in the history
  • Loading branch information
hails committed Mar 21, 2020
1 parent 2480641 commit 3696070
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/scheduler.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
use crate::process;
use std::env;
use std::time::Duration;
use telegram_bot::types::refs::UserId;
use telegram_bot::*;
use tokio;

pub fn start(token: String) {
// api.send(request: Req)
tokio::spawn(async move {
let update_in_secs = env::var("UPDATE_DATA_IN_SECS").expect("UPDATE_DATA_IN_SECS not set");
let update_in_secs = update_in_secs.parse::<u64>().unwrap();

let api = Api::new(&token);

loop {
Expand All @@ -24,7 +27,7 @@ pub fn start(token: String) {
);
api.send(message).await.unwrap();
}
tokio::time::delay_for(Duration::from_secs(1)).await;
tokio::time::delay_for(Duration::from_secs(update_in_secs)).await;
}
});
}

0 comments on commit 3696070

Please sign in to comment.