Add option to disable chat filters in private channels

A constructor parameter and corresponding field 'disableInPrivate' have been added to the ChatFilter class. This handles disabling specific chat filters in private channels. The necessary checks have been implemented in RegexManager. The configuration for each filter is also updated in RegexConfig to incorporate this new functionality.
This commit is contained in:
2024-03-31 13:37:05 +02:00
parent 034de90062
commit 4af85d0e79
3 changed files with 16 additions and 2 deletions
@@ -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) {