From 1118d8bdf8b91637a09cf40f49d17e6ccc1bf95f Mon Sep 17 00:00:00 2001 From: the institute Date: Sat, 19 Oct 2024 22:24:12 +0100 Subject: [PATCH] feat(bot): add Maki (maki.gg) logclean support (#685) --- PluralKit.Bot/Services/LoggerCleanService.cs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/PluralKit.Bot/Services/LoggerCleanService.cs b/PluralKit.Bot/Services/LoggerCleanService.cs index 0f623e68..6346b8b2 100644 --- a/PluralKit.Bot/Services/LoggerCleanService.cs +++ b/PluralKit.Bot/Services/LoggerCleanService.cs @@ -23,6 +23,7 @@ public class LoggerCleanService private static readonly Regex _basicRegex = new("(\\d{17,19})"); private static readonly Regex _dynoRegex = new("Message ID: (\\d{17,19})"); private static readonly Regex _carlRegex = new("Message ID: (\\d{17,19})"); + private static readonly Regex _makiRegex = new("Message ID: (\\d{17,19})"); private static readonly Regex _circleRegex = new("\\(`(\\d{17,19})`\\)"); private static readonly Regex _loggerARegex = new("Message = (\\d{17,19})"); private static readonly Regex _loggerBRegex = new("MessageID:(\\d{17,19})"); @@ -60,6 +61,7 @@ public class LoggerCleanService new LoggerBot("Dyno#8389", 470724017205149701, ExtractDyno), // webhook new LoggerBot("Dyno#5714", 470723870270160917, ExtractDyno), // webhook new LoggerBot("Dyno#1961", 347378323418251264, ExtractDyno), // webhook + new LoggerBot("Maki", 563434444321587202, ExtractMaki), // webhook new LoggerBot("Auttaja", 242730576195354624, ExtractAuttaja), // webhook new LoggerBot("GenericBot", 295329346590343168, ExtractGenericBot), new LoggerBot("blargbot", 134133271750639616, ExtractBlargBot), @@ -231,6 +233,15 @@ public class LoggerCleanService return match.Success ? ulong.Parse(match.Groups[1].Value) : null; } + private static ulong? ExtractMaki(Message msg) + { + // Embed, Message Author Name field: "Message Deleted", footer is "Message ID: [id]" + var embed = msg.Embeds?.FirstOrDefault(); + if (embed.Author?.Name == null || embed?.Footer == null || !embed.Author.Name.StartsWith("Message Deleted")) return null; + var match = _makiRegex.Match(embed.Footer.Text ?? ""); + return match.Success ? ulong.Parse(match.Groups[1].Value) : null; + } + private static FuzzyExtractResult? ExtractCircle(Message msg) { // Like Auttaja, Circle has both embed and compact modes, but the regex works for both.