fix: no longer consider empty custom filters
This commit is contained in:
parent
b0e49b8458
commit
815ba1c1ad
|
@ -16,7 +16,7 @@ namespace NoSoliciting {
|
||||||
|
|
||||||
msg = NoSolUtil.Normalise(msg);
|
msg = NoSolUtil.Normalise(msg);
|
||||||
|
|
||||||
return config.ChatSubstrings.Any(needle => msg.ContainsIgnoreCase(needle))
|
return config.ValidChatSubstrings.Any(needle => msg.ContainsIgnoreCase(needle))
|
||||||
|| config.CompiledChatRegexes.Any(needle => needle.IsMatch(msg));
|
|| config.CompiledChatRegexes.Any(needle => needle.IsMatch(msg));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,7 @@ namespace NoSoliciting {
|
||||||
|
|
||||||
msg = NoSolUtil.Normalise(msg);
|
msg = NoSolUtil.Normalise(msg);
|
||||||
|
|
||||||
return config.PFSubstrings.Any(needle => msg.ContainsIgnoreCase(needle))
|
return config.ValidPfSubstrings.Any(needle => msg.ContainsIgnoreCase(needle))
|
||||||
|| config.CompiledPFRegexes.Any(needle => needle.IsMatch(msg));
|
|| config.CompiledPFRegexes.Any(needle => needle.IsMatch(msg));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -351,9 +351,7 @@ namespace NoSoliciting.Interface {
|
||||||
for (var i = 0; i < substrings.Count; i++) {
|
for (var i = 0; i < substrings.Count; i++) {
|
||||||
var input = substrings[i];
|
var input = substrings[i];
|
||||||
if (ImGui.InputText($"##{name}-substring-{i}", ref input, 1_000)) {
|
if (ImGui.InputText($"##{name}-substring-{i}", ref input, 1_000)) {
|
||||||
if (input.Length != 0) {
|
substrings[i] = input;
|
||||||
substrings[i] = input;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui.SameLine();
|
ImGui.SameLine();
|
||||||
|
@ -382,15 +380,12 @@ namespace NoSoliciting.Interface {
|
||||||
for (var i = 0; i < regexes.Count; i++) {
|
for (var i = 0; i < regexes.Count; i++) {
|
||||||
var input = regexes[i];
|
var input = regexes[i];
|
||||||
if (ImGui.InputText($"##{name}-regex-{i}", ref input, 1_000)) {
|
if (ImGui.InputText($"##{name}-regex-{i}", ref input, 1_000)) {
|
||||||
var valid = true;
|
|
||||||
try {
|
try {
|
||||||
_ = new Regex(input);
|
_ = new Regex(input);
|
||||||
} catch (ArgumentException) {
|
// update if valid
|
||||||
valid = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (valid && input.Length != 0) {
|
|
||||||
regexes[i] = input;
|
regexes[i] = input;
|
||||||
|
} catch (ArgumentException) {
|
||||||
|
// ignore
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -99,6 +99,9 @@ namespace NoSoliciting {
|
||||||
|
|
||||||
public bool ConsiderPrivatePfs { get; set; }
|
public bool ConsiderPrivatePfs { get; set; }
|
||||||
|
|
||||||
|
public IEnumerable<string> ValidChatSubstrings => this.ChatSubstrings.Where(needle => !string.IsNullOrWhiteSpace(needle));
|
||||||
|
public IEnumerable<string> ValidPfSubstrings => this.PFSubstrings.Where(needle => !string.IsNullOrWhiteSpace(needle));
|
||||||
|
|
||||||
public void Initialise(DalamudPluginInterface pi) {
|
public void Initialise(DalamudPluginInterface pi) {
|
||||||
this.Interface = pi;
|
this.Interface = pi;
|
||||||
this.CompileRegexes();
|
this.CompileRegexes();
|
||||||
|
@ -110,9 +113,11 @@ namespace NoSoliciting {
|
||||||
|
|
||||||
public void CompileRegexes() {
|
public void CompileRegexes() {
|
||||||
this.CompiledChatRegexes = this.ChatRegexes
|
this.CompiledChatRegexes = this.ChatRegexes
|
||||||
|
.Where(reg => !string.IsNullOrWhiteSpace(reg))
|
||||||
.Select(reg => new Regex(reg, RegexOptions.Compiled))
|
.Select(reg => new Regex(reg, RegexOptions.Compiled))
|
||||||
.ToList();
|
.ToList();
|
||||||
this.CompiledPFRegexes = this.PFRegexes
|
this.CompiledPFRegexes = this.PFRegexes
|
||||||
|
.Where(reg => !string.IsNullOrWhiteSpace(reg))
|
||||||
.Select(reg => new Regex(reg, RegexOptions.Compiled))
|
.Select(reg => new Regex(reg, RegexOptions.Compiled))
|
||||||
.ToList();
|
.ToList();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue