parentact to ExecBodyParams

This commit is contained in:
ModulatingForce 2024-03-24 15:46:08 -04:00
commit 7e5e43fec3
4 changed files with 58 additions and 21 deletions

View file

@ -47,7 +47,7 @@ pub enum ChangeResult {
pub struct Channel(pub String);
use super::bot_actions::ExecBodyParams;
use super::botmodules::StatusType;
use super::botmodules::{BotAction, StatusType};
#[derive(Clone)]
pub struct BotManagers {
@ -264,16 +264,6 @@ impl BotInstance {
// // [ ] #todo Need to run through all Listener Bodies for Enabled Modules for the context of the message (e.g., ModStatus is Enabled in the context for the channel)
let botlock = bot.read().await;
let actsdb = Arc::clone(&botlock.botmodules.botactions);
let actsdblock = actsdb.read().await;
botlog::debug(
format!("# of BotModules: {}", (*actsdblock).len()).as_str(),
Some("BotInstance > listener_main_prvmsg()".to_string()),
Some(msg),
);
/*
[ ] What we should do instead is :
@ -309,9 +299,30 @@ impl BotInstance {
},
};
let botlock = bot.read().await;
let actsdb = Arc::clone(&botlock.botmodules.botactions);
let actsdblock = actsdb.read().await;
botlog::debug(
format!("# of BotModules: {}", (*actsdblock).len()).as_str(),
Some("BotInstance > listener_main_prvmsg()".to_string()),
Some(msg),
);
for acts in (*actsdblock).values() {
for a in acts {
match a {
// let act_ar = Arc::new(RwLock::new(a));
// let act_ar_clone = Arc::clone(&act_ar);
let act_clone = Arc::clone(a);
// match a {
// match &(*act_ar_clone.read().await) {
match &(*act_clone.read().await) {
crate::core::botmodules::BotAction::C(c) => {
/*
BotCommand handling -
@ -454,7 +465,13 @@ impl BotInstance {
let a = Arc::clone(&bot);
// c.execute(a, msg.clone()).await;
c.execute(ExecBodyParams { bot : a, msg : msg.clone() }).await;
// c.execute(ExecBodyParams { bot : a, msg : msg.clone() }).await;
c.execute(ExecBodyParams {
bot : a,
msg : msg.clone() ,
// parent_act : BotAction::C(c) ,
parent_act : Arc::clone(&act_clone),
}).await;
botlog::trace(
"exit out of execution",
@ -501,7 +518,12 @@ impl BotInstance {
} else {
let a = Arc::clone(&bot);
// l.execute(a, msg.clone()).await;
l.execute(ExecBodyParams { bot : a, msg : msg.clone()} ).await;
l.execute(ExecBodyParams {
bot : a,
msg : msg.clone() ,
// parent_act : BotAction::L(l) ,
parent_act : Arc::clone(&act_clone),
} ).await;
}
}