smol
This commit is contained in:
parent
35db264b9e
commit
246c3d98e6
4 changed files with 136 additions and 78 deletions
|
@ -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());
|
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 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
|
// self.say_in_reply_to(
|
||||||
};
|
// ¶ms.msg,
|
||||||
|
// format!("uuh You do not have the right roles to send to {}",
|
||||||
if let Permissible::Allow = elevated_access {
|
// channel_login.clone(),
|
||||||
let botlock = bot.read().await;
|
// ),
|
||||||
|
// params.clone()
|
||||||
|
// ).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,8 +440,54 @@ 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;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -82,6 +82,7 @@ impl Chat {
|
||||||
Some("chat.rs > send_botmsg ".to_string()),
|
Some("chat.rs > send_botmsg ".to_string()),
|
||||||
Some(¶ms.msg),
|
Some(¶ms.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(
|
||||||
|
// ¶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(
|
self.say_in_reply_to(
|
||||||
¶ms.msg,
|
a,
|
||||||
"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;
|
||||||
|
|
||||||
|
}
|
||||||
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",
|
||||||
|
@ -270,6 +259,9 @@ impl Chat {
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
||||||
Use
|
Use
|
||||||
|
@ -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(¶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
|
// [ ] 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(
|
||||||
¶ms.msg,
|
// ¶ms.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;
|
||||||
|
|
||||||
|
|
|
@ -142,7 +142,7 @@ pub async fn init(mgr: Arc<ModulesManager>) {
|
||||||
Some(¶ms.msg),
|
Some(¶ms.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(
|
||||||
|
|
|
@ -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(
|
||||||
¶ms.msg,
|
// ¶ms.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 ,
|
||||||
|
|
Loading…
Reference in a new issue