diff --git a/src/core/botinstance.rs b/src/core/botinstance.rs index 750061c..ce55ff9 100644 --- a/src/core/botinstance.rs +++ b/src/core/botinstance.rs @@ -410,38 +410,57 @@ impl BotInstance { // Only respond to those with th ebelow User Roles - if user_roles.contains(&identity::UserRole::Mod(Channel(msg.channel_login.clone()))) - || user_roles.contains(&identity::UserRole::SupMod(Channel(msg.channel_login.clone()))) - || user_roles.contains(&identity::UserRole::Broadcaster) - || user_roles.contains(&identity::UserRole::BotAdmin) - { + let outstr = + format!("sadg Module is disabled : {:?}",a); + + + let params = ExecBodyParams { + bot : Arc::clone(&bot), + msg : (*msg).clone(), + parent_act : Arc::clone(&act_clone), + }; + + // When sending a BotMsgTypeNotif, send_botmsg does Roles related validation as required + + botlock.botmgrs.chat.send_botmsg(super::chat::BotMsgType::Notif( + outstr + ), + params, + ).await; + + + // if user_roles.contains(&identity::UserRole::Mod(Channel(msg.channel_login.clone()))) + // || user_roles.contains(&identity::UserRole::SupMod(Channel(msg.channel_login.clone()))) + // || user_roles.contains(&identity::UserRole::Broadcaster) + // || user_roles.contains(&identity::UserRole::BotAdmin) + // { - // self.say_in_reply_to( - // ¶ms.msg, - // format!("uuh You do not have the right roles to send to {}", - // channel_login.clone(), - // ), - // params.clone() - // ).await; - let outstr = - format!("sadg Module is disabled : {:?}",a); + // // self.say_in_reply_to( + // // ¶ms.msg, + // // format!("uuh You do not have the right roles to send to {}", + // // channel_login.clone(), + // // ), + // // params.clone() + // // ).await; + // let outstr = + // format!("sadg Module is disabled : {:?}",a); - let params = ExecBodyParams { - bot : Arc::clone(&bot), - msg : (*msg).clone(), - parent_act : Arc::clone(&act_clone), - }; + // let params = ExecBodyParams { + // bot : Arc::clone(&bot), + // msg : (*msg).clone(), + // parent_act : Arc::clone(&act_clone), + // }; - botlock.botmgrs.chat.say_in_reply_to( - msg, - outstr, - // c.module.clone() - params, - ).await; + // botlock.botmgrs.chat.say_in_reply_to( + // msg, + // outstr, + // // c.module.clone() + // params, + // ).await; - } + // } // botlog::trace( diff --git a/src/core/botmodules.rs b/src/core/botmodules.rs index 5ae8ceb..6fded1b 100644 --- a/src/core/botmodules.rs +++ b/src/core/botmodules.rs @@ -117,9 +117,9 @@ pub async fn init(mgr: Arc) { // BotAction::C(c) => Some(&(*c).module), // BotAction::L(l) => Some(&(*l).module), // _ => None, - // }; + // // }; - let parent_module = params.get_parent_module().await; + // let parent_module = params.get_parent_module().await; @@ -191,20 +191,42 @@ pub async fn init(mgr: Arc) { Some(¶ms.msg), ); - // Only call Say if there is a parent module passed - if parent_module.is_some() { + // We should call a notification around here + + let bot = params.clone().bot; + + let botclone = Arc::clone(&bot); + let botlock = botclone.read().await; + let id = botlock.get_identity(); + let id = Arc::clone(&id); + let idlock = id.read().await; // <-- [ ] 03.24 - seems to work + let user_roles = idlock.getspecialuserroles( + params.msg.sender.name.clone(), + Some(Channel(params.msg.channel_login.clone())) + ).await; + + botlock.botmgrs.chat.send_botmsg(super::chat::BotMsgType::Notif( + outmsg.to_string() + ), + params.clone(), + ).await; + + + + // // Only call Say if there is a parent module passed + // if parent_module.is_some() { - botlock - .botmgrs - .chat - .say_in_reply_to( - ¶ms.msg, - outmsg.to_string() , - // parent_module.unwrap().clone() - params.clone(), - ).await; - } + // botlock + // .botmgrs + // .chat + // .say_in_reply_to( + // ¶ms.msg, + // outmsg.to_string() , + // // parent_module.unwrap().clone() + // params.clone(), + // ).await; + // } return; @@ -236,6 +258,9 @@ pub async fn init(mgr: Arc) { trg_level, id).await; + + // We should call a notification around here + let outmsg = match rslt.clone() { ChangeResult::Failed(a) => format!("Stare Failed : {}",a), @@ -243,22 +268,30 @@ pub async fn init(mgr: Arc) { ChangeResult::Success(a) => format!("YAAY Success : {}",a), }; + botlock.botmgrs.chat.send_botmsg(super::chat::BotMsgType::Notif( + outmsg.to_string() + ), + params.clone(), + ).await; + - // Only call Say if there is a parent module passed - if parent_module.is_some() { + + + // // Only call Say if there is a parent module passed + // if parent_module.is_some() { - botlock - .botmgrs - .chat - .say_in_reply_to( - ¶ms.msg, - outmsg.to_string(), - // parent_module.unwrap().clone() - params.clone(), - ).await; + // botlock + // .botmgrs + // .chat + // .say_in_reply_to( + // ¶ms.msg, + // outmsg.to_string(), + // // parent_module.unwrap().clone() + // params.clone(), + // ).await; - } + // } @@ -414,22 +447,29 @@ pub async fn init(mgr: Arc) { // _ => None, // }; + // We should call a notification around here + + botlock.botmgrs.chat.send_botmsg(super::chat::BotMsgType::Notif( + outmsg.to_string() + ), + params.clone(), + ).await; - // Only call Say if there is a parent module passed - if parent_module.is_some() { + // // Only call Say if there is a parent module passed + // if parent_module.is_some() { - botlock - .botmgrs - .chat - .say_in_reply_to( - ¶ms.msg, - outmsg.to_string(), - // ,parent_module.unwrap().clone() - params.clone() - ).await; + // botlock + // .botmgrs + // .chat + // .say_in_reply_to( + // ¶ms.msg, + // outmsg.to_string(), + // // ,parent_module.unwrap().clone() + // params.clone() + // ).await; - } + // } return; @@ -471,21 +511,29 @@ pub async fn init(mgr: Arc) { ChangeResult::Success(a) => format!("YAAY Success : {}",a), }; + // We should call a notification around here - // Only call Say if there is a parent module passed - if parent_module.is_some() { + botlock.botmgrs.chat.send_botmsg(super::chat::BotMsgType::Notif( + outmsg.to_string() + ), + params.clone(), + ).await; - botlock - .botmgrs - .chat - .say_in_reply_to( - ¶ms.msg, - outmsg.to_string(), - // parent_module.unwrap().clone() - params.clone(), - ).await; - } + // // Only call Say if there is a parent module passed + // if parent_module.is_some() { + + // botlock + // .botmgrs + // .chat + // .say_in_reply_to( + // ¶ms.msg, + // outmsg.to_string(), + // // parent_module.unwrap().clone() + // params.clone(), + // ).await; + + // } diff --git a/src/core/chat.rs b/src/core/chat.rs index c36fcf7..f07eb55 100644 --- a/src/core/chat.rs +++ b/src/core/chat.rs @@ -37,7 +37,7 @@ pub struct Chat { #[derive(Clone,Debug)] -enum BotMsgType<'a> { +pub enum BotMsgType<'a> { SayInReplyTo(&'a PrivmsgMessage,String), Say(String,String), Notif(String), // For Bot Sent Notifications @@ -66,7 +66,7 @@ impl Chat { // async fn send_botmsg(&self, msginput: BotMsgType<'_>) { #[async_recursion] // async fn send_botmsg(&self, msginput: BotMsgType<'_>, params : ExecBodyParams) { - async fn send_botmsg(&self, msginput: BotMsgType<'async_recursion>, params : ExecBodyParams) { + pub async fn send_botmsg(&self, msginput: BotMsgType<'async_recursion>, params : ExecBodyParams) { diff --git a/src/core/identity.rs b/src/core/identity.rs index 0be4dea..b9223bf 100644 --- a/src/core/identity.rs +++ b/src/core/identity.rs @@ -231,21 +231,30 @@ pub async fn init(mgr: Arc) { Some(¶ms.msg), ); - // Only call Say if there is a parent module passed - if parent_module.is_some() { + // We should call a notification around here + + botlock.botmgrs.chat.send_botmsg(super::chat::BotMsgType::Notif( + outmsg.to_string() + ), + params.clone(), + ).await; - botlock - .botmgrs - .chat - .say_in_reply_to( - ¶ms.msg, - outmsg.to_string(), - // parent_module.unwrap().clone() - params.clone(), - ).await; + // // Only call Say if there is a parent module passed + // if parent_module.is_some() { - } + + // botlock + // .botmgrs + // .chat + // .say_in_reply_to( + // ¶ms.msg, + // outmsg.to_string(), + // // parent_module.unwrap().clone() + // params.clone(), + // ).await; + + // } botlog::trace( // &format!("End of cmd_promote()"), @@ -458,21 +467,27 @@ pub async fn init(mgr: Arc) { Some(¶ms.msg), ); + botlock.botmgrs.chat.send_botmsg(super::chat::BotMsgType::Notif( + outmsg.to_string() + ), + params.clone(), + ).await; - // Only call Say if there is a parent module passed - if parent_module.is_some() { - botlock - .botmgrs - .chat - .say_in_reply_to( - ¶ms.msg, - outmsg.to_string(), - // parent_module.unwrap().clone() - params.clone() - ).await; + // // Only call Say if there is a parent module passed + // if parent_module.is_some() { - } + // botlock + // .botmgrs + // .chat + // .say_in_reply_to( + // ¶ms.msg, + // outmsg.to_string(), + // // parent_module.unwrap().clone() + // params.clone() + // ).await; + + // }