other bots cant run botcommands

This commit is contained in:
ModulatingForce 2024-03-20 19:08:01 -04:00
commit e22e755bf5
4 changed files with 61 additions and 2 deletions
src/core

View file

@ -12,11 +12,40 @@ use crate::core::botinstance::ChType;
use crate::core::botlog;
use crate::core::botmodules::{BotActionTrait, BotCommand, BotModule, ModulesManager};
use dotenv::dotenv;
use std::env;
fn adminvector() -> Vec<String> {
vec![String::from("ModulatingForce")]
//vec![]
}
pub fn otherbots_vector() -> Vec<String> {
// vec![String::from("ModulatingForce")]
// //vec![]
dotenv().ok();
let mut other_bots = Vec::new();
if let Ok(value) = env::var("OtherBots") {
for bot in value.split(',') {
other_bots.push(String::from(bot).to_lowercase())
}
}
botlog::debug(
&format!(
"OtherBots : {:?}",other_bots,
),
Some("identity.rs > otherbots_vector()".to_string()),
None,
);
other_bots
}
pub async fn init(mgr: Arc<ModulesManager>) {
botlog::trace(
"Went into Identity Module init",
@ -780,6 +809,24 @@ impl IdentityManager {
let usr = usr.to_lowercase();
let bot_vector = otherbots_vector() ; // result of pulling from Cargo.toml
botlog::trace(
&format!(
"Checking user is part of known bots: bot_vector.contains(&usr) : {:?}",bot_vector.contains(&usr)
),
Some("identity.rs > can_user_run()".to_string()),
None,
);
if bot_vector.contains(&usr) {
return (
Permissible::Block,
ChangeResult::NoChange("Other Bots Cannot Run Commands".to_string()),
);
}
// if cmdreqroles.len() == 0 {
if cmdreqroles.is_empty() {
// return Ok(Permissible::Allow)