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 committed Jun 14, 2024
1 parent 10adf19 commit 4b75d76
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ homepage = "https://revanced.app"
license = "GPL-3.0"
name = "revanced-discord-bot"
repository = "https://github.com/revanced/revanced-discord-bot"
version = "2.8.0"
version = "2.9.0"
edition = "2021"

[profile.release]
Expand Down
13 changes: 5 additions & 8 deletions src/utils/message_response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,13 @@ use serenity::Message;
use tracing::log::error;

use super::*;
use crate::{
model::application::Trigger,
BotData,
};
use crate::{model::application::Trigger, BotData};

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()) {
return true;
return false;
}
}

Expand All @@ -22,11 +19,11 @@ impl Trigger {
.iter()
.any(|&member_role| roles.contains(&member_role.get()))
{
return true;
return false;
}
}

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

Expand All @@ -49,7 +46,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 4b75d76

Please sign in to comment.