storkit: merge 458_story_matrix_bot_ignores_messages_addressed_to_other_bots_in_ambient_mode
This commit is contained in:
@@ -19,7 +19,7 @@ use tokio::sync::watch;
|
||||
use super::context::BotContext;
|
||||
use super::format::markdown_to_html;
|
||||
use super::history::{ConversationEntry, ConversationRole, save_history};
|
||||
use super::mentions::{is_reply_to_bot, mentions_bot};
|
||||
use super::mentions::{is_addressed_to_other, is_reply_to_bot, mentions_bot};
|
||||
use super::verification::check_sender_verified;
|
||||
|
||||
/// Build the user-facing prompt for a single turn. In multi-user rooms the
|
||||
@@ -93,6 +93,19 @@ pub(super) async fn on_room_message(
|
||||
return;
|
||||
}
|
||||
|
||||
// In ambient mode, ignore messages that are explicitly addressed to a
|
||||
// different entity (e.g. "sally: do X" or "@sally do X" when we are stu).
|
||||
// We still let through messages addressed to us and the "ambient on" command.
|
||||
if is_ambient && !is_addressed && !is_ambient_on
|
||||
&& is_addressed_to_other(&body, &ctx.bot_user_id, &ctx.bot_name)
|
||||
{
|
||||
slog!(
|
||||
"[matrix-bot] Ignoring ambient message addressed to another bot (sender={})",
|
||||
ev.sender
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
// Reject commands from unencrypted rooms — E2EE is mandatory.
|
||||
if !room.encryption_state().is_encrypted() {
|
||||
slog!(
|
||||
|
||||
Reference in New Issue
Block a user