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

@ -1573,6 +1573,10 @@ pub struct MattermostConfig {
/// When false, replies go to the channel root.
#[serde(default)]
pub thread_replies: Option<bool>,
/// When true, only respond to messages that @-mention the bot.
/// Other messages in the channel are silently ignored.
#[serde(default)]
pub mention_only: Option<bool>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]