Skip to content

Commit

Permalink
fix(bots/discord): correct whitelist logic
Browse files Browse the repository at this point in the history
  • Loading branch information
PalmDevs committed Aug 3, 2024
1 parent 4e889d4 commit 49c29be
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions bots/discord/src/utils/discord/messageScan.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -122,17 +122,19 @@ export const messageMatchesFilter = (message: Message, filter: NonNullable<Confi
// If matches whitelist but also matches blacklist, will return false
// If matches only whitelist, will return true
// If matches neither, will return true
return whitelist
? (whitelist.channels?.includes(message.channelId) ?? true) ||
(whitelist.roles?.some(role => 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 (
Expand Down

0 comments on commit 49c29be

Please sign in to comment.