From f2a579f8e76df09a5ccb56156fd232e54f05529d Mon Sep 17 00:00:00 2001 From: Ashelyn Rose Date: Tue, 9 Jul 2024 18:52:55 -0600 Subject: unproxy escape --- src/listener.rs | 1 + src/system.rs | 21 ++++++++++++++++++--- 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(¤t_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 { -- cgit 1.4.1