mirror of
https://github.com/PluralKit/PluralKit.git
synced 2026-02-04 04:56:49 +00:00
feat(cleanup): add koira log cleanup spport
This commit is contained in:
parent
1c0925a178
commit
03c1241175
1 changed files with 14 additions and 1 deletions
|
|
@ -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; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue