diff options
Diffstat (limited to 'src/system')
-rw-r--r-- | src/system/message_parser.rs | 15 | ||||
-rw-r--r-- | src/system/mod.rs | 6 |
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 { |