summary refs log tree commit diff
path: root/src/system
diff options
context:
space:
mode:
authorAshelyn Rose <git@ashen.earth>2024-10-06 17:28:01 -0600
committerAshelyn Rose <git@ashen.earth>2024-10-06 17:28:01 -0600
commit4d3f5abc20a44efc5c9b53efe3b21d34304dc46a (patch)
treebc62010cd01da102a4f7c5e61ef02b6ff1923350 /src/system
parent4ceb1c233d48bc537a8d2aaad129abbf71d8ff81 (diff)
Allow just prefix to set ap latch without proxying
Diffstat (limited to 'src/system')
-rw-r--r--src/system/message_parser.rs15
-rw-r--r--src/system/mod.rs6
2 files changed, 16 insertions, 5 deletions
diff --git a/src/system/message_parser.rs b/src/system/message_parser.rs
index b044f61..e769eed 100644
--- a/src/system/message_parser.rs
+++ b/src/system/message_parser.rs
@@ -9,6 +9,7 @@ use super::{FullMessage, MemberId, MessageId, Timestamp, UserId};
 
 pub enum ParsedMessage {
     Command(Command),
+    SetProxyAndDelete(MemberId),
     ProxiedMessage {
         member_id: MemberId,
         message_content: String,
@@ -155,11 +156,15 @@ impl MessageParser {
         );
 
         if let Some((member_id, matched_content)) = matches_prefix {
-            Some(ParsedMessage::ProxiedMessage {
-                member_id,
-                message_content: matched_content.to_string(),
-                latch: true,
-            })
+            if matched_content.trim() != "" {
+                Some(ParsedMessage::ProxiedMessage {
+                    member_id,
+                    message_content: matched_content.to_string(),
+                    latch: true,
+                })
+            } else {
+                Some(ParsedMessage::SetProxyAndDelete(member_id))
+            }
         } else {
             None
         }
diff --git a/src/system/mod.rs b/src/system/mod.rs
index 6d81536..8fea1fa 100644
--- a/src/system/mod.rs
+++ b/src/system/mod.rs
@@ -209,6 +209,12 @@ impl Manager {
                 self.latch_state = None;
             },
 
+            message_parser::ParsedMessage::SetProxyAndDelete(member_id) => {
+                let _ = self.bots.get(&member_id).unwrap().delete_message(message.channel_id, message.id).await;
+                self.update_autoproxy_state_after_message(member_id, message.timestamp);
+                self.update_status_of_system();
+            }
+
             message_parser::ParsedMessage::ProxiedMessage { member_id, message_content, latch } => {
                 if let Ok(_) = self.proxy_message(&message, member_id, message_content.as_str()).await {
                     if latch {