diff --git a/src/config.rs b/src/config.rs index 6d341e27..40be0be6 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 allow_bot_trigger: bool, } #[derive(Debug, Deserialize)] diff --git a/src/discord.rs b/src/discord.rs index f176a3d6..36601f72 100644 --- a/src/discord.rs +++ b/src/discord.rs @@ -19,12 +19,14 @@ pub struct Handler { pub allowed_channels: HashSet, pub allowed_users: HashSet, pub reactions_config: ReactionsConfig, + pub allow_bot_trigger: bool, } #[async_trait] impl EventHandler for Handler { async fn message(&self, ctx: Context, msg: Message) { - if msg.author.bot { + // Skip bot messages unless allow_bot_trigger is enabled + if msg.author.bot && !self.allow_bot_trigger { return; } diff --git a/src/main.rs b/src/main.rs index 39817342..def44017 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 allow_bot_trigger = cfg.discord.allow_bot_trigger; + info!(channels = allowed_channels.len(), users = allowed_users.len(), allow_bot_trigger, "parsed allowlists"); let handler = discord::Handler { pool: pool.clone(), allowed_channels, allowed_users, reactions_config: cfg.reactions, + allow_bot_trigger, }; let intents = GatewayIntents::GUILD_MESSAGES