Skip to content

Commit

Permalink
Added emoji filter
Browse files Browse the repository at this point in the history
  • Loading branch information
faab007nl committed Dec 15, 2021
1 parent bc5a191 commit dffc453
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import java.util.List;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class WordBlacklistModule extends Module {
Expand Down Expand Up @@ -88,8 +89,10 @@ public void onMessageUpdate(GuildMessageUpdateEvent e) {
public boolean runMatcher(String message){
AtomicBoolean blockMessage = new AtomicBoolean(false);
for (String regex : BLACKLISTED_WORDS) {
boolean match = Pattern.compile(regex, Pattern.CASE_INSENSITIVE | Pattern.MULTILINE | Pattern.DOTALL).matcher(message).find();
if (match) {
Matcher matcher = Pattern.compile(regex, Pattern.CASE_INSENSITIVE | Pattern.MULTILINE | Pattern.DOTALL).matcher(message);
boolean match = matcher.find();
String group = matcher.group(0);
if (match && (!group.startsWith(":") && !group.endsWith(":"))) {
blockMessage.set(true);
break;
}
Expand Down

0 comments on commit dffc453

Please sign in to comment.