refactor core to use Notif msg

This commit is contained in:
ModulatingForce 2024-03-25 14:11:21 -04:00
parent c0603739c9
commit 628db3c229
4 changed files with 184 additions and 102 deletions

View file

@ -410,20 +410,6 @@ impl BotInstance {
// Only respond to those with th ebelow User Roles // 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)
{
// self.say_in_reply_to(
// &params.msg,
// format!("uuh You do not have the right roles to send to {}",
// channel_login.clone(),
// ),
// params.clone()
// ).await;
let outstr = let outstr =
format!("sadg Module is disabled : {:?}",a); format!("sadg Module is disabled : {:?}",a);
@ -434,14 +420,47 @@ impl BotInstance {
parent_act : Arc::clone(&act_clone), parent_act : Arc::clone(&act_clone),
}; };
botlock.botmgrs.chat.say_in_reply_to( // When sending a BotMsgTypeNotif, send_botmsg does Roles related validation as required
msg,
outstr, botlock.botmgrs.chat.send_botmsg(super::chat::BotMsgType::Notif(
// c.module.clone() outstr
),
params, params,
).await; ).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(
// // &params.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),
// };
// botlock.botmgrs.chat.say_in_reply_to(
// msg,
// outstr,
// // c.module.clone()
// params,
// ).await;
// }
// botlog::trace( // botlog::trace(

View file

@ -117,9 +117,9 @@ pub async fn init(mgr: Arc<ModulesManager>) {
// BotAction::C(c) => Some(&(*c).module), // BotAction::C(c) => Some(&(*c).module),
// BotAction::L(l) => Some(&(*l).module), // BotAction::L(l) => Some(&(*l).module),
// _ => None, // _ => 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<ModulesManager>) {
Some(&params.msg), Some(&params.msg),
); );
// Only call Say if there is a parent module passed // We should call a notification around here
if parent_module.is_some() {
let bot = params.clone().bot;
botlock let botclone = Arc::clone(&bot);
.botmgrs let botlock = botclone.read().await;
.chat let id = botlock.get_identity();
.say_in_reply_to( let id = Arc::clone(&id);
&params.msg, let idlock = id.read().await; // <-- [ ] 03.24 - seems to work
outmsg.to_string() , let user_roles = idlock.getspecialuserroles(
// parent_module.unwrap().clone() 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(), params.clone(),
).await; ).await;
}
// // Only call Say if there is a parent module passed
// if parent_module.is_some() {
// botlock
// .botmgrs
// .chat
// .say_in_reply_to(
// &params.msg,
// outmsg.to_string() ,
// // parent_module.unwrap().clone()
// params.clone(),
// ).await;
// }
return; return;
@ -237,28 +259,39 @@ pub async fn init(mgr: Arc<ModulesManager>) {
id).await; id).await;
// We should call a notification around here
let outmsg = match rslt.clone() { let outmsg = match rslt.clone() {
ChangeResult::Failed(a) => format!("Stare Failed : {}",a), ChangeResult::Failed(a) => format!("Stare Failed : {}",a),
ChangeResult::NoChange(a) => format!("Hmm No Change : {}",a), ChangeResult::NoChange(a) => format!("Hmm No Change : {}",a),
ChangeResult::Success(a) => format!("YAAY Success : {}",a), ChangeResult::Success(a) => format!("YAAY Success : {}",a),
}; };
botlock.botmgrs.chat.send_botmsg(super::chat::BotMsgType::Notif(
// Only call Say if there is a parent module passed outmsg.to_string()
if parent_module.is_some() { ),
botlock
.botmgrs
.chat
.say_in_reply_to(
&params.msg,
outmsg.to_string(),
// parent_module.unwrap().clone()
params.clone(), params.clone(),
).await; ).await;
}
// // Only call Say if there is a parent module passed
// if parent_module.is_some() {
// botlock
// .botmgrs
// .chat
// .say_in_reply_to(
// &params.msg,
// outmsg.to_string(),
// // parent_module.unwrap().clone()
// params.clone(),
// ).await;
// }
@ -414,22 +447,29 @@ pub async fn init(mgr: Arc<ModulesManager>) {
// _ => None, // _ => None,
// }; // };
// We should call a notification around here
botlock.botmgrs.chat.send_botmsg(super::chat::BotMsgType::Notif(
// Only call Say if there is a parent module passed outmsg.to_string()
if parent_module.is_some() { ),
params.clone(),
botlock
.botmgrs
.chat
.say_in_reply_to(
&params.msg,
outmsg.to_string(),
// ,parent_module.unwrap().clone()
params.clone()
).await; ).await;
}
// // Only call Say if there is a parent module passed
// if parent_module.is_some() {
// botlock
// .botmgrs
// .chat
// .say_in_reply_to(
// &params.msg,
// outmsg.to_string(),
// // ,parent_module.unwrap().clone()
// params.clone()
// ).await;
// }
return; return;
@ -471,21 +511,29 @@ pub async fn init(mgr: Arc<ModulesManager>) {
ChangeResult::Success(a) => format!("YAAY Success : {}",a), ChangeResult::Success(a) => format!("YAAY Success : {}",a),
}; };
// We should call a notification around here
// Only call Say if there is a parent module passed botlock.botmgrs.chat.send_botmsg(super::chat::BotMsgType::Notif(
if parent_module.is_some() { outmsg.to_string()
),
botlock
.botmgrs
.chat
.say_in_reply_to(
&params.msg,
outmsg.to_string(),
// parent_module.unwrap().clone()
params.clone(), params.clone(),
).await; ).await;
}
// // Only call Say if there is a parent module passed
// if parent_module.is_some() {
// botlock
// .botmgrs
// .chat
// .say_in_reply_to(
// &params.msg,
// outmsg.to_string(),
// // parent_module.unwrap().clone()
// params.clone(),
// ).await;
// }

View file

@ -37,7 +37,7 @@ pub struct Chat {
#[derive(Clone,Debug)] #[derive(Clone,Debug)]
enum BotMsgType<'a> { pub enum BotMsgType<'a> {
SayInReplyTo(&'a PrivmsgMessage,String), SayInReplyTo(&'a PrivmsgMessage,String),
Say(String,String), Say(String,String),
Notif(String), // For Bot Sent Notifications Notif(String), // For Bot Sent Notifications
@ -66,7 +66,7 @@ impl Chat {
// async fn send_botmsg(&self, msginput: BotMsgType<'_>) { // async fn send_botmsg(&self, msginput: BotMsgType<'_>) {
#[async_recursion] #[async_recursion]
// async fn send_botmsg(&self, msginput: BotMsgType<'_>, params : ExecBodyParams) { // 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) {

View file

@ -231,21 +231,30 @@ pub async fn init(mgr: Arc<ModulesManager>) {
Some(&params.msg), Some(&params.msg),
); );
// Only call Say if there is a parent module passed // We should call a notification around here
if parent_module.is_some() {
botlock.botmgrs.chat.send_botmsg(super::chat::BotMsgType::Notif(
botlock outmsg.to_string()
.botmgrs ),
.chat
.say_in_reply_to(
&params.msg,
outmsg.to_string(),
// parent_module.unwrap().clone()
params.clone(), params.clone(),
).await; ).await;
}
// // Only call Say if there is a parent module passed
// if parent_module.is_some() {
// botlock
// .botmgrs
// .chat
// .say_in_reply_to(
// &params.msg,
// outmsg.to_string(),
// // parent_module.unwrap().clone()
// params.clone(),
// ).await;
// }
botlog::trace( botlog::trace(
// &format!("End of cmd_promote()"), // &format!("End of cmd_promote()"),
@ -458,21 +467,27 @@ pub async fn init(mgr: Arc<ModulesManager>) {
Some(&params.msg), Some(&params.msg),
); );
botlock.botmgrs.chat.send_botmsg(super::chat::BotMsgType::Notif(
// Only call Say if there is a parent module passed outmsg.to_string()
if parent_module.is_some() { ),
params.clone(),
botlock
.botmgrs
.chat
.say_in_reply_to(
&params.msg,
outmsg.to_string(),
// parent_module.unwrap().clone()
params.clone()
).await; ).await;
}
// // Only call Say if there is a parent module passed
// if parent_module.is_some() {
// botlock
// .botmgrs
// .chat
// .say_in_reply_to(
// &params.msg,
// outmsg.to_string(),
// // parent_module.unwrap().clone()
// params.clone()
// ).await;
// }