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 regex = entry.getValue().node("regex").getString();
|
||||||
String replacement = entry.getValue().node("replacement").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<>());
|
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()) {
|
if (type == null || type.isEmpty() || regex == null || regex.isEmpty()) {
|
||||||
ALogger.warn("Filter: " + name + " was set up incorrectly");
|
ALogger.warn("Filter: " + name + " was set up incorrectly");
|
||||||
} else {
|
} else {
|
||||||
if (replacement == null || replacement.isEmpty()) {
|
if (replacement == null || replacement.isEmpty()) {
|
||||||
replacement = name;
|
replacement = name;
|
||||||
}
|
}
|
||||||
ChatFilter chatFilter = new ChatFilter(name, type, regex, replacement, exclusions);
|
ChatFilter chatFilter = new ChatFilter(name, type, regex, replacement, exclusions, disableInPrivate);
|
||||||
RegexManager.addFilter(chatFilter);
|
RegexManager.addFilter(chatFilter);
|
||||||
}
|
}
|
||||||
} catch(SerializationException ex) {
|
} catch(SerializationException ex) {
|
||||||
|
|
|
||||||
|
|
@ -60,7 +60,10 @@ public class RegexManager {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
CachedPermissionData permissionData = user.getCachedData().getPermissionData();
|
CachedPermissionData permissionData = user.getCachedData().getPermissionData();
|
||||||
|
boolean isPrivate = channel.equals("party");
|
||||||
for(ChatFilter chatFilter : chatFilters) {
|
for(ChatFilter chatFilter : chatFilters) {
|
||||||
|
if (isPrivate && chatFilter.isDisabledInPrivate())
|
||||||
|
continue;
|
||||||
switch (chatFilter.getType()) {
|
switch (chatFilter.getType()) {
|
||||||
case CHAT:
|
case CHAT:
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
|
|
@ -17,14 +17,16 @@ public class ChatFilter {
|
||||||
private final Pattern pattern;
|
private final Pattern pattern;
|
||||||
private final String replacement;
|
private final String replacement;
|
||||||
private final List<String> exclusions;
|
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.name = name;
|
||||||
this.filterType = FilterType.getType(type);
|
this.filterType = FilterType.getType(type);
|
||||||
this.regex = regex;
|
this.regex = regex;
|
||||||
this.pattern = Pattern.compile(getRegex(), Pattern.CASE_INSENSITIVE);
|
this.pattern = Pattern.compile(getRegex(), Pattern.CASE_INSENSITIVE);
|
||||||
this.replacement = replacement;
|
this.replacement = replacement;
|
||||||
this.exclusions = exclusions;
|
this.exclusions = exclusions;
|
||||||
|
this.disableInPrivate = disableInPrivate;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
|
|
@ -47,6 +49,10 @@ public class ChatFilter {
|
||||||
return this.exclusions;
|
return this.exclusions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isDisabledInPrivate() {
|
||||||
|
return disableInPrivate;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean matches(ModifiableString filterableString) {
|
public boolean matches(ModifiableString filterableString) {
|
||||||
String input = filterableString.string();
|
String input = filterableString.string();
|
||||||
Matcher matcher = pattern.matcher(input);
|
Matcher matcher = pattern.matcher(input);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user