mirror of
https://github.com/Tyrrrz/DiscordChatExporter.git
synced 2026-02-19 07:47:11 +00:00
@@ -1,4 +1,5 @@
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
using DiscordChatExporter.Core.Discord.Data;
|
||||
|
||||
namespace DiscordChatExporter.Core.Exporting.Filtering
|
||||
@@ -9,10 +10,25 @@ namespace DiscordChatExporter.Core.Exporting.Filtering
|
||||
|
||||
public ContainsMessageFilter(string text) => _text = text;
|
||||
|
||||
public override bool Filter(Message message) => Regex.IsMatch(
|
||||
message.Content,
|
||||
"\\b" + _text + "\\b",
|
||||
RegexOptions.IgnoreCase | RegexOptions.CultureInvariant
|
||||
);
|
||||
private bool Filter(string? content) =>
|
||||
!string.IsNullOrWhiteSpace(content) &&
|
||||
Regex.IsMatch(
|
||||
content,
|
||||
"\\b" + Regex.Escape(_text) + "\\b",
|
||||
RegexOptions.IgnoreCase | RegexOptions.CultureInvariant
|
||||
);
|
||||
|
||||
public override bool Filter(Message message) =>
|
||||
Filter(message.Content) ||
|
||||
message.Embeds.Any(e =>
|
||||
Filter(e.Title) ||
|
||||
Filter(e.Author?.Name) ||
|
||||
Filter(e.Description) ||
|
||||
Filter(e.Footer?.Text) ||
|
||||
e.Fields.Any(f =>
|
||||
Filter(f.Name) ||
|
||||
Filter(f.Value)
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user