improvement: more forgiving admin command syntax

This commit is contained in:
Timo Kösters 2023-08-10 17:26:55 +02:00
parent fd9e52a559
commit 606b25b9e7
No known key found for this signature in database
GPG key ID: 0B25E636FBA7E4CB
2 changed files with 4 additions and 2 deletions

View file

@ -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();

View file

@ -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