Enh Botcommand with add to modmgr
This commit is contained in:
parent
68f08a6e78
commit
a577f502a2
2 changed files with 40 additions and 2 deletions
|
@ -61,7 +61,7 @@ pub struct BotInstance {
|
||||||
pub incoming_messages : UnboundedReceiver<ServerMessage>,
|
pub incoming_messages : UnboundedReceiver<ServerMessage>,
|
||||||
pub ratelimiters : HashMap<ChType,RateLimiter>, // used to limit messages sent per channel
|
pub ratelimiters : HashMap<ChType,RateLimiter>, // used to limit messages sent per channel
|
||||||
// botmodules : HashMap<ModType,Vec<EnType>>,
|
// botmodules : HashMap<ModType,Vec<EnType>>,
|
||||||
botmodules : ModulesManager,
|
pub botmodules : ModulesManager,
|
||||||
twitch_oauth : String,
|
twitch_oauth : String,
|
||||||
pub bot_channels : Vec<ChType>,
|
pub bot_channels : Vec<ChType>,
|
||||||
/*bot_commands : Vec[BotCommand],
|
/*bot_commands : Vec[BotCommand],
|
||||||
|
|
|
@ -63,6 +63,34 @@ struct BotCommand {
|
||||||
help : String,
|
help : String,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl BotCommand {
|
||||||
|
pub fn add_to_bot(self, bot:BotInstance) {
|
||||||
|
// let mut mgr = bot.botmodules;
|
||||||
|
// let nmod = self.module.clone();
|
||||||
|
// mgr.add_botaction(nmod, BotAction::C(self));
|
||||||
|
let mut mgr = bot.botmodules;
|
||||||
|
//let nmod = self.module.clone();
|
||||||
|
// mgr.add_botaction(self.module.clone(), BotAction::C(self));
|
||||||
|
|
||||||
|
self.add_to_modmgr(&mut mgr);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
pub fn add_to_modmgr(self, modmgr:&mut ModulesManager) {
|
||||||
|
// // let mut mgr = bot.botmodules;
|
||||||
|
// // let nmod = self.module.clone();
|
||||||
|
// // mgr.add_botaction(nmod, BotAction::C(self));
|
||||||
|
// let mut mgr = modmgr;
|
||||||
|
// //let nmod = self.module.clone();
|
||||||
|
// mgr.add_botaction(self.module.clone(), BotAction::C(self));
|
||||||
|
// let mut mgr = modmgr;
|
||||||
|
// //let nmod = self.module.clone();
|
||||||
|
modmgr.add_botaction(self.module.clone(), BotAction::C(self));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
struct Listener {
|
struct Listener {
|
||||||
module : ModType,
|
module : ModType,
|
||||||
|
@ -150,6 +178,16 @@ impl ModulesManager {
|
||||||
// mgr.add_botaction(BotModule(String::from("experiments 002")), BotAction::C(bcmd));
|
// mgr.add_botaction(BotModule(String::from("experiments 002")), BotAction::C(bcmd));
|
||||||
|
|
||||||
|
|
||||||
|
BotCommand {
|
||||||
|
module : BotModule(String::from("experiments 002")),
|
||||||
|
command : String::from("DUPCMD2"), // command call name
|
||||||
|
alias : vec![String::from("DUPALIAS2A"),String::from("DUPALIAS2B")], // String of alternative names
|
||||||
|
// bot_prefix : char, // although should be global?
|
||||||
|
// exec_body : fn,
|
||||||
|
help : String::from("DUPCMD2 tester"),
|
||||||
|
}.add_to_modmgr(&mut mgr);
|
||||||
|
|
||||||
|
|
||||||
println!(">> Modules Manager : {:?}",mgr);
|
println!(">> Modules Manager : {:?}",mgr);
|
||||||
|
|
||||||
mgr
|
mgr
|
||||||
|
|
Loading…
Reference in a new issue