feat(mattermost): add mention_only config for @-mention filtering

Add mention_only support for the Mattermost channel, matching the existing
Discord implementation. When enabled, the bot only processes messages that
contain an @-mention of the bot username, reducing noise in busy channels.

- Add mention_only field to MattermostConfig schema (Option<bool>, default false)
- Rename get_bot_user_id() to get_bot_identity() returning (user_id, username)
- Add contains_bot_mention_mm() with case-insensitive word-boundary matching
  and metadata.mentions array support
- Add normalize_mattermost_content() to strip @-mentions from processed text
- Wire mention_only through channel and cron factory constructors
- Add 23 new tests covering mention detection, stripping, case-insensitivity,
  word boundaries, metadata mentions, empty-after-strip, and disabled passthrough
This commit is contained in:
Vernon Stinebaker 2026-02-18 19:51:45 +08:00 committed by Chummy
parent 65a12dd611
commit d97866a640
4 changed files with 468 additions and 38 deletions

View file

@ -306,6 +306,7 @@ async fn deliver_if_configured(config: &Config, job: &CronJob, output: &str) ->
mm.channel_id.clone(),
mm.allowed_users.clone(),
mm.thread_replies.unwrap_or(true),
mm.mention_only.unwrap_or(false),
);
channel.send(&SendMessage::new(output, target)).await?;
}