2022-06-04 18:10:21 +00:00
|
|
|
use async_trait::async_trait;
|
2022-06-04 19:34:53 +00:00
|
|
|
use servers::{
|
2022-06-05 14:08:13 +00:00
|
|
|
plugins::{Command, CommandManagerType, CommandRegistrar, Plugin, PluginRegistrar},
|
|
|
|
tcp::Client,
|
2022-06-04 19:34:53 +00:00
|
|
|
};
|
2022-06-04 18:10:21 +00:00
|
|
|
|
|
|
|
struct PluginTest;
|
|
|
|
|
|
|
|
#[async_trait]
|
|
|
|
impl Plugin for PluginTest {
|
|
|
|
fn name(&self) -> &'static str {
|
|
|
|
"test"
|
|
|
|
}
|
|
|
|
|
|
|
|
async fn on_plugin_load(&self) {}
|
|
|
|
|
|
|
|
async fn on_plugin_unload(&self) {}
|
|
|
|
}
|
|
|
|
|
|
|
|
#[async_trait]
|
|
|
|
impl Command for PluginTest {
|
|
|
|
fn name(&self) -> &'static str {
|
|
|
|
"/test"
|
|
|
|
}
|
|
|
|
|
|
|
|
fn help(&self) -> &'static str {
|
|
|
|
"test command"
|
|
|
|
}
|
|
|
|
|
|
|
|
async fn execute(&self, client: &mut Client, _args: Vec<&str>, _commands: &CommandManagerType) {
|
2022-06-05 21:13:14 +00:00
|
|
|
client.send("content").expect("send message")
|
2022-06-04 18:10:21 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#[no_mangle]
|
|
|
|
pub fn plugin_entry(registrar: &mut dyn PluginRegistrar, command: &mut dyn CommandRegistrar) {
|
|
|
|
registrar.register_plugin(Box::new(PluginTest));
|
2022-06-05 20:10:23 +00:00
|
|
|
command.register_command(Box::new(PluginTest));
|
2022-06-04 18:10:21 +00:00
|
|
|
}
|