Crates.io | bot-handler-manager |
lib.rs | bot-handler-manager |
version | 0.1.3 |
source | src |
created_at | 2021-08-13 08:45:14.720259 |
updated_at | 2021-08-15 16:28:23.020307 |
description | A really small chatbot 'if and else module' |
homepage | |
repository | https://github.com/dhairy-online/bot-handler-module |
max_upload_size | |
id | 435610 |
size | 4,986 |
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(" ")
}
}));
}
}
Feel free to open issues and contribute!
breadA#3012
Thanks! :smiley: