summary refs log tree commit diff
path: root/src/system/plugin/prefixes.rs
diff options
context:
space:
mode:
authorAshelyn Rose <git@ashen.earth>2025-02-28 21:52:16 -0700
committerAshelyn Rose <git@ashen.earth>2025-02-28 21:52:16 -0700
commite9253bd959bf5bf6e8bcc6de4db247895b015a16 (patch)
tree1817aed80c8255d1292007a81e7f0a16138d25cc /src/system/plugin/prefixes.rs
parent5cb49a76c2cedb500b82f405af3cf1dcc0507f98 (diff)
Partial refactor
Handles message prefixes and autoproxy
Diffstat (limited to 'src/system/plugin/prefixes.rs')
-rw-r--r--src/system/plugin/prefixes.rs40
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
+    }
+}