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,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(
// &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);
// // 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),
};
// 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(

View file

@ -117,9 +117,9 @@ pub async fn init(mgr: Arc<ModulesManager>) {
// 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<ModulesManager>) {
Some(&params.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(
&params.msg,
outmsg.to_string() ,
// parent_module.unwrap().clone()
params.clone(),
).await;
}
// botlock
// .botmgrs
// .chat
// .say_in_reply_to(
// &params.msg,
// outmsg.to_string() ,
// // parent_module.unwrap().clone()
// params.clone(),
// ).await;
// }
return;
@ -236,6 +258,9 @@ pub async fn init(mgr: Arc<ModulesManager>) {
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<ModulesManager>) {
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(
&params.msg,
outmsg.to_string(),
// parent_module.unwrap().clone()
params.clone(),
).await;
// 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,
// };
// 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(
&params.msg,
outmsg.to_string(),
// ,parent_module.unwrap().clone()
params.clone()
).await;
// botlock
// .botmgrs
// .chat
// .say_in_reply_to(
// &params.msg,
// outmsg.to_string(),
// // ,parent_module.unwrap().clone()
// params.clone()
// ).await;
}
// }
return;
@ -471,21 +511,29 @@ pub async fn init(mgr: Arc<ModulesManager>) {
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(
&params.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(
// &params.msg,
// outmsg.to_string(),
// // parent_module.unwrap().clone()
// params.clone(),
// ).await;
// }

View file

@ -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) {

View file

@ -231,21 +231,30 @@ pub async fn init(mgr: Arc<ModulesManager>) {
Some(&params.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(
&params.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(
// &params.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<ModulesManager>) {
Some(&params.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(
&params.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(
// &params.msg,
// outmsg.to_string(),
// // parent_module.unwrap().clone()
// params.clone()
// ).await;
// }