use std::future::Future;
use std::pin::Pin;
use super::backend_context::BackendContext;
pub trait Command: Send + Sync {
fn name(&self) -> &'static str;
fn aliases(&self) -> &[&'static str] {
&[]
}
fn help(&self) -> Option<&'static str> {
None
}
fn matches(&self, msg: &str) -> bool {
let name = self.name();
if msg == format!("/{}", name) || msg.starts_with(&format!("/{} ", name)) {
return true;
}
for alias in self.aliases() {
if msg == format!("/{}", alias) || msg.starts_with(&format!("/{} ", alias)) {
return true;
}
}
false
}
fn execute<'a>(
&'a self,
ctx: &'a mut BackendContext<'_>,
) -> Pin<Box<dyn Future<Output = bool> + Send + 'a>>;
}