Add this to your cargo.toml file:
bot-handler-manager = "0.1.3"
// Use the crate
use bot_handler_manager;
fn main() {
// Make a prefix
let mut commander = bot_handler_manager::Commander::new("~> ");
// Listen for messages/commands
commander.on("Hello!", |_| {"Hello there!"}.to_string());
// loop the readline()
loop {
// read
commander.read(Some(|input: &str| {
// if the user types a message/command, and it contains in the vector,
// the user can type in MIX-CASE.
// example: "HeLLO, RuST!"
let my_user_input = vec!["hello, rust!", "hello, world!", "hello, bot!", "hi!"];
if my_user_input.contains(&input) {
String::from("Hello, I'm Alive!")
} else {
String::from(" ")
}
}));
}
}
breadA#3012
- MIT
Thanks! 😃