diff options
author | Ashelyn Rose <git@ashen.earth> | 2024-10-06 17:53:31 -0600 |
---|---|---|
committer | Ashelyn Rose <git@ashen.earth> | 2024-10-06 17:53:31 -0600 |
commit | 27d7107a127f3ff513b6281d94e22ce6ff781115 (patch) | |
tree | ea9d489b66b81caf097f47d3e01b148e27647f1f /src/system/message_parser.rs | |
parent | 4d3f5abc20a44efc5c9b53efe3b21d34304dc46a (diff) |
Reproxy
Diffstat (limited to 'src/system/message_parser.rs')
-rw-r--r-- | src/system/message_parser.rs | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/system/message_parser.rs b/src/system/message_parser.rs index e769eed..5d14095 100644 --- a/src/system/message_parser.rs +++ b/src/system/message_parser.rs @@ -65,7 +65,7 @@ impl MessageParser { } } - if let Some(parse) = MessageParser::check_member_patterns(message, system_config) { + if let Some(parse) = MessageParser::check_member_patterns(message, secondary_message, system_config) { return parse } @@ -150,13 +150,15 @@ impl MessageParser { None } - fn check_member_patterns(message: &FullMessage, system_config: &System) -> Option<ParsedMessage> { + fn check_member_patterns(message: &FullMessage, secondary_message: Option<&FullMessage>, system_config: &System) -> Option<ParsedMessage> { let matches_prefix = system_config.members.iter().enumerate().find_map(|(member_id, member)| Some((member_id, member.matches_proxy_prefix(&message)?)) ); if let Some((member_id, matched_content)) = matches_prefix { - if matched_content.trim() != "" { + if matched_content.trim() == "*" { + Some(ParsedMessage::Command(Command::Reproxy(member_id, secondary_message.unwrap().id))) + } else if matched_content.trim() != "" { Some(ParsedMessage::ProxiedMessage { member_id, message_content: matched_content.to_string(), @@ -192,7 +194,7 @@ impl MessageParser { None } - fn get_member_id_from_user_id(user_id: UserId, system_config: &System) -> Option<MemberId> { + pub fn get_member_id_from_user_id(user_id: UserId, system_config: &System) -> Option<MemberId> { system_config.members.iter().enumerate() .filter(|(_id, m)| m.user_id.is_some()) .find(|(_id, m)| m.user_id.unwrap() == user_id) |