story-kit: merge 285_story_matrix_bot_help_command_lists_available_bot_commands
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user