Add debug logs
All checks were successful
Build and push container image / build (push) Successful in 12m40s
Build and push container image / deploy (push) Successful in 34s

This commit is contained in:
toast 2024-08-16 11:42:52 +10:00
parent dfa1ae75b2
commit cb660d13f4
5 changed files with 13 additions and 22 deletions

2
Cargo.lock generated
View File

@ -1023,7 +1023,7 @@ dependencies = [
[[package]] [[package]]
name = "kon" name = "kon"
version = "0.3.17" version = "0.3.18"
dependencies = [ dependencies = [
"bb8", "bb8",
"bb8-postgres", "bb8-postgres",

View File

@ -1,6 +1,6 @@
[package] [package]
name = "kon" name = "kon"
version = "0.3.17" version = "0.3.18"
edition = "2021" edition = "2021"
[dependencies] [dependencies]

View File

@ -3,7 +3,7 @@ mod processor; // Process the feeds and send it off to Discord
mod esxi; mod esxi;
mod github; mod github;
mod gportal; mod gportal;
mod rust_msg; mod rust;
use crate::{ use crate::{
Error, Error,

View File

@ -1,4 +1,5 @@
use super::{ use super::{
task_info,
task_err, task_err,
TASK_NAME, TASK_NAME,
BINARY_PROPERTIES, BINARY_PROPERTIES,
@ -6,7 +7,7 @@ use super::{
esxi::esxi_embed, esxi::esxi_embed,
github::github_embed, github::github_embed,
gportal::gportal_embed, gportal::gportal_embed,
rust_msg::rust_message rust::rust_message
}; };
use regex::Regex; use regex::Regex;
@ -57,26 +58,20 @@ pub async fn feed_processor(ctx: &Context) {
} }
if Regex::new(r"(?i)\bresolved\b").unwrap().is_match(&new_desc) { if Regex::new(r"(?i)\bresolved\b").unwrap().is_match(&new_desc) {
task_info(TASK_NAME, &format!("GPortal func, replying to message id: {}", msg_id));
message.reply(&ctx.http, "This incident has been marked as resolved!").await.unwrap(); message.reply(&ctx.http, "This incident has been marked as resolved!").await.unwrap();
redis.del(&rkey).await.unwrap(); redis.del(&rkey).await.unwrap();
} }
} }
} else {
// If the message is invalid ID, send a new message instead
let message = channel.send_message(&ctx.http, CreateMessage::new()
.content("*Uh-oh! G-Portal is having issues!*").add_embed(embed)
).await.unwrap();
redis.set(&rkey, &message.id.to_string()).await.unwrap();
redis.expire(&rkey, 36000).await.unwrap();
} }
}, },
Ok(None) | Err(_) => { Ok(None) | Err(_) => {
// If the message is not found, send a new message instead // If the message is invalid ID, send a new message instead
let message = channel.send_message(&ctx.http, CreateMessage::new() let message = channel.send_message(&ctx.http, CreateMessage::new()
.content("*Uh-oh! G-Portal is having issues!*").add_embed(embed) .content("*Uh-oh! G-Portal is having issues!*").add_embed(embed)
).await.unwrap(); ).await.unwrap();
redis.set(&rkey, &message.id.to_string()).await.unwrap(); redis.set(&rkey, &message.id.to_string()).await.unwrap();
redis.expire(&rkey, 36000).await.unwrap(); redis.expire(&rkey, 36000).await.unwrap();
} }
} }
}, },
@ -109,15 +104,11 @@ pub async fn feed_processor(ctx: &Context) {
} }
if Regex::new(r"(?i)\bresolved\b").unwrap().is_match(&new_desc) { if Regex::new(r"(?i)\bresolved\b").unwrap().is_match(&new_desc) {
task_info(TASK_NAME, &format!("GitHub func, replying to message id: {}", msg_id));
message.reply(&ctx.http, "This incident has been marked as resolved!").await.unwrap(); message.reply(&ctx.http, "This incident has been marked as resolved!").await.unwrap();
redis.del(&rkey).await.unwrap(); redis.del(&rkey).await.unwrap();
} }
} }
} else {
// If the message is invalid ID, send a new message instead
let message = channel.send_message(&ctx.http, CreateMessage::new().add_embed(embed)).await.unwrap();
redis.set(&rkey, &message.id.to_string()).await.unwrap();
redis.expire(&rkey, 36000).await.unwrap();
} }
}, },
Ok(None) | Err(_) => { Ok(None) | Err(_) => {