Allow custom profanity filter replacement

This commit is contained in:
UnknownShadow200 2018-12-27 22:26:18 +11:00
parent 800fe69e5f
commit 201fc8a927
2 changed files with 10 additions and 3 deletions

View File

@ -50,13 +50,18 @@ namespace MCGalaxy {
}
if (!isFiltered) continue;
// If a bad word is found anywhere in the word, replace the word
int length = words[i].Length;
words[i] = "&c[&fBlocked&c]&f";
// If a bad word is found anywhere in the word, replace the word
words[i] = Replace(words[i]);
}
return String.Join(" ", words);
}
static string Replace(string word) {
string replacement = Server.Config.ProfanityReplacement;
// for * repeat to ****
return replacement.Length == 1 ? new string(replacement[0], word.Length) : replacement;
}
static void InitReduceTable() {
if (reduceKeys != null) return;
// Because some letters are similar (Like i and l), they are reduced to the same form.

View File

@ -201,6 +201,8 @@ namespace MCGalaxy {
internal List<string> DisabledChatTokens = new List<string>();
[ConfigBool("profanity-filter", "Other", false)]
public bool ProfanityFiltering = false;
[ConfigString("profanity-replacement", "Other", "*")]
public string ProfanityReplacement = "*";
[ConfigString("host-state", "Other", "Alive")]
public string ConsoleName = "Alive";