mirror of
https://github.com/Tyrrrz/DiscordChatExporter.git
synced 2026-02-15 00:03:38 -07:00
parent
e849c9516c
commit
6b8170ab89
|
|
@ -1,4 +1,5 @@
|
||||||
using System.Text.RegularExpressions;
|
using System.Linq;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
using DiscordChatExporter.Core.Discord.Data;
|
using DiscordChatExporter.Core.Discord.Data;
|
||||||
|
|
||||||
namespace DiscordChatExporter.Core.Exporting.Filtering
|
namespace DiscordChatExporter.Core.Exporting.Filtering
|
||||||
|
|
@ -9,10 +10,25 @@ namespace DiscordChatExporter.Core.Exporting.Filtering
|
||||||
|
|
||||||
public ContainsMessageFilter(string text) => _text = text;
|
public ContainsMessageFilter(string text) => _text = text;
|
||||||
|
|
||||||
public override bool Filter(Message message) => Regex.IsMatch(
|
private bool Filter(string? content) =>
|
||||||
message.Content,
|
!string.IsNullOrWhiteSpace(content) &&
|
||||||
"\\b" + _text + "\\b",
|
Regex.IsMatch(
|
||||||
|
content,
|
||||||
|
"\\b" + Regex.Escape(_text) + "\\b",
|
||||||
RegexOptions.IgnoreCase | RegexOptions.CultureInvariant
|
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)
|
||||||
|
)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
Reference in a new issue