summary refs log tree commit diff
diff options
context:
space:
mode:
authorAshelyn Rose <git@ashen.earth>2024-07-09 18:52:55 -0600
committerAshelyn Rose <git@ashen.earth>2024-07-09 18:52:55 -0600
commitf2a579f8e76df09a5ccb56156fd232e54f05529d (patch)
tree24d5ecd35d49d71dd9f72faa41ab7e8fc9070f22
parent8903b0afca8a7e1b18b33c92f41051bd5ceb9b3d (diff)
unproxy escape
-rw-r--r--src/listener.rs1
-rw-r--r--src/system.rs21
2 files changed, 19 insertions, 3 deletions
diff --git a/src/listener.rs b/src/listener.rs
index bc9868d..ca69466 100644
--- a/src/listener.rs
+++ b/src/listener.rs
@@ -80,6 +80,7 @@ impl Listener {
                 },
                 Err(source) => {
                     if !source.is_fatal() {
+                        println!("Warn: Client encountered an error: {}", source.to_string());
                         continue;
                     }
 
diff --git a/src/system.rs b/src/system.rs
index cf59f0d..e3882ad 100644
--- a/src/system.rs
+++ b/src/system.rs
@@ -81,9 +81,25 @@ impl System {
     }
 
     async fn handle_message(&mut self, message: Message, timestamp: Timestamp) {
-        // Check for command
         // TODO: Commands
-        // TODO: Escaping
+
+        // Escape sequence
+        if message.content.starts_with(r"\") {
+            if message.content == r"\\" {
+                let client = if let Some((current_member, _)) = self.latch_state.clone() {
+                    self.clients.get(&current_member.name).expect(format!("No client for member {}", current_member.name).as_str())
+                } else {
+                    self.clients.iter().next().expect("No clients!").1
+                };
+
+                client.delete_message(message.channel_id, message.id).await.expect("Could not delete message");
+                self.latch_state = None
+            } else if message.content.starts_with(r"\\") {
+                self.latch_state = None;
+            }
+
+            return
+        }
 
         // TODO: Non-latching prefixes maybe?
         
@@ -95,7 +111,6 @@ impl System {
             return
         }
 
-
         // Check for autoproxy
         if let Some(autoproxy_config) = &self.config.autoproxy {
             match autoproxy_config {