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

View file

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