Skip to content

Commit

Permalink
Ignored users config knob
Browse files Browse the repository at this point in the history
  • Loading branch information
RedDaedalus committed Apr 11, 2024
1 parent 59b7ff3 commit 8306198
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
2 changes: 2 additions & 0 deletions config.example.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
3 changes: 3 additions & 0 deletions src/config.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
use serde::Deserialize;
use twilight_model::id::{marker::UserMarker, Id};

use crate::pass::Pass;

#[derive(Deserialize)]
pub struct Config {
pub token: String,
pub reply_cache_size: usize,
#[serde(default)]
pub ignored_users: Vec<Id<UserMarker>>,
#[serde(rename = "pass")]
pub passes: Vec<Pass>,
}
2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ async fn dispatch_event(state: Arc<State>, 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(());
}

Expand Down

0 comments on commit 8306198

Please sign in to comment.