Optional profanity filter
This commit is contained in:
@@ -187,6 +187,10 @@ function renderPropertyEntranceLabel(name, position, locked, isBusiness, price,
|
||||
screenPosition.y -= propertyLabelNameOffset;
|
||||
|
||||
text = name || " ";
|
||||
if (profanityFilterEnabled) {
|
||||
text = replaceProfanityInMessage(text);
|
||||
}
|
||||
|
||||
size = propertyLabelNameFont.measure(text, game.width, 0.0, 0.0, propertyLabelNameFont.size, true, true);
|
||||
propertyLabelNameFont.render(text, [screenPosition.x - size[0] / 2, screenPosition.y - size[1] / 2], game.width, 0.0, 0.0, propertyLabelNameFont.size, (isBusiness) ? toColour(0, 153, 255, 255) : toColour(17, 204, 17, 255), false, true, false, true);
|
||||
}
|
||||
|
||||
@@ -44,6 +44,10 @@ function loadPausedStatusFont() {
|
||||
// ===========================================================================
|
||||
|
||||
function updatePlayerNameTag(clientName, characterName, colour, paused, ping) {
|
||||
if (profanityFilterEnabled) {
|
||||
characterName = replaceProfanityInMessage(characterName);
|
||||
}
|
||||
|
||||
playerNames[clientName] = characterName;
|
||||
playerColours[clientName] = colour;
|
||||
playerPaused[clientName] = paused;
|
||||
|
||||
@@ -110,6 +110,7 @@ function messageDiscordChatChannel(messageString) {
|
||||
}
|
||||
|
||||
messageString = removeColoursInMessage(messageString);
|
||||
messageString = replaceProfanityInMessage(messageString);
|
||||
triggerDiscordWebHook(messageString, getServerId(), AGRP_DISCORD_WEBHOOK_LOG);
|
||||
}
|
||||
|
||||
@@ -129,6 +130,7 @@ function messageDiscordEventChannel(messageString) {
|
||||
}
|
||||
|
||||
messageString = removeColoursInMessage(messageString);
|
||||
messageString = replaceProfanityInMessage(messageString);
|
||||
triggerDiscordWebHook(messageString, getServerId(), AGRP_DISCORD_WEBHOOK_LOG);
|
||||
}
|
||||
|
||||
|
||||
@@ -1098,6 +1098,8 @@ let serverEmoji = [
|
||||
[":water_buffalo:", "🐃"],
|
||||
[":neutral_face:", "😐"],
|
||||
[":clock1230:", "🕧"],
|
||||
[":think:", "🤔"],
|
||||
[":thinking:", "🤔"],
|
||||
[":P", "😛"],
|
||||
[":)", "🙂"],
|
||||
[":D", "😃"],
|
||||
@@ -1105,6 +1107,7 @@ let serverEmoji = [
|
||||
[":O", "😮"],
|
||||
[":(", "☹️"],
|
||||
[":|", "😐"],
|
||||
["XD", "😆"],
|
||||
];
|
||||
|
||||
// ===========================================================================
|
||||
@@ -3014,9 +3017,9 @@ function removeColoursInMessage(messageText) {
|
||||
*/
|
||||
function replaceProfanityInMessage(messageString) {
|
||||
for (let i in profanityFilterWords) {
|
||||
while (messageString.indexOf(profanityFilterWords[i]) != -1) {
|
||||
messageString = messageString.replace(profanityFilterWords[i], fillStringWithCharacter("*", profanityFilterWords[i].length));
|
||||
}
|
||||
let find = profanityFilterWords[i];
|
||||
let re = new RegExp(find, 'gi');
|
||||
messageString = messageString.replace(re, fillStringWithCharacter('*', find.length - 1));
|
||||
}
|
||||
return messageString;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user