From 83061988dda15cb7056b700ef6adaa9cde53d197 Mon Sep 17 00:00:00 2001 From: Daedalus <16168171+RedDaedalus@users.noreply.github.com> Date: Thu, 11 Apr 2024 13:12:50 -0600 Subject: [PATCH] Ignored users config knob --- config.example.toml | 2 ++ src/config.rs | 3 +++ src/main.rs | 2 +- 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/config.example.toml b/config.example.toml index 28fa479..cd3e071 100644 --- a/config.example.toml +++ b/config.example.toml @@ -2,6 +2,8 @@ token = "your bot's token" # Number of replies to cache. Cache memory usage (bytes) = `this * 16`. reply_cache_size = 3 +# User IDs the bot won't respond to. +ignored_users = [] # Passes: each pass gets run independently and all of its matched URLs are appended # to the bot's output. diff --git a/src/config.rs b/src/config.rs index 5f4cf1a..2f0e416 100644 --- a/src/config.rs +++ b/src/config.rs @@ -1,4 +1,5 @@ use serde::Deserialize; +use twilight_model::id::{marker::UserMarker, Id}; use crate::pass::Pass; @@ -6,6 +7,8 @@ use crate::pass::Pass; pub struct Config { pub token: String, pub reply_cache_size: usize, + #[serde(default)] + pub ignored_users: Vec>, #[serde(rename = "pass")] pub passes: Vec, } diff --git a/src/main.rs b/src/main.rs index 64c7f21..173adfe 100644 --- a/src/main.rs +++ b/src/main.rs @@ -82,7 +82,7 @@ async fn dispatch_event(state: Arc, event: Event) -> Result<(), anyhow::E match event { // CREATE: Fix embeds when someone sends a twitter link Event::MessageCreate(message) => { - if message.author.bot { + if message.author.bot || state.config.ignored_users.contains(&message.author.id) { return Ok(()); }