diff options
Diffstat (limited to 'src/system/plugin/prefixes.rs')
-rw-r--r-- | src/system/plugin/prefixes.rs | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/src/system/plugin/prefixes.rs b/src/system/plugin/prefixes.rs new file mode 100644 index 0000000..a513573 --- /dev/null +++ b/src/system/plugin/prefixes.rs @@ -0,0 +1,40 @@ +use async_trait::async_trait; +use twilight_model::id::{marker::ChannelMarker, Id}; +use crate::system::types::Response; + +use super::{CommandOutcome, SeancePlugin}; + +pub struct ProxyPrefixes; + +#[async_trait] +impl SeancePlugin for ProxyPrefixes { + async fn handle_command(&self, _system: &crate::system::types::System, _message: &twilight_model::channel::Message) -> CommandOutcome { + CommandOutcome::Skipped + } + + async fn handle_message(&self, system: &crate::system::types::System, message: &twilight_model::channel::Message, response: &mut crate::system::types::Response) { + if let Response::Noop { delete_source: _ } = response { + for member in &system.members { + println!("Checking member prefix: {:?}", member.message_pattern); + match member.message_pattern.captures(message.content.as_str()) { + None => { + println!("Nope"); + continue; + }, + Some(captures) => match captures.name("content") { + None => continue, + Some(matched_content) => { + println!("Matched member prefix: {:?}", member.message_pattern); + *response = Response::Proxy { member: member.clone(), content: matched_content.as_str().to_string() }; + return + }, + } + } + } + } + } + + async fn post_response(&self, _system: &crate::system::types::System, _message: &twilight_model::channel::Message, _channel: Id<ChannelMarker>, _response: &crate::system::types::Response) { + return + } +} |