mod autoproxy; // mod edit; // mod ghost; mod prefixes; // mod reproxy; use std::{collections::HashMap, sync::Arc}; use async_trait::async_trait; use twilight_model::{channel::{Channel, Message}, id::{marker::ChannelMarker, Id}}; use super::log::Logger; use crate::system::types::{System, Response}; pub use prefixes::ProxyPrefixes; pub use autoproxy::Autoproxy; #[async_trait] pub trait SeancePlugin<'system> { fn get_commands(&self) -> Vec<&'static str>; async fn handle_command<'message>(&self, logger: &'system Logger, system: &'system System, message: &'message Message, args: Vec<&'message str>); async fn handle_message<'message>(&self, logger: &'system Logger, system: &'system System, message: &'message Message, response: &'message mut Response); async fn post_response<'message>(&self, logger: &'system Logger, system: &'system System, message: &'message Message, channel: Id, response: &'message Response); } pub fn get_plugins<'system>() -> (Vec>>>, HashMap<&'static str, Arc>>>) { let all_plugins : Vec>>> = vec![ Arc::new(Box::new(ProxyPrefixes)), Arc::new(Box::new(Autoproxy::new())), ]; let by_commands = all_plugins.iter() .map(|plugin| { let commands = plugin.get_commands(); commands.into_iter().map(|command| { (command, plugin.clone()) }) }) .flatten() .collect(); (all_plugins, by_commands) }