diff --git a/src/core/botinstance.rs b/src/core/botinstance.rs index 144e8ee..2e30421 100644 --- a/src/core/botinstance.rs +++ b/src/core/botinstance.rs @@ -19,12 +19,21 @@ use crate::core::ratelimiter::RateLimiter; use crate::core::bot_actions::actions_util::BotAR; use crate::core::botmodules::ModulesManager; -use crate::core::identity::{ChangeResult, IdentityManager, Permissible}; +use crate::core::identity::{IdentityManager, Permissible}; use crate::core::botlog; use crate::core::chat::Chat; +#[derive(Debug, PartialEq, Eq)] +pub enum ChangeResult { + Success(String), + Failed(String), + NoChange(String), +} + + + #[derive(Debug, PartialEq, Eq, Hash, Clone)] pub enum ChType { Channel(String), diff --git a/src/core/botmodules.rs b/src/core/botmodules.rs index fdbddcf..746c673 100644 --- a/src/core/botmodules.rs +++ b/src/core/botmodules.rs @@ -22,7 +22,7 @@ Example use core::panic; use std::collections::HashMap; -use std::error::Error; +// use std::error::Error; use std::sync::Arc; use twitch_irc::message::PrivmsgMessage; @@ -32,7 +32,7 @@ use tokio::sync::RwLock; use async_trait::async_trait; use self::bot_actions::actions_util::BotAR; -use crate::core::botinstance::{BotInstance, ChType}; +use crate::core::botinstance::{BotInstance, ChType,ChangeResult}; use crate::core::botlog; use crate::core::identity; @@ -40,6 +40,9 @@ use crate::core::bot_actions; pub use ChType::Channel; pub use ModType::BotModule; +// use super::identity::ChangeResult; + + #[derive(Debug, PartialEq, Eq, Hash, Clone)] pub enum ModType { BotModule(String), @@ -237,17 +240,50 @@ impl ModulesManager { StatusType::Enabled(StatusLvl::Instance) } - pub fn togglestatus(&self, _: ModType, _: ChType) -> StatusType { - // enables or disables based on current status - StatusType::Enabled(StatusLvl::Instance) + // pub fn togglestatus(&self, _: ModType, _: ChType) -> StatusType { + // // enables or disables based on current status + // StatusType::Enabled(StatusLvl::Instance) + // } + + // pub fn setstatus(&self, _: ModType, _: StatusType) -> Result<&str, Box> { + // // sets the status based given ModSatusType + // // e.g., b.setstatus(BodModule("GambaCore"), Enabled(Channel("modulatingforce"))).expect("ERROR") + // Ok("") + // } + + pub fn set_instance_disabled(&self, _in_module: ModType) -> (StatusType,ChangeResult) { + // at Instance level + // - If core module, do nothing + (StatusType::Disabled(StatusLvl::Instance),ChangeResult::NoChange("Nothing needed".to_string())) } - pub fn setstatus(&self, _: ModType, _: StatusType) -> Result<&str, Box> { - // sets the status based given ModSatusType - // e.g., b.setstatus(BodModule("GambaCore"), Enabled(Channel("modulatingforce"))).expect("ERROR") - Ok("") + pub fn force_disabled(&self, _in_module: ModType) -> (StatusType,ChangeResult) { + // Disables the module at Instance level, and removes all Enabled/Disabled at Channel level + // - Bot Moderators MUST Re-enable if they were enabled before + // - If core module, do nothing + (StatusType::Disabled(StatusLvl::Instance),ChangeResult::NoChange("Nothing needed".to_string())) } + pub fn set_instance_enabled(&self, _in_module: ModType) -> (StatusType,ChangeResult) { + // at Instance level + // - If core module, do nothing + (StatusType::Enabled(StatusLvl::Instance),ChangeResult::NoChange("Nothing needed".to_string())) + } + + pub fn set_ch_disabled(&self, _in_module: ModType , _in_chnl: ChType) -> (StatusType,ChangeResult) { + // at Instance level + // - If core module, do nothing + (StatusType::Disabled(StatusLvl::Instance),ChangeResult::NoChange("Nothing needed".to_string())) + } + + pub fn set_ch_enabled(&self, _in_module: ModType , _in_chnl: ChType) -> (StatusType,ChangeResult) { + // at Instance level + // - If core module, do nothing + (StatusType::Enabled(StatusLvl::Instance),ChangeResult::NoChange("Nothing needed".to_string())) + } + + + pub async fn add_botaction(&self, in_module: ModType, in_action: BotAction) { self.int_add_botaction(in_module,ModGroup::Custom,in_action).await; } diff --git a/src/core/identity.rs b/src/core/identity.rs index b302a7e..65a5088 100644 --- a/src/core/identity.rs +++ b/src/core/identity.rs @@ -8,7 +8,7 @@ use twitch_irc::message::PrivmsgMessage; use casual_logger::Log; use crate::core::bot_actions::actions_util::{self, BotAR}; -use crate::core::botinstance::ChType; +use crate::core::botinstance::{ChType,ChangeResult}; use crate::core::botlog; use crate::core::botmodules::{BotActionTrait, BotCommand, BotModule, ModulesManager}; @@ -608,12 +608,12 @@ pub enum ChatBadge { Mod, } -#[derive(Debug, PartialEq, Eq)] -pub enum ChangeResult { - Success(String), - Failed(String), - NoChange(String), -} +// #[derive(Debug, PartialEq, Eq)] +// pub enum ChangeResult { +// Success(String), +// Failed(String), +// NoChange(String), +// } impl IdentityManager { pub fn init() -> IdentityManager {