feat(log cleanup): add koira log cleanup support

This commit is contained in:
Dominik Koch 2024-12-06 14:52:11 +01:00 committed by rladenson
parent b73dd370d1
commit 73f9a0aa36
2 changed files with 15 additions and 0 deletions

View file

@ -44,6 +44,7 @@ public class LoggerCleanService
private static readonly Regex _SkyraRegex = new("https://discord.com/channels/(\\d{17,19})/(\\d{17,19})/(\\d{17,19})");
private static readonly Regex _AnnabelleRegex = new("```\n(\\d{17,19})\n```");
private static readonly Regex _AnnabelleRegexFuzzy = new("\\<t:(\\d+)\\> A message from \\*\\*[\\w.]{2,32}\\*\\* \\(`(\\d{17,19})`\\) was deleted in <#\\d{17,19}>");
private static readonly Regex _koiraRegex = new("ID:\\*\\* (\\d{17,19})");
private static readonly Regex _VortexRegex =
new("`\\[(\\d\\d:\\d\\d:\\d\\d)\\]` .* \\(ID:(\\d{17,19})\\).* <#\\d{17,19}>:");
@ -82,6 +83,7 @@ public class LoggerCleanService
new LoggerBot("Dozer", 356535250932858885, ExtractDozer),
new LoggerBot("Skyra", 266624760782258186, ExtractSkyra),
new LoggerBot("Annabelle", 231241068383961088, ExtractAnnabelle, fuzzyExtractFunc: ExtractAnnabelleFuzzy),
new LoggerBot("Koira", 1247013404569239624, ExtractKoira)
}.ToDictionary(b => b.Id);
private static Dictionary<ulong, LoggerBot> _botsByApplicationId
@ -427,6 +429,18 @@ public class LoggerCleanService
: null;
}
private static ulong? ExtractKoira(Message msg)
{
// Embed, Message author name field: "Message Deleted", description contains "**[emoji] ID:** [id]"
// Example: "ID:** 347077478726238228"
// We only use the end of the bold markdown because there's a custom emoji in the bold we don't want to copy the code of
var embed = msg.Embeds?.FirstOrDefault();
if (embed == null) return null;
if (!(embed.Author?.Name?.StartsWith("Message Deleted") ?? false)) return null;
var match = _koiraRegex.Match(embed.Description);
return match.Success ? ulong.Parse(match.Groups[1].Value) : null;
}
public class LoggerBot
{
public ulong Id;