This commit is contained in:
ModulatingForce 2024-03-25 09:30:15 -04:00
parent 35db264b9e
commit 246c3d98e6
4 changed files with 136 additions and 78 deletions

View file

@ -390,40 +390,48 @@ impl BotInstance {
Some(msg), 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( botlog::trace(
"ACQUIRING WRITE LOCK : ID", &format!("For Disabled Command Evaluating User Roles {:?}", user_roles),
Some("BotInstance > listener_main_prvmsg()".to_string()), Some("BotInstance > listener_main_prvmsg()".to_string()),
Some(msg), Some(msg),
); );
// Only respond to those with th ebelow User Roles
const OF_CMD_CHANNEL:Channel = Channel(String::new());
let elevated_access = { if user_roles.contains(&identity::UserRole::Mod(Channel(msg.channel_login.clone())))
let mut idlock = id.write().await; || user_roles.contains(&identity::UserRole::SupMod(Channel(msg.channel_login.clone())))
let (permissability, _) = idlock || user_roles.contains(&identity::UserRole::Broadcaster)
.can_user_run_prvmsg(msg, || user_roles.contains(&identity::UserRole::BotAdmin)
vec![ {
identity::UserRole::BotAdmin,
identity::UserRole::Mod(OF_CMD_CHANNEL),
identity::UserRole::SupMod(OF_CMD_CHANNEL), // self.say_in_reply_to(
identity::UserRole::Broadcaster, // &params.msg,
]) // format!("uuh You do not have the right roles to send to {}",
.await; // channel_login.clone(),
// ),
permissability // params.clone()
}; // ).await;
if let Permissible::Allow = elevated_access {
let botlock = bot.read().await;
let outstr = let outstr =
format!("sadg Module is disabled : {:?}",a); format!("sadg Module is disabled : {:?}",a);
let params = ExecBodyParams { let params = ExecBodyParams {
bot : Arc::clone(&bot), bot : Arc::clone(&bot),
msg : (*msg).clone(), msg : (*msg).clone(),
parent_act : Arc::clone(&act_clone), parent_act : Arc::clone(&act_clone),
}; };
botlock.botmgrs.chat.say_in_reply_to( botlock.botmgrs.chat.say_in_reply_to(
@ -432,7 +440,53 @@ impl BotInstance {
// c.module.clone() // c.module.clone()
params, params,
).await; ).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; return;
}; };

View file

@ -82,6 +82,7 @@ impl Chat {
Some("chat.rs > send_botmsg ".to_string()), Some("chat.rs > send_botmsg ".to_string()),
Some(&params.msg), Some(&params.msg),
); );
Log::flush();
let (channel_login,mut outmsg) = match msginput.clone() { let (channel_login,mut outmsg) = match msginput.clone() {
BotMsgType::SayInReplyTo(msg, outmsg) => { BotMsgType::SayInReplyTo(msg, outmsg) => {
@ -150,12 +151,20 @@ impl Chat {
None, None,
); );
self.say_in_reply_to( // self.say_in_reply_to(
&params.msg, // &params.msg,
"uuh Bot can't send to a channel it isn't joined".to_string(), // "uuh Bot can't send to a channel it isn't joined".to_string(),
params.clone() // params.clone()
).await; // ).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 ; return ;
} }
@ -222,26 +231,6 @@ impl Chat {
params.clone() params.clone()
).await; ).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( botlog::trace(
"AFTER potential Async recursion", "AFTER potential Async recursion",
@ -269,6 +258,9 @@ impl Chat {
*/ */
/* /*
@ -293,23 +285,35 @@ impl Chat {
Some(Channel(channel_login.clone())) Some(Channel(channel_login.clone()))
).await; ).await;
botlog::trace(
format!("BEFORE user roles check check : userroles = {:?}",user_roles).as_str(),
Some("chat.rs > send_botmsg ".to_string()),
Some(&params.msg),
);
Log::flush();
// [ ] If user has any of the following target roles, they will be allowed - otherwise, they will not be allowed to send // [ ] 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 // - 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 // - 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()))) 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::SupMod(Channel(channel_login.clone())))
|| user_roles.contains(&identity::UserRole::Broadcaster)) || user_roles.contains(&identity::UserRole::Broadcaster)
|| user_roles.contains(&identity::UserRole::BotAdmin))
{ {
self.say_in_reply_to( // self.say_in_reply_to(
&params.msg, // &params.msg,
format!("uuh You do not have the right roles to send to {}", // format!("uuh You do not have the right roles to send to {}",
channel_login.clone(), // channel_login.clone(),
), // ),
params.clone() // params.clone()
).await; // ).await;
return; return;

View file

@ -142,7 +142,7 @@ pub async fn init(mgr: Arc<ModulesManager>) {
Some(&params.msg), Some(&params.msg),
); );
let rollwin = rand::thread_rng().gen_ratio(1, 1); let rollwin = rand::thread_rng().gen_ratio(1, 10);
if rollwin { if rollwin {
botlog::debug( botlog::debug(

View file

@ -145,34 +145,34 @@ async fn sayout(params : ExecBodyParams) {
None, None,
); );
// if botlock.botmgrs.chat.client.get_channel_status(trgchnl.to_string().clone()).await == (false,false) { // // 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.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 // // in the case where the provided channel isn't something we're known to be connected to
botlog::warn( // botlog::warn(
&format!("A message attempted to send for a Non-Joined Channel : {}",trgchnl.to_string().clone()), // &format!("A message attempted to send for a Non-Joined Channel : {}",trgchnl.to_string().clone()),
Some("Chat > send_botmsg".to_string()), // Some("Chat > send_botmsg".to_string()),
None, // None,
); // );
// return ; // // return ;
if parent_module.clone().is_some() { // if parent_module.clone().is_some() {
botlock // botlock
.botmgrs // .botmgrs
.chat // .chat
.say_in_reply_to( // .say_in_reply_to(
&params.msg, // &params.msg,
format!("Not a Joined Channel : {}",trgchnl), // format!("Not a Joined Channel : {}",trgchnl),
// parent_module.clone().unwrap().clone() // // parent_module.clone().unwrap().clone()
params.clone(), // params.clone(),
).await; // ).await;
} // }
} // }
/* /*
1. If a Reply , 1. If a Reply ,