From 8b3395c19a26da918e70e14cfe00fb1d089cfc03 Mon Sep 17 00:00:00 2001 From: ModulatingForce <116608425+modulatingforce@users.noreply.github.com> Date: Sun, 24 Mar 2024 23:42:59 -0400 Subject: [PATCH] smol --- src/core/chat.rs | 156 +++++++++++++++++++++++++++-------------------- 1 file changed, 89 insertions(+), 67 deletions(-) diff --git a/src/core/chat.rs b/src/core/chat.rs index 4cfc027..2a6fc26 100644 --- a/src/core/chat.rs +++ b/src/core/chat.rs @@ -64,6 +64,9 @@ impl Chat { // async fn send_botmsg(&self, msginput: BotMsgType<'_>) { async fn send_botmsg(&self, msginput: BotMsgType<'_>, params : ExecBodyParams) { + + + /* formats message before sending to TwitchIRC @@ -74,7 +77,7 @@ impl Chat { */ - botlog::trace( + botlog::trace( format!("send_bot_msg params : {:?}",msginput).as_str(), Some("chat.rs > send_botmsg ".to_string()), Some(¶ms.msg), @@ -90,47 +93,7 @@ impl Chat { }; - botlog::trace( - "BEFORE GET_CHANNEL_STATUS", - Some("chat.rs > send_botmsg ".to_string()), - Some(¶ms.msg), - ); - - let rslt = self.client.get_channel_status(channel_login.clone()).await == (false,false); - botlog::trace( - format!("GET_CHANNEL_STATUS result = {:?}",rslt).as_str(), - Some("chat.rs > send_botmsg ".to_string()), - Some(¶ms.msg), - ); - - Log::flush(); - - - - if rslt { - // in the case where the provided channel isn't something we're known to be connected to - - botlog::warn( - &format!("A message attempted to send for a Non-Joined Channel : {}",channel_login.clone()), - Some("Chat > send_botmsg".to_string()), - None, - ); - return ; - } - - /* - [x] !! => 03.24 - Somewhere around here, we should be validating module for target channel - */ - - - /* - - Use ModulesManager.modstatus - - modstatus(&self, in_module: BotModule, in_chnl: Channel) -> StatusType - - */ - botlog::trace( "BEFORE parent_module call", @@ -150,6 +113,65 @@ impl Chat { Channel(channel_login.clone()) ).await; + + // botlog::trace( + // "BEFORE GET_CHANNEL_STATUS", + // Some("chat.rs > send_botmsg ".to_string()), + // Some(¶ms.msg), + // ); + + // let rslt = self.client.get_channel_status(channel_login.clone()).await == (false,false); + + // botlog::trace( + // format!("GET_CHANNEL_STATUS result = {:?}",rslt).as_str(), + // Some("chat.rs > send_botmsg ".to_string()), + // Some(¶ms.msg), + // ); + + // Log::flush(); + + + + // if rslt { + // // in the case where the provided channel isn't something we're known to be connected to + + // botlog::warn( + // &format!("A message attempted to send for a Non-Joined Channel : {}",channel_login.clone()), + // Some("Chat > send_botmsg".to_string()), + // None, + // ); + // return ; + // } + + if !params.bot.read().await.bot_channels.contains(&Channel(channel_login.clone())) { + botlog::warn( + &format!("A message attempted to send for a Non-Joined Channel : {}",channel_login.clone()), + Some("Chat > send_botmsg".to_string()), + None, + ); + + self.say_in_reply_to( + ¶ms.msg, + "uuh Bot can't send to a channel it isn't joined".to_string(), + params.clone() + ).await; + + return ; + } + + /* + [x] !! => 03.24 - Somewhere around here, we should be validating module for target channel + */ + + + /* + - Use ModulesManager.modstatus + + modstatus(&self, in_module: BotModule, in_chnl: Channel) -> StatusType + + */ + + // match modstatus { // super::botmodules::StatusType::Enabled(_) => (), // super::botmodules::StatusType::Disabled(_) => (), @@ -190,35 +212,35 @@ impl Chat { Log::flush(); - // self.say_in_reply_to( - // a, - // format!("uuh {:?} is disabled on {} : {:?}", - // parent_module.clone().unwrap(), - // channel_login.clone(), - // lvl - // ), - // params.clone() - // ).await; + self.say_in_reply_to( + a, + format!("uuh {:?} is disabled on {} : {:?}", + parent_module.clone().unwrap(), + channel_login.clone(), + lvl + ), + params.clone() + ).await; - let chat_clone = self.clone(); + // let chat_clone = self.clone(); - // tokio::spawn( async move { - // // for _ in 0..5 { - // // println!(">> Innterroutine triggered!"); - // // sleep(Duration::from_secs_f64(5.0)).await; - // // } + // // tokio::spawn( async move { + // // // for _ in 0..5 { + // // // println!(">> Innterroutine triggered!"); + // // // sleep(Duration::from_secs_f64(5.0)).await; + // // // } - // chat_clone.say_in_reply_to( - // a, - // format!("uuh {:?} is disabled on {} : {:?}", - // parent_module.clone().unwrap(), - // channel_login.clone(), - // lvl - // ), - // params.clone() - // ).await; - // } - // ); + // // chat_clone.say_in_reply_to( + // // a, + // // format!("uuh {:?} is disabled on {} : {:?}", + // // parent_module.clone().unwrap(), + // // channel_login.clone(), + // // lvl + // // ), + // // params.clone() + // // ).await; + // // } + // // ); botlog::trace(