BotCommands added are valided at runtime
This commit is contained in:
parent
717f366979
commit
45564cceed
2 changed files with 60 additions and 50 deletions
|
@ -276,70 +276,70 @@ impl ModulesManager
|
||||||
// BotAction::R(r) => None,
|
// BotAction::R(r) => None,
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// if let BotAction::C(incmd) = act {
|
if let BotAction::C(incmd) = act {
|
||||||
|
|
||||||
// // let n = & mgr.botactions;
|
// let n = & mgr.botactions;
|
||||||
|
|
||||||
// let d = &mgr.botactions;
|
let d = &mgr.botactions;
|
||||||
|
|
||||||
// for (module,moduleactions) in d {
|
for (module,moduleactions) in d {
|
||||||
|
|
||||||
|
|
||||||
// for modact in moduleactions.iter() {
|
for modact in moduleactions.iter() {
|
||||||
// if let BotAction::C(dbcmd) = &modact {
|
if let BotAction::C(dbcmd) = &modact {
|
||||||
// // At this point, there is an command incmd and looked up dbcmd
|
// At this point, there is an command incmd and looked up dbcmd
|
||||||
|
|
||||||
// // [x] check if given botcommand c.command:String conflicts with any in botactions
|
// [x] check if given botcommand c.command:String conflicts with any in botactions
|
||||||
|
|
||||||
// if incmd.command.to_lowercase() == dbcmd.command.to_lowercase() {
|
if incmd.command.to_lowercase() == dbcmd.command.to_lowercase() {
|
||||||
// // Returning State - with the identified module
|
// Returning State - with the identified module
|
||||||
// // return Some((module.clone(),BotAction::C(*dbcmd.clone())));
|
// return Some((module.clone(),BotAction::C(*dbcmd.clone())));
|
||||||
// // return Some(incmd); // for some reason I keep getting issues
|
// return Some(incmd); // for some reason I keep getting issues
|
||||||
// //return Some(BotModule(String::from("GambaCore"))); // works
|
//return Some(BotModule(String::from("GambaCore"))); // works
|
||||||
// return Some(module.clone()); // works
|
return Some(module.clone()); // works
|
||||||
// // return Some(dbcmd.clone());
|
// return Some(dbcmd.clone());
|
||||||
// }
|
}
|
||||||
|
|
||||||
// for a in &dbcmd.alias {
|
for a in &dbcmd.alias {
|
||||||
// if incmd.command.to_lowercase() == a.to_lowercase() {
|
if incmd.command.to_lowercase() == a.to_lowercase() {
|
||||||
// // Returning State - with the identified module
|
// Returning State - with the identified module
|
||||||
// // return Some((module.clone(),BotAction::C(dbcmd)));
|
// return Some((module.clone(),BotAction::C(dbcmd)));
|
||||||
// return Some(module.clone()); // works
|
return Some(module.clone()); // works
|
||||||
|
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
|
|
||||||
|
|
||||||
// // [x] Then do the same check except for each c.alias
|
// [x] Then do the same check except for each c.alias
|
||||||
|
|
||||||
// for inalias in &incmd.alias {
|
for inalias in &incmd.alias {
|
||||||
|
|
||||||
// if inalias.to_lowercase() == dbcmd.command.to_lowercase() {
|
if inalias.to_lowercase() == dbcmd.command.to_lowercase() {
|
||||||
// // Returning State - with the identified module
|
// Returning State - with the identified module
|
||||||
// // return Some((module.clone(),BotAction::C(dbcmd)));
|
// return Some((module.clone(),BotAction::C(dbcmd)));
|
||||||
// return Some(module.clone()); // works
|
return Some(module.clone()); // works
|
||||||
|
|
||||||
// }
|
}
|
||||||
|
|
||||||
// for a in &dbcmd.alias {
|
for a in &dbcmd.alias {
|
||||||
// if inalias.to_lowercase() == a.to_lowercase() {
|
if inalias.to_lowercase() == a.to_lowercase() {
|
||||||
// // Returning State - with the identified module
|
// Returning State - with the identified module
|
||||||
// // return Some((module.clone(),BotAction::C(dbcmd)));
|
// return Some((module.clone(),BotAction::C(dbcmd)));
|
||||||
// return Some(module.clone()); // works
|
return Some(module.clone()); // works
|
||||||
|
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
|
|
||||||
// }
|
}
|
||||||
|
|
||||||
|
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
|
|
||||||
// }
|
}
|
||||||
|
|
||||||
// // return Some(BotModule(String::from("GambaCore")))
|
// return Some(BotModule(String::from("GambaCore")))
|
||||||
// }
|
}
|
||||||
|
|
||||||
|
|
||||||
// for all other scenarios (e.g., Listener, Routine), find no conflicts
|
// for all other scenarios (e.g., Listener, Routine), find no conflicts
|
||||||
|
|
|
@ -26,13 +26,23 @@ pub fn init(mgr:&mut ModulesManager)
|
||||||
|
|
||||||
BotCommand {
|
BotCommand {
|
||||||
module : BotModule(String::from("experiments 004")),
|
module : BotModule(String::from("experiments 004")),
|
||||||
command : String::from("test"), // command call name
|
command : String::from("test1"), // command call name
|
||||||
alias : vec![String::from("tester"),String::from("testy")], // String of alternative names
|
alias : vec![String::from("tester1"),String::from("testy1")], // String of alternative names
|
||||||
exec_body : actions_util::asyncbox(testy) ,
|
exec_body : actions_util::asyncbox(testy) ,
|
||||||
help : String::from("DUPCMD4 tester"),
|
help : String::from("DUPCMD4 tester"),
|
||||||
}.add_to_modmgr(mgr);
|
}.add_to_modmgr(mgr);
|
||||||
|
|
||||||
|
|
||||||
|
BotCommand {
|
||||||
|
module : BotModule(String::from("experiments 004")),
|
||||||
|
command : String::from("test2"), // command call name
|
||||||
|
alias : vec![String::from("tester2"),String::from("testy2")], // String of alternative names
|
||||||
|
exec_body : actions_util::asyncbox(testy) ,
|
||||||
|
help : String::from("DUPCMD4 tester"),
|
||||||
|
}.add_to_modmgr(mgr);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
let list1 = Listener {
|
let list1 = Listener {
|
||||||
module : BotModule(String::from("experiments 004")),
|
module : BotModule(String::from("experiments 004")),
|
||||||
name : String::from("GoodGirl Listener"),
|
name : String::from("GoodGirl Listener"),
|
||||||
|
|
Loading…
Reference in a new issue