Merge branch 'main' into april_fools
This commit is contained in:
commit
157edbd6b6
|
|
@ -178,13 +178,18 @@ public final class RegexConfig {
|
|||
String regex = entry.getValue().node("regex").getString();
|
||||
String replacement = entry.getValue().node("replacement").getString();
|
||||
List<String> exclusions = entry.getValue().node("exclusions").getList(io.leangen.geantyref.TypeToken.get(String.class), new ArrayList<>());
|
||||
boolean disableInPrivate = false;
|
||||
ConfigurationNode node = entry.getValue().node("disable-in-private");
|
||||
if (node != null) {
|
||||
disableInPrivate = node.getBoolean();
|
||||
}
|
||||
if (type == null || type.isEmpty() || regex == null || regex.isEmpty()) {
|
||||
ALogger.warn("Filter: " + name + " was set up incorrectly");
|
||||
} else {
|
||||
if (replacement == null || replacement.isEmpty()) {
|
||||
replacement = name;
|
||||
}
|
||||
ChatFilter chatFilter = new ChatFilter(name, type, regex, replacement, exclusions);
|
||||
ChatFilter chatFilter = new ChatFilter(name, type, regex, replacement, exclusions, disableInPrivate);
|
||||
RegexManager.addFilter(chatFilter);
|
||||
}
|
||||
} catch(SerializationException ex) {
|
||||
|
|
|
|||
|
|
@ -60,7 +60,10 @@ public class RegexManager {
|
|||
return false;
|
||||
}
|
||||
CachedPermissionData permissionData = user.getCachedData().getPermissionData();
|
||||
boolean isPrivate = channel.equals("party");
|
||||
for(ChatFilter chatFilter : chatFilters) {
|
||||
if (isPrivate && chatFilter.isDisabledInPrivate())
|
||||
continue;
|
||||
switch (chatFilter.getType()) {
|
||||
case CHAT:
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -17,14 +17,16 @@ public class ChatFilter {
|
|||
private final Pattern pattern;
|
||||
private final String replacement;
|
||||
private final List<String> exclusions;
|
||||
private final boolean disableInPrivate;
|
||||
|
||||
public ChatFilter(String name, String type, String regex, String replacement, List<String> exclusions) {
|
||||
public ChatFilter(String name, String type, String regex, String replacement, List<String> exclusions, boolean disableInPrivate) {
|
||||
this.name = name;
|
||||
this.filterType = FilterType.getType(type);
|
||||
this.regex = regex;
|
||||
this.pattern = Pattern.compile(getRegex(), Pattern.CASE_INSENSITIVE);
|
||||
this.replacement = replacement;
|
||||
this.exclusions = exclusions;
|
||||
this.disableInPrivate = disableInPrivate;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
|
|
@ -47,6 +49,10 @@ public class ChatFilter {
|
|||
return this.exclusions;
|
||||
}
|
||||
|
||||
public boolean isDisabledInPrivate() {
|
||||
return disableInPrivate;
|
||||
}
|
||||
|
||||
public boolean matches(ModifiableString filterableString) {
|
||||
String input = filterableString.string();
|
||||
Matcher matcher = pattern.matcher(input);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user