From 66b9298f61949118b56e5371c1a4a23f1b91918e Mon Sep 17 00:00:00 2001 From: TudbuT Date: Mon, 7 Oct 2024 07:41:22 +0200 Subject: [PATCH] improve chatfilter --- .../client/feature/modules/chat/ChatFilter.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Client/src/main/java/de/com/baseband/client/feature/modules/chat/ChatFilter.java b/Client/src/main/java/de/com/baseband/client/feature/modules/chat/ChatFilter.java index 3d87b12..62782a9 100644 --- a/Client/src/main/java/de/com/baseband/client/feature/modules/chat/ChatFilter.java +++ b/Client/src/main/java/de/com/baseband/client/feature/modules/chat/ChatFilter.java @@ -125,11 +125,11 @@ public class ChatFilter extends Feature { } public boolean containsWord(String s, String word) { - return Pattern.compile("(?<=[  ](§.)?(§.)?(§.)?)" + word + "(?=\\W|$)", Pattern.CASE_INSENSITIVE).matcher(s).find(); + return Pattern.compile("(?<=[  ](§.)?(§.)?(§.)?)" + word + "(?=[^a-z]|$)", Pattern.CASE_INSENSITIVE).matcher(s).find(); } public String filter(String s, String word, String type) { - Pattern pat = Pattern.compile("(?<=[  ](§.)?(§.)?(§.)?)" + word + "(?=\\W|$)", Pattern.CASE_INSENSITIVE); + Pattern pat = Pattern.compile("(?<=[  ](§.)?(§.)?(§.)?)" + word + "(?=[^a-z]|$)", Pattern.CASE_INSENSITIVE); Matcher matcher = pat.matcher(s); StringBuilder result = new StringBuilder(s.length()); int last = 0; @@ -137,7 +137,7 @@ public class ChatFilter extends Feature { result.append(s, last, matcher.start()); switch (mode) { case Censor: - result.append(matcher.group().replaceFirst("[aeiou]", "*")); + result.append(matcher.group().replaceAll("[aeiou]", "*")); break; case Replace: result.append("[").append(type).append(" removed]"); @@ -155,14 +155,14 @@ public class ChatFilter extends Feature { // TODO expand public static final String[] ETHNIC_SLURS = new String[] { - "nig+a?e?h?r*", + "[a-z]*nig+a?e?h?r*[a-z]*", "negr+o(id)?", }; public static final String[] QUEERPHOBIC_SLURS = new String[] { - "trann\\w*", + "[a-z]*trann[a-z]*", "shemale", - "hon", + "hon[a-z]*", "subnormal", "troon", };