Skip to content

Commit

Permalink
feat: show which banned phrases got filtered
Browse files Browse the repository at this point in the history
  • Loading branch information
vyneer committed Sep 13, 2023
1 parent d354748 commit 0b72f59
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
11 changes: 11 additions & 0 deletions assets/chat/js/chat.js
Original file line number Diff line number Diff line change
Expand Up @@ -1203,6 +1203,17 @@ class Chat {
`You are temporarily muted! You can chat again ${this.mutedtimer.getReadableDuration()}. Subscribe to remove the mute immediately.`,
);
break;
case 'bannedphrase': {
const phraseCountText =
data.filtered.length === 1
? 'this banned phrase'
: 'these banned phrases';
const filteredPretty = data.filtered.map((p) => `"${p}"`).join(', ');
message = MessageBuilder.error(
`Your message was filtered because it contained ${phraseCountText}: ${filteredPretty}.`,
);
break;
}
default:
message = MessageBuilder.error(errorstrings.get(desc) || desc);
}
Expand Down
2 changes: 0 additions & 2 deletions assets/chat/js/const.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,6 @@ const errorstrings = new Map(
alreadyvoted: 'You have already voted!',
nochatting:
"You aren't allowed to chat. Either you haven't picked a username, or a mod disabled your privileges.",
bannedphrase:
'Your message was filtered because it contained a banned phrase.',
duplicatephrase: 'Banned phrase already exists.',
nophrase: "Banned phrase doesn't exist.",
}),
Expand Down

0 comments on commit 0b72f59

Please sign in to comment.