use value from .env for polling time

This commit is contained in:
b1ek 2023-08-05 03:52:00 +10:00
parent 1c5fb8a0f0
commit 4e3ab96b40
Signed by: blek
GPG Key ID: 14546221E3595D0C
1 changed files with 6 additions and 4 deletions

View File

@ -1,9 +1,9 @@
#![forbid(unsafe_code)]
use std::{path::{self, Path}, thread, time::Duration};
use std::{path::Path, thread, time::Duration};
use log;
use teloxide_core::{prelude::*, types::{Recipient, UpdateKind}};
use teloxide_core::{prelude::*, types::Recipient};
use teloxide::Bot;
use tokio::fs;
@ -55,12 +55,14 @@ async fn main() {
let chat = bot.get_chat(Recipient::Id(ChatId(CHAT_ID.parse::<i64>().unwrap()))).await.unwrap();
log::info!("Using chat {}", chat.title().unwrap());
log::info!("Starting polling SCM for updates ({})", POLL_TIME);
let time = POLL_TIME.parse::<u64>().unwrap();
log::info!("Starting polling SCM for updates ({})", time);
loop {
let (new_prs, new_data) = api::get_new_prs(prs.clone(), repos.clone()).await;
log::info!("Found {} new PRs", new_prs.len());
thread::sleep(Duration::from_secs(5));
thread::sleep(Duration::from_millis(time));
if new_prs.len() != 0 {
prs = new_data;