From 606b25b9e73b467f44912bf10d2d4c299e9dbd2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timo=20K=C3=B6sters?= Date: Thu, 10 Aug 2023 17:26:55 +0200 Subject: improvement: more forgiving admin command syntax --- src/service/admin/mod.rs | 2 +- src/service/rooms/timeline/mod.rs | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/service/admin/mod.rs b/src/service/admin/mod.rs index 6c3e3d0..0fe5edf 100644 --- a/src/service/admin/mod.rs +++ b/src/service/admin/mod.rs @@ -287,7 +287,7 @@ impl Service { // Parse and process a message from the admin room async fn process_admin_message(&self, room_message: String) -> RoomMessageEventContent { - let mut lines = room_message.lines(); + let mut lines = room_message.lines().filter(|l| !l.trim().is_empty()); let command_line = lines.next().expect("each string has at least one line"); let body: Vec<_> = lines.collect(); diff --git a/src/service/rooms/timeline/mod.rs b/src/service/rooms/timeline/mod.rs index 83c3010..25e1c54 100644 --- a/src/service/rooms/timeline/mod.rs +++ b/src/service/rooms/timeline/mod.rs @@ -456,7 +456,9 @@ impl Service { let server_user = format!("@conduit:{}", services().globals.server_name()); let to_conduit = body.starts_with(&format!("{server_user}: ")) - || body.starts_with(&format!("{server_user} ")); + || body.starts_with(&format!("{server_user} ")) + || body == format!("{server_user}:") + || body == format!("{server_user}"); // This will evaluate to false if the emergency password is set up so that // the administrator can execute commands as conduit -- cgit v1.2.3