Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ pub struct DiscordConfig {
pub allowed_channels: Vec<String>,
#[serde(default)]
pub allowed_users: Vec<String>,
#[serde(default)]
pub allow_bot_trigger: bool,
}

#[derive(Debug, Deserialize)]
Expand Down
4 changes: 3 additions & 1 deletion src/discord.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,14 @@ pub struct Handler {
pub allowed_channels: HashSet<u64>,
pub allowed_users: HashSet<u64>,
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;
}

Expand Down
4 changes: 3 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down