Fix for prev_time var, more debug logging

This commit is contained in:
Neshura 2023-08-03 00:04:19 +02:00
parent 4109efc3c3
commit 1c619f1b97
Signed by: Neshura
GPG key ID: B6983AAA6B9A7A6C

View file

@ -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();
}