Skip to content
This repository has been archived by the owner on Aug 7, 2024. It is now read-only.

Commit

Permalink
fix: Handle response whitelist and blacklist correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
oSumAtrIX authored Jun 14, 2024
1 parent 10adf19 commit c2397bd
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/utils/message_response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,21 @@ use crate::{
impl Trigger {
fn matches(&self, new_message: &Message, member_roles: &[RoleId]) -> bool {
if let Some(channels) = &self.channels {
if !channels.contains(&new_message.channel_id.get()) {
if channels.contains(&new_message.channel_id.get()) {
return true;
}
}

if let Some(roles) = &self.roles {
if !member_roles
if member_roles
.iter()
.any(|&member_role| roles.contains(&member_role.get()))
{
return true;
}
}

if !self.regex.iter().any(|r| r.is_match(&new_message.content)) {
if self.regex.iter().any(|r| r.is_match(&new_message.content)) {
return true;
}

Expand All @@ -49,7 +49,7 @@ pub async fn handle_message_response(

for response in &configuration.responses {
if let Some(whitelist) = &response.whitelist {
if whitelist.matches(new_message, member_roles) {
if !whitelist.matches(new_message, member_roles) {
continue;
}
}
Expand Down

0 comments on commit c2397bd

Please sign in to comment.