Add stuff

This commit is contained in:
Michael Mikovsky
2025-05-21 12:10:42 -06:00
parent 018f0c03d4
commit 69b3ea7afb
11 changed files with 1107 additions and 239 deletions
+27
View File
@@ -0,0 +1,27 @@
use azalea::{Client, Event};
use crate::bot_task::*;
pub trait BotTask: Send {
fn on_event(&mut self, bot: &Client, event: &Event);
fn end(&self) -> bool;
}
pub fn parse_command(command: &str) -> Option<Box<dyn BotTask>> {
let args = command
.split_whitespace()
.map(|s| s.to_string())
.collect::<Vec<String>>();
match args[0].as_str() {
"!chat" => Some(Box::new(Chat::init(args[1..].to_vec()))),
"!goto" => {
if let Some(task) = GotoBlock::parse(args[1..].to_vec()) {
Some(Box::new(task))
} else {
return None;
}
}
_ => None,
}
}