-
Notifications
You must be signed in to change notification settings - Fork 16
temp mute non suspecious players when they use n word #166
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
344dc13
733620d
e1f0e41
2c5c166
a59b711
9f4a9cc
a83cd3b
3ab6db7
6a0520f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,7 +5,7 @@ For functions that don't need values from other files, see funcs.ts. | |
| */ | ||
|
|
||
| import * as api from "/api"; | ||
| import { adminNames, bannedWords, Gamemode, GamemodeName, multiCharSubstitutions, substitutions, text } from "/config"; | ||
| import { adminNames, bannedWords, Gamemode, GamemodeName, multiCharSubstitutions, substitutions, text, tempMute } from "/config"; | ||
| import { fail, PartialFormatString } from "/frameworks/commands"; | ||
| import { crash, escapeStringColorsServer, escapeTextDiscord, parseError, random, StringIO } from "/funcs"; | ||
| import { fishState, ipPattern, ipPortPattern, ipRangeCIDRPattern, ipRangeWildcardPattern, maxTime, tileHistory, uuidPattern } from "/globals"; | ||
|
|
@@ -546,6 +546,26 @@ export function processChat(player:mindustryPlayer, message:string, effects = fa | |
| } | ||
| Log.info(`Censored message from player ${player.name}: "${escapeStringColorsServer(message)}"; contained "${filterTripText}"`); | ||
| FishPlayer.messageStaff(`[yellow]Censored message from player ${fishPlayer.cleanedName}: "${message}" contained "${filterTripText}"`); | ||
|
|
||
| if (!suspicious) { | ||
| const normalized = removeFoosChars(message).toLowerCase(); | ||
| const nwordPattern = /\bn[i1!][gq9]{2,}(?:[ea3]r|a)\b/; | ||
|
|
||
| if (nwordPattern.test(normalized)) { | ||
| const durationMs = tempMute.nwordDurationMs; | ||
| const muteTimestamp = Date.now(); | ||
| (fishPlayer as any)._lastAutomodMuteAt = muteTimestamp; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't use undeclared fields like this, it's bad practice. Remove the underscore and add it to the type definition for FishPlayer with the other transients, like |
||
| void fishPlayer.mute("automod"); | ||
| player.sendMessage(`[scarlet]You have been muted for ${Math.round(durationMs / 60000)} minutes.[lightgray] Reason: Prohibited language`); | ||
| FishPlayer.messageStaff(`[yellow]Temp-muted ${fishPlayer.cleanedName} for ${Math.round(durationMs / 60000)} minutes: n-word`); | ||
| Log.info(`[automod] Temp-muted ${player.name} (${player.uuid()}) for ${Math.round(durationMs / 60000)}m: n-word`); | ||
| Timer.schedule(() => { | ||
| if ((fishPlayer as any)._lastAutomodMuteAt === muteTimestamp) { | ||
| void fishPlayer.unmute("automod"); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This won't work if the server restarts between the mute and unmute: You can fix this by storing the scheduled unmute, but that will get complicated. (What if the server doesn't come back online? What if the server crashes while saving and needs a rollback?) It's usually better design to avoid updating stored state on a timer, because it causes bugs like this. Instead, we need to change the stored
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. requires #95 |
||
| } | ||
| }, durationMs / 1000); | ||
| } | ||
| } | ||
| } | ||
| message = text.chatFilterReplacement.message(); | ||
| highlight ??= text.chatFilterReplacement.highlight(); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This also needs to remove color tags, or it would allow things like
bad[white]word.Maybe this (strip colors, remove foos chars, lowercase) should be made into a function? something like cleanTextLight