From 4e3ab96b405af422b7f64af3625e0ecbefc5a9c1 Mon Sep 17 00:00:00 2001 From: b1ek Date: Sat, 5 Aug 2023 03:52:00 +1000 Subject: [PATCH] use value from .env for polling time --- src/main.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/main.rs b/src/main.rs index 6db1c5b..3b783e3 100644 --- a/src/main.rs +++ b/src/main.rs @@ -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::().unwrap()))).await.unwrap(); log::info!("Using chat {}", chat.title().unwrap()); - log::info!("Starting polling SCM for updates ({})", POLL_TIME); + let time = POLL_TIME.parse::().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;