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 ratelimiters : HashMap<ChType,RateLimiter>, // used to limit messages sent per channel
|
||||
// botmodules : HashMap<ModType,Vec<EnType>>,
|
||||
botmodules : ModulesManager,
|
||||
pub botmodules : ModulesManager,
|
||||
twitch_oauth : String,
|
||||
pub bot_channels : Vec<ChType>,
|
||||
/*bot_commands : Vec[BotCommand],
|
||||
|
@ -157,7 +157,7 @@ impl BotInstance {
|
|||
println!("(#{}) {}: {}", msg.channel_login, msg.sender.name, msg.message_text);
|
||||
|
||||
println!("Privmsg section");
|
||||
|
||||
|
||||
// b.listener_main_prvmsg(&msg);
|
||||
self.listener_main_prvmsg(&msg).await;
|
||||
|
||||
|
|
|
@ -63,6 +63,34 @@ struct BotCommand {
|
|||
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)]
|
||||
struct Listener {
|
||||
module : ModType,
|
||||
|
@ -150,6 +178,16 @@ impl ModulesManager {
|
|||
// 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);
|
||||
|
||||
mgr
|
||||
|
|
Loading…
Reference in a new issue