2020-08-04 22:22:57 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Linq;
|
2021-02-18 01:00:35 +00:00
|
|
|
|
using NoSoliciting.Interface;
|
2020-08-04 22:22:57 +00:00
|
|
|
|
|
|
|
|
|
namespace NoSoliciting {
|
2020-08-23 14:55:52 +00:00
|
|
|
|
public partial class Filter {
|
2021-01-02 13:23:41 +00:00
|
|
|
|
private static class PartyFinder {
|
2020-08-06 04:17:14 +00:00
|
|
|
|
public static bool MatchesCustomFilters(string msg, PluginConfiguration config) {
|
|
|
|
|
if (config == null) {
|
|
|
|
|
throw new ArgumentNullException(nameof(config), "PluginConfiguration cannot be null");
|
|
|
|
|
}
|
|
|
|
|
|
2020-12-21 02:49:10 +00:00
|
|
|
|
if (!config.CustomPFFilter) {
|
2020-08-06 04:17:14 +00:00
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2021-02-18 01:00:35 +00:00
|
|
|
|
msg = NoSolUtil.Normalise(msg);
|
2020-08-06 04:17:14 +00:00
|
|
|
|
|
2021-04-25 19:19:42 +00:00
|
|
|
|
return config.ValidPfSubstrings.Any(needle => msg.ContainsIgnoreCase(needle))
|
2021-04-28 16:50:26 +00:00
|
|
|
|
|| config.CompiledPfRegexes.Any(needle => needle.IsMatch(msg));
|
2020-08-06 04:17:14 +00:00
|
|
|
|
}
|
2020-08-04 22:22:57 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|