From 1c619f1b97192147d6c952ccc2035815da1519c7 Mon Sep 17 00:00:00 2001 From: Neshura Date: Thu, 3 Aug 2023 00:04:19 +0200 Subject: [PATCH] Fix for prev_time var, more debug logging --- src/main.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main.rs b/src/main.rs index ac04f80..8f21fa1 100644 --- a/src/main.rs +++ b/src/main.rs @@ -98,13 +98,13 @@ impl Bot { } #[warn(unused_results)] - pub(crate) fn run_once(&mut self, mut prev_time: NaiveTime) -> Result<(), reqwest::Error> { + pub(crate) fn run_once(&mut self, prev_time: &mut NaiveTime) -> Result<(), reqwest::Error> { println!("{:#<1$}", "", 30); self.start_time = Utc::now(); - if self.start_time.time() - prev_time > chrono::Duration::seconds(6) { // Prod should use hours, add command line switch later and read duration from config + if self.start_time.time() - *prev_time > chrono::Duration::seconds(6) { // Prod should use hours, add command line switch later and read duration from config println!("Reloading Config"); - prev_time = self.start_time.time(); + *prev_time = self.start_time.time(); self.config.load(); match self.community_ids.load(&self.auth, &self.config.instance) { Ok(_) => {}, @@ -199,7 +199,7 @@ fn run_bot() { this.idle(); // 3 retries in case of connection issues let mut loop_breaker: u8 = 0; - while !this.run_once(old).is_ok() && loop_breaker <= 3 { + while !this.run_once(&mut old).is_ok() && loop_breaker <= 3 { println!("Unable to complete Bot cycle, retrying with fresh login credentials"); if this.login().is_ok() { this.community_ids.load(&this.auth, &this.config.instance); @@ -210,7 +210,7 @@ fn run_bot() { this.print_info(); println!("Start Time: {}", this.start_time.time()); println!("Previous Time: {}", old); - println!("Difference: {}", this.start_time.time() - old); + println!("Difference Start - Old: {}", this.start_time.time() - old); println!("Difference Now - Start: {}", Utc::now().time() - this.start_time.time()); this.idle(); }