use crate::bot::module::{Action, Command, CommandSpec, Module}; pub struct Builtins; const COMMANDS: &[CommandSpec] = &[ CommandSpec { name: "ping", usage: "ping", about: "reply with 'pong'" }, CommandSpec { name: "echo", usage: "echo ", about: "echo the text back" }, CommandSpec { name: "hello", usage: "hello", about: "greet the sender" }, ]; impl Module for Builtins { fn name(&self) -> &'static str { "builtins" } fn commands(&self) -> &'static [CommandSpec] { COMMANDS } fn on_command(&mut self, cmd: &Command) -> Vec { let reply = match cmd.name { "ping" => "pong".to_string(), "echo" => cmd.args.join(" "), "hello" => format!("hello, {}!", cmd.sender), _ => return Vec::new(), }; vec![Action::Reply(reply)] } }