use async_trait::async_trait; use twilight_model::id::{marker::ChannelMarker, Id}; use twilight_model::channel::Message; use crate::system::{log::Logger, types::{Response, System}}; use super::{PluginCommand, SeancePlugin}; pub struct ProxyPrefixes; impl ProxyPrefixes { pub fn new() -> Self { Self } } #[async_trait] impl<'system> SeancePlugin<'system> for ProxyPrefixes { fn get_commands(&self) -> Vec { vec![] } async fn handle_command<'message>(&self, _logger: &'system Logger, _system: &'system System, _message: &'message Message, _command: PluginCommand, _args: Vec<&'message str>) { unreachable!("Prefix plugin has no commands") } async fn handle_message<'message>(&self, logger: &'system Logger, system: &'system System, message: &'message Message, response: &'message mut Response) { if let Response::Noop { delete_source: _ } = response { for member in &system.members { match member.message_pattern.captures(message.content.as_str()) { None => continue, Some(captures) => match captures.name("content") { None => continue, Some(matched_content) => { logger.log_line(Some(member.discord_token.clone()), "Matched prefix".to_string()).await; *response = Response::Proxy { member: member.clone(), content: matched_content.as_str().to_string() }; return }, } } } } } async fn post_response<'message>(&self, _logger: &'system Logger, _system: &'system System, _message: &'message Message, _channel: Id, _response: &'message Response) { return } }