Skip to content

Commit 74f4ed3

Browse files
committed
feat: Allow whitelist to override blacklist regardless of source
1 parent 42dde7d commit 74f4ed3

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

src/ps/handlers/commands/index.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -91,18 +91,18 @@ export async function commandHandler(message: PSMessage, indirect: IndirectCtx |
9191
if (message.type === 'chat') {
9292
const roomConfig = PSRoomConfigs[message.target.id];
9393
const lookup = context.command.join('.');
94-
if (roomConfig?.blacklist?.includes(lookup) && !roomConfig?.whitelist?.includes(lookup)) {
94+
const isWhitelisted =
95+
roomConfig.whitelist &&
96+
(roomConfig.whitelist?.includes(lookup) ||
97+
sourceCommand.categories.some(category => roomConfig.whitelist!.includes(`cat:${category}`)));
98+
if (roomConfig?.blacklist?.includes(lookup) && !isWhitelisted) {
9599
throw new ChatError($T('BLACKLISTED_COMMAND', { room: message.target.title }));
96100
}
97101
const blacklistedCategories = roomConfig?.blacklist
98102
? sourceCommand.categories.filter(category => roomConfig.blacklist!.includes(`cat:${category}`))
99103
: [];
100-
if (blacklistedCategories.length > 0) {
101-
if (!(roomConfig?.whitelist && sourceCommand.categories.some(category => roomConfig.whitelist!.includes(`cat:${category}`)))) {
102-
throw new ChatError(
103-
$T('BLACKLISTED_CATEGORIES', { room: message.target.title, categories: blacklistedCategories.list($T) })
104-
);
105-
}
104+
if (blacklistedCategories.length > 0 && !isWhitelisted) {
105+
throw new ChatError($T('BLACKLISTED_CATEGORIES', { room: message.target.title, categories: blacklistedCategories.list($T) }));
106106
}
107107
}
108108
if (!cascade.flags.routePMs && indirect?.type === 'spoof') {

0 commit comments

Comments
 (0)