story-kit: merge 285_story_matrix_bot_help_command_lists_available_bot_commands

This commit is contained in:
Dave
2026-03-18 14:53:47 +00:00
parent 727da0c6d0
commit e7bb8db7c1
3 changed files with 336 additions and 0 deletions

View File

@@ -831,6 +831,23 @@ async fn on_room_message(
let user_message = body;
slog!("[matrix-bot] Message from {sender}: {user_message}");
// Check for bot-level commands (e.g. "help") before invoking the LLM.
if let Some(response) = super::commands::try_handle_command(
&ctx.bot_name,
ctx.bot_user_id.as_str(),
&user_message,
) {
slog!("[matrix-bot] Handled bot command from {sender}");
let html = markdown_to_html(&response);
if let Ok(resp) = room
.send(RoomMessageEventContent::text_html(response, html))
.await
{
ctx.bot_sent_event_ids.lock().await.insert(resp.event_id);
}
return;
}
// Spawn a separate task so the Matrix sync loop is not blocked while we
// wait for the LLM response (which can take several seconds).
tokio::spawn(async move {