Exec Body Fn should be passed Parent BotAction
#43
4 changed files with 136 additions and 78 deletions
|
@ -390,40 +390,48 @@ impl BotInstance {
|
|||
Some(msg),
|
||||
);
|
||||
|
||||
|
||||
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(
|
||||
msg.sender.name.clone(),
|
||||
Some(Channel(msg.channel_login.clone()))
|
||||
).await;
|
||||
|
||||
|
||||
botlog::trace(
|
||||
"ACQUIRING WRITE LOCK : ID",
|
||||
&format!("For Disabled Command Evaluating User Roles {:?}", user_roles),
|
||||
Some("BotInstance > listener_main_prvmsg()".to_string()),
|
||||
Some(msg),
|
||||
);
|
||||
|
||||
|
||||
const OF_CMD_CHANNEL:Channel = Channel(String::new());
|
||||
// Only respond to those with th ebelow User Roles
|
||||
|
||||
let elevated_access = {
|
||||
let mut idlock = id.write().await;
|
||||
let (permissability, _) = idlock
|
||||
.can_user_run_prvmsg(msg,
|
||||
vec![
|
||||
identity::UserRole::BotAdmin,
|
||||
identity::UserRole::Mod(OF_CMD_CHANNEL),
|
||||
identity::UserRole::SupMod(OF_CMD_CHANNEL),
|
||||
identity::UserRole::Broadcaster,
|
||||
])
|
||||
.await;
|
||||
|
||||
permissability
|
||||
};
|
||||
|
||||
if let Permissible::Allow = elevated_access {
|
||||
let botlock = bot.read().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);
|
||||
|
||||
|
||||
let params = ExecBodyParams {
|
||||
bot : Arc::clone(&bot),
|
||||
msg : (*msg).clone(),
|
||||
parent_act : Arc::clone(&act_clone),
|
||||
|
||||
};
|
||||
|
||||
botlock.botmgrs.chat.say_in_reply_to(
|
||||
|
@ -432,7 +440,53 @@ impl BotInstance {
|
|||
// c.module.clone()
|
||||
params,
|
||||
).await;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
// botlog::trace(
|
||||
// "ACQUIRING WRITE LOCK : ID",
|
||||
// Some("BotInstance > listener_main_prvmsg()".to_string()),
|
||||
// Some(msg),
|
||||
// );
|
||||
|
||||
|
||||
// const OF_CMD_CHANNEL:Channel = Channel(String::new());
|
||||
|
||||
// let elevated_access = {
|
||||
// let mut idlock = id.write().await;
|
||||
// let (permissability, _) = idlock
|
||||
// .can_user_run_prvmsg(msg,
|
||||
// vec![
|
||||
// identity::UserRole::BotAdmin,
|
||||
// identity::UserRole::Mod(OF_CMD_CHANNEL),
|
||||
// identity::UserRole::SupMod(OF_CMD_CHANNEL),
|
||||
// identity::UserRole::Broadcaster,
|
||||
// ])
|
||||
// .await;
|
||||
|
||||
// permissability
|
||||
// };
|
||||
|
||||
// if let Permissible::Allow = elevated_access {
|
||||
// let botlock = bot.read().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;
|
||||
// }
|
||||
|
||||
return;
|
||||
};
|
||||
|
|
|
@ -82,6 +82,7 @@ impl Chat {
|
|||
Some("chat.rs > send_botmsg ".to_string()),
|
||||
Some(¶ms.msg),
|
||||
);
|
||||
Log::flush();
|
||||
|
||||
let (channel_login,mut outmsg) = match msginput.clone() {
|
||||
BotMsgType::SayInReplyTo(msg, outmsg) => {
|
||||
|
@ -150,12 +151,20 @@ impl Chat {
|
|||
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;
|
||||
// self.say_in_reply_to(
|
||||
// ¶ms.msg,
|
||||
// "uuh Bot can't send to a channel it isn't joined".to_string(),
|
||||
// params.clone()
|
||||
// ).await;
|
||||
if let BotMsgType::SayInReplyTo(a,_) = msginput {
|
||||
|
||||
self.say_in_reply_to(
|
||||
a,
|
||||
"uuh Bot can't send to a channel it isn't joined".to_string(),
|
||||
params.clone()
|
||||
).await;
|
||||
|
||||
}
|
||||
return ;
|
||||
}
|
||||
|
||||
|
@ -222,26 +231,6 @@ impl Chat {
|
|||
params.clone()
|
||||
).await;
|
||||
|
||||
// let chat_clone = self.clone();
|
||||
|
||||
// // 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;
|
||||
// // }
|
||||
// // );
|
||||
|
||||
|
||||
botlog::trace(
|
||||
"AFTER potential Async recursion",
|
||||
|
@ -269,6 +258,9 @@ impl Chat {
|
|||
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
|
||||
|
@ -293,23 +285,35 @@ impl Chat {
|
|||
Some(Channel(channel_login.clone()))
|
||||
).await;
|
||||
|
||||
botlog::trace(
|
||||
format!("BEFORE user roles check check : userroles = {:?}",user_roles).as_str(),
|
||||
Some("chat.rs > send_botmsg ".to_string()),
|
||||
Some(¶ms.msg),
|
||||
);
|
||||
|
||||
Log::flush();
|
||||
|
||||
// [ ] If user has any of the following target roles, they will be allowed - otherwise, they will not be allowed to send
|
||||
// - Otherwise if not (checked here) , this will not run
|
||||
// - NOTE : For now, I've removed BotAdmin just for curiosity - BotAdmins can always elevate themselves if they want
|
||||
|
||||
// if !(user_roles.contains(&identity::UserRole::Mod(Channel(channel_login.clone())))
|
||||
// || user_roles.contains(&identity::UserRole::SupMod(Channel(channel_login.clone())))
|
||||
// || user_roles.contains(&identity::UserRole::Broadcaster))
|
||||
if !(user_roles.contains(&identity::UserRole::Mod(Channel(channel_login.clone())))
|
||||
|| user_roles.contains(&identity::UserRole::SupMod(Channel(channel_login.clone())))
|
||||
|| user_roles.contains(&identity::UserRole::Broadcaster))
|
||||
|| user_roles.contains(&identity::UserRole::SupMod(Channel(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;
|
||||
// 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;
|
||||
|
||||
return;
|
||||
|
||||
|
|
|
@ -142,7 +142,7 @@ pub async fn init(mgr: Arc<ModulesManager>) {
|
|||
Some(¶ms.msg),
|
||||
);
|
||||
|
||||
let rollwin = rand::thread_rng().gen_ratio(1, 1);
|
||||
let rollwin = rand::thread_rng().gen_ratio(1, 10);
|
||||
|
||||
if rollwin {
|
||||
botlog::debug(
|
||||
|
|
|
@ -145,34 +145,34 @@ async fn sayout(params : ExecBodyParams) {
|
|||
None,
|
||||
);
|
||||
|
||||
// if botlock.botmgrs.chat.client.get_channel_status(trgchnl.to_string().clone()).await == (false,false) {
|
||||
if !botlock.bot_channels.contains(&Channel(trgchnl.to_lowercase().to_string().clone())) {
|
||||
// // if botlock.botmgrs.chat.client.get_channel_status(trgchnl.to_string().clone()).await == (false,false) {
|
||||
// if !botlock.bot_channels.contains(&Channel(trgchnl.to_lowercase().to_string().clone())) {
|
||||
|
||||
// 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 : {}",trgchnl.to_string().clone()),
|
||||
Some("Chat > send_botmsg".to_string()),
|
||||
None,
|
||||
);
|
||||
// return ;
|
||||
// // 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 : {}",trgchnl.to_string().clone()),
|
||||
// Some("Chat > send_botmsg".to_string()),
|
||||
// None,
|
||||
// );
|
||||
// // return ;
|
||||
|
||||
if parent_module.clone().is_some() {
|
||||
// if parent_module.clone().is_some() {
|
||||
|
||||
|
||||
botlock
|
||||
.botmgrs
|
||||
.chat
|
||||
.say_in_reply_to(
|
||||
¶ms.msg,
|
||||
format!("Not a Joined Channel : {}",trgchnl),
|
||||
// parent_module.clone().unwrap().clone()
|
||||
params.clone(),
|
||||
).await;
|
||||
// botlock
|
||||
// .botmgrs
|
||||
// .chat
|
||||
// .say_in_reply_to(
|
||||
// ¶ms.msg,
|
||||
// format!("Not a Joined Channel : {}",trgchnl),
|
||||
// // parent_module.clone().unwrap().clone()
|
||||
// params.clone(),
|
||||
// ).await;
|
||||
|
||||
}
|
||||
// }
|
||||
|
||||
|
||||
}
|
||||
// }
|
||||
|
||||
/*
|
||||
1. If a Reply ,
|
||||
|
|
Loading…
Reference in a new issue