ModulesManager #37

Merged
modulatingforce merged 22 commits from modulesmanager into main 2024-03-22 21:34:08 -04:00
Showing only changes of commit 2c298663b1 - Show all commits

View file

@ -19,7 +19,7 @@ use crate::core::ratelimiter::RateLimiter;
use crate::core::bot_actions::actions_util::BotAR;
use crate::core::botmodules::ModulesManager;
use crate::core::identity::{IdentityManager, Permissible};
use crate::core::identity::{IdentityManager, Permissible,self};
use crate::core::botlog;
use crate::core::chat::Chat;
@ -295,7 +295,7 @@ impl BotInstance {
let botlock = bot.read().await;
let id = botlock.get_identity();
// [ ] Check first if the Module for that Given Command is Enabled or Disabled on the given Channel
// [x] Check first if the Module for that Given Command is Enabled or Disabled on the given Channel
let modmgr = Arc::clone(&botlock.botmodules);
let modstatus = modmgr.modstatus(
c.module.clone(),
@ -303,15 +303,40 @@ impl BotInstance {
if let StatusType::Disabled(a) = modstatus {
let botlock = bot.read().await;
let outstr =
format!("sadg Module is disabled : {:?}",a);
botlock.botmgrs.chat.say_in_reply_to(msg, outstr).await;
// [x] Should only respond if a BotAdmin , Mod , SupMod , BroadCaster
// - Specifically it should respond only to those who may be able to enable the module
const OF_CMD_CHANNEL:ChType = 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);
botlock.botmgrs.chat.say_in_reply_to(msg, outstr).await;
}
return;
};
let eval = {
let mut idlock = id.write().await;
let (permissability, chngrslt) = idlock
@ -350,7 +375,7 @@ impl BotInstance {
match eval {
Permissible::Allow => {
botlog::debug(
"Executed as permissible",
"Executing as permissible",
Some("BotInstance > listener_main_prvmsg()".to_string()),
Some(msg),
);