ModulesManager #37
3 changed files with 62 additions and 17 deletions
|
@ -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),
|
||||
|
|
|
@ -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<dyn Error>> {
|
||||
// // 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<dyn Error>> {
|
||||
// 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;
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in a new issue