From 878ca63b65f92c6b0cc080d3467a48b094157b9e Mon Sep 17 00:00:00 2001 From: rladenson <78043712+rladenson@users.noreply.github.com> Date: Fri, 4 Aug 2023 20:31:16 -0600 Subject: [PATCH] feat: add logclean support for Dozer bot (#580) --- PluralKit.Bot/Services/LoggerCleanService.cs | 9 +++++++++ docs/content/staff/compatibility.md | 1 + 2 files changed, 10 insertions(+) diff --git a/PluralKit.Bot/Services/LoggerCleanService.cs b/PluralKit.Bot/Services/LoggerCleanService.cs index dd9ca9f0..7df10227 100644 --- a/PluralKit.Bot/Services/LoggerCleanService.cs +++ b/PluralKit.Bot/Services/LoggerCleanService.cs @@ -38,6 +38,7 @@ public class LoggerCleanService private static readonly Regex _GearBotRegex = new("\\(``(\\d{17,19})``\\) in <#\\d{17,19}> has been removed."); private static readonly Regex _GiselleRegex = new("\\*\\*Message ID\\*\\*: `(\\d{17,19})`"); private static readonly Regex _ProBotRegex = new("\\*\\*Message sent by <@(\\d{17,19})> deleted in <#\\d{17,19}>.\\*\\*"); + private static readonly Regex _DozerRegex = new("Message ID: (\\d{17,19}) - (\\d{17,19})\nUserID: (\\d{17,19})"); private static readonly Regex _VortexRegex = new("`\\[(\\d\\d:\\d\\d:\\d\\d)\\]` .* \\(ID:(\\d{17,19})\\).* <#\\d{17,19}>:"); @@ -71,6 +72,7 @@ public class LoggerCleanService new LoggerBot("Vortex", 240254129333731328, fuzzyExtractFunc: ExtractVortex), new LoggerBot("ProBot", 282859044593598464, fuzzyExtractFunc: ExtractProBot), // webhook new LoggerBot("ProBot Prime", 567703512763334685, fuzzyExtractFunc: ExtractProBot), // webhook (?) + new LoggerBot("Dozer", 356535250932858885, ExtractDozer), }.ToDictionary(b => b.Id); private static Dictionary _botsByApplicationId @@ -363,6 +365,13 @@ public class LoggerCleanService } : null; } + + private static ulong? ExtractDozer(Message msg) + { + var embed = msg.Embeds?.FirstOrDefault(); + var match = _DozerRegex.Match(embed?.Footer.Text); + return match.Success ? ulong.Parse(match.Groups[2].Value) : null; + } public class LoggerBot { diff --git a/docs/content/staff/compatibility.md b/docs/content/staff/compatibility.md index ed823e5b..a6b10293 100644 --- a/docs/content/staff/compatibility.md +++ b/docs/content/staff/compatibility.md @@ -25,6 +25,7 @@ At the moment, log cleanup works with the following bots: - [blargbot](https://blargbot.xyz/) (precise) - [Carl-bot](https://carl.gg/) (precise) - [Circle](https://circlebot.xyz/) (fuzzy) +- [Dozer](https://github.com/frcdiscord/dozer) (precise) - [Dyno](https://dyno.gg/) (precise) - [GearBot](https://gearbot.rocks/) (fuzzy) - [GenericBot](https://github.com/galenguyer/GenericBot) (precise)