From 2c298663b1ae519a4503d94196eab3aa2fb29dff Mon Sep 17 00:00:00 2001
From: ModulatingForce <116608425+modulatingforce@users.noreply.github.com>
Date: Fri, 22 Mar 2024 19:07:19 -0400
Subject: [PATCH] rsp only to elevated users

---
 src/core/botinstance.rs | 41 +++++++++++++++++++++++++++++++++--------
 1 file changed, 33 insertions(+), 8 deletions(-)

diff --git a/src/core/botinstance.rs b/src/core/botinstance.rs
index 5e70806..2f1548c 100644
--- a/src/core/botinstance.rs
+++ b/src/core/botinstance.rs
@@ -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),
                                     );