module disable by default
This commit is contained in:
parent
739f7aeeef
commit
802fd714c2
2 changed files with 21 additions and 4 deletions
src/botcore
|
@ -249,9 +249,15 @@ impl Bot
|
||||||
}
|
}
|
||||||
|
|
||||||
/// loads a `Module` and its bot objects
|
/// loads a `Module` and its bot objects
|
||||||
pub fn load_module(&mut self,m: Module) {
|
pub async fn load_module(&mut self,m: Module) {
|
||||||
|
if m.get_status_by_default() == Status::Disabled {
|
||||||
|
for chnl in &self.botchannels {
|
||||||
|
self.disable_module(chnl.clone(),
|
||||||
|
m.get_names().first().unwrap().clone()).await
|
||||||
|
}
|
||||||
|
}
|
||||||
self.modules.push(m)
|
self.modules.push(m)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn get_channel_module_status(&self,channel:String,module:String) -> Status {
|
pub async fn get_channel_module_status(&self,channel:String,module:String) -> Status {
|
||||||
let found_disabled:bool = {
|
let found_disabled:bool = {
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
use crate::{Command, Listener};
|
use crate::{Command, Listener};
|
||||||
|
|
||||||
#[derive(PartialEq, Eq,Debug)]
|
#[derive(PartialEq, Eq,Debug,Clone)]
|
||||||
pub enum Status {
|
pub enum Status {
|
||||||
Disabled,
|
Disabled,
|
||||||
Enabled
|
Enabled
|
||||||
|
@ -19,6 +19,8 @@ pub struct Module
|
||||||
bot_read_description : String,
|
bot_read_description : String,
|
||||||
listeners: Vec<Listener>,
|
listeners: Vec<Listener>,
|
||||||
commands: Vec<Command>,
|
commands: Vec<Command>,
|
||||||
|
// disable module at load for bot channels
|
||||||
|
default_status_per_channel: Status,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Module
|
impl Module
|
||||||
|
@ -30,7 +32,8 @@ impl Module
|
||||||
// _alias: alias,
|
// _alias: alias,
|
||||||
bot_read_description,
|
bot_read_description,
|
||||||
listeners: vec![],
|
listeners: vec![],
|
||||||
commands: vec![]
|
commands: vec![],
|
||||||
|
default_status_per_channel: Status::Disabled,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,5 +63,13 @@ impl Module
|
||||||
self.bot_read_description.clone()
|
self.bot_read_description.clone()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn set_status_by_default(&mut self,status:Status){
|
||||||
|
self.default_status_per_channel = status;
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn get_status_by_default(&self) -> Status {
|
||||||
|
self.default_status_per_channel.clone()
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
Loading…
Add table
Add a link
Reference in a new issue