From 49c29bebfbe348ae4e2cc1b3a83bfa41eb26ccd1 Mon Sep 17 00:00:00 2001 From: PalmDevs Date: Sun, 4 Aug 2024 00:29:11 +0700 Subject: [PATCH] fix(bots/discord): correct whitelist logic --- bots/discord/src/utils/discord/messageScan.ts | 26 ++++++++++--------- 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/bots/discord/src/utils/discord/messageScan.ts b/bots/discord/src/utils/discord/messageScan.ts index 5c4822d..c66409d 100644 --- a/bots/discord/src/utils/discord/messageScan.ts +++ b/bots/discord/src/utils/discord/messageScan.ts @@ -87,7 +87,7 @@ export const getResponseFromText = async ( } // If we still don't have a response config, we can match all regexes after the initial label trigger - if (!responseConfig.triggers) { + if (!responseConfig.triggers && ocrMode) { logger.debug('No match from NLP, doing after regexes') for (let i = 0; i < responses.length; i++) { const { @@ -122,17 +122,19 @@ export const messageMatchesFilter = (message: Message, filter: NonNullable memberRoles.has(role)) ?? true) || - (whitelist.users?.includes(message.author.id) ?? true) - : true && - !( - blacklist && - (blacklist.channels?.includes(message.channelId) || - blacklist.roles?.some(role => memberRoles.has(role)) || - blacklist.users?.includes(message.author.id)) - ) + return ( + (whitelist + ? whitelist.channels?.includes(message.channelId) || + whitelist.roles?.some(role => memberRoles.has(role)) || + whitelist.users?.includes(message.author.id) + : true) && + !( + blacklist && + (blacklist.channels?.includes(message.channelId) || + blacklist.roles?.some(role => memberRoles.has(role)) || + blacklist.users?.includes(message.author.id)) + ) + ) } export const handleUserResponseCorrection = async (