BotCommands added are valided at runtime
This commit is contained in:
parent
3f6e3710ef
commit
520c6b6fc8
2 changed files with 60 additions and 50 deletions
|
@ -276,70 +276,70 @@ impl ModulesManager
|
|||
// 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() {
|
||||
// if let BotAction::C(dbcmd) = &modact {
|
||||
// // At this point, there is an command incmd and looked up dbcmd
|
||||
for modact in moduleactions.iter() {
|
||||
if let BotAction::C(dbcmd) = &modact {
|
||||
// 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() {
|
||||
// // Returning State - with the identified module
|
||||
// // return Some((module.clone(),BotAction::C(*dbcmd.clone())));
|
||||
// // return Some(incmd); // for some reason I keep getting issues
|
||||
// //return Some(BotModule(String::from("GambaCore"))); // works
|
||||
// return Some(module.clone()); // works
|
||||
// // return Some(dbcmd.clone());
|
||||
// }
|
||||
if incmd.command.to_lowercase() == dbcmd.command.to_lowercase() {
|
||||
// Returning State - with the identified module
|
||||
// return Some((module.clone(),BotAction::C(*dbcmd.clone())));
|
||||
// return Some(incmd); // for some reason I keep getting issues
|
||||
//return Some(BotModule(String::from("GambaCore"))); // works
|
||||
return Some(module.clone()); // works
|
||||
// return Some(dbcmd.clone());
|
||||
}
|
||||
|
||||
// for a in &dbcmd.alias {
|
||||
// if incmd.command.to_lowercase() == a.to_lowercase() {
|
||||
// // Returning State - with the identified module
|
||||
// // return Some((module.clone(),BotAction::C(dbcmd)));
|
||||
// return Some(module.clone()); // works
|
||||
for a in &dbcmd.alias {
|
||||
if incmd.command.to_lowercase() == a.to_lowercase() {
|
||||
// Returning State - with the identified module
|
||||
// return Some((module.clone(),BotAction::C(dbcmd)));
|
||||
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() {
|
||||
// // Returning State - with the identified module
|
||||
// // return Some((module.clone(),BotAction::C(dbcmd)));
|
||||
// return Some(module.clone()); // works
|
||||
if inalias.to_lowercase() == dbcmd.command.to_lowercase() {
|
||||
// Returning State - with the identified module
|
||||
// return Some((module.clone(),BotAction::C(dbcmd)));
|
||||
return Some(module.clone()); // works
|
||||
|
||||
// }
|
||||
}
|
||||
|
||||
// for a in &dbcmd.alias {
|
||||
// if inalias.to_lowercase() == a.to_lowercase() {
|
||||
// // Returning State - with the identified module
|
||||
// // return Some((module.clone(),BotAction::C(dbcmd)));
|
||||
// return Some(module.clone()); // works
|
||||
for a in &dbcmd.alias {
|
||||
if inalias.to_lowercase() == a.to_lowercase() {
|
||||
// Returning State - with the identified module
|
||||
// return Some((module.clone(),BotAction::C(dbcmd)));
|
||||
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
|
||||
|
|
|
@ -24,13 +24,23 @@ pub fn init(mgr:&mut ModulesManager)
|
|||
{
|
||||
|
||||
|
||||
BotCommand {
|
||||
module : BotModule(String::from("experiments 004")),
|
||||
command : String::from("test"), // command call name
|
||||
alias : vec![String::from("tester"),String::from("testy")], // String of alternative names
|
||||
exec_body : actions_util::asyncbox(testy) ,
|
||||
help : String::from("DUPCMD4 tester"),
|
||||
}.add_to_modmgr(mgr);
|
||||
BotCommand {
|
||||
module : BotModule(String::from("experiments 004")),
|
||||
command : String::from("test1"), // command call name
|
||||
alias : vec![String::from("tester1"),String::from("testy1")], // String of alternative names
|
||||
exec_body : actions_util::asyncbox(testy) ,
|
||||
help : String::from("DUPCMD4 tester"),
|
||||
}.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 {
|
||||
|
|
Loading…
Reference in a new issue