diff --git a/src/config.rs b/src/config.rs index 6d341e27..8e711cd9 100644 --- a/src/config.rs +++ b/src/config.rs @@ -20,6 +20,8 @@ pub struct DiscordConfig { pub allowed_channels: Vec, #[serde(default)] pub allowed_users: Vec, + #[serde(default)] + pub monitored_bot_ids: Vec, } #[derive(Debug, Deserialize)] diff --git a/src/discord.rs b/src/discord.rs index f176a3d6..2376dbca 100644 --- a/src/discord.rs +++ b/src/discord.rs @@ -19,12 +19,17 @@ pub struct Handler { pub allowed_channels: HashSet, pub allowed_users: HashSet, pub reactions_config: ReactionsConfig, + pub monitored_bot_ids: HashSet, } #[async_trait] impl EventHandler for Handler { async fn message(&self, ctx: Context, msg: Message) { - if msg.author.bot { + // Check if message is from a monitored bot (allows auto-response without mention) + let is_monitored_bot = msg.author.bot && self.monitored_bot_ids.contains(&msg.author.id.get()); + + // Skip bot messages unless from a monitored bot + if msg.author.bot && !is_monitored_bot { return; } @@ -63,7 +68,8 @@ impl EventHandler for Handler { if !in_allowed_channel && !in_thread { return; } - if !in_thread && !is_mentioned { + // Require mention unless in thread or from a monitored bot + if !in_thread && !is_mentioned && !is_monitored_bot { return; } diff --git a/src/main.rs b/src/main.rs index 39817342..2eaf0df4 100644 --- a/src/main.rs +++ b/src/main.rs @@ -40,13 +40,15 @@ async fn main() -> anyhow::Result<()> { let allowed_channels = parse_id_set(&cfg.discord.allowed_channels, "allowed_channels")?; let allowed_users = parse_id_set(&cfg.discord.allowed_users, "allowed_users")?; - info!(channels = allowed_channels.len(), users = allowed_users.len(), "parsed allowlists"); + let monitored_bot_ids = parse_id_set(&cfg.discord.monitored_bot_ids, "monitored_bot_ids")?; + info!(channels = allowed_channels.len(), users = allowed_users.len(), monitored_bots = monitored_bot_ids.len(), "parsed allowlists"); let handler = discord::Handler { pool: pool.clone(), allowed_channels, allowed_users, reactions_config: cfg.reactions, + monitored_bot_ids, }; let intents = GatewayIntents::GUILD_MESSAGES