feat(cleanup): add koira log cleanup spport

This commit is contained in:
Dominik Koch 2024-12-06 14:52:11 +01:00
parent 1c0925a178
commit 03c1241175
No known key found for this signature in database
GPG key ID: 29B5CF4D740CED25

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,17 @@ public class LoggerCleanService
: null;
}
private static ulong? ExtractKoira(Message msg)
{
// Embed, Message title field: "Message Deleted", description contains "**ID:** [[id]]"
// Example: "**ID:** [347077478726238228]"
var embed = msg.Embeds?.FirstOrDefault();
if (embed == null) return null;
if (!(embed.Title?.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;
@ -452,4 +465,4 @@ public class LoggerCleanService
{
public ulong User { get; set; }
}
}
}