fix(bot): use newly-exposed message ID in Carl-bot logclean

This commit is contained in:
Iris System 2023-02-08 03:05:08 +13:00
parent e6d8c44d72
commit 51ceb36129
2 changed files with 7 additions and 15 deletions

View File

@ -22,7 +22,7 @@ public class LoggerCleanService
{ {
private static readonly Regex _basicRegex = new("(\\d{17,19})"); private static readonly Regex _basicRegex = new("(\\d{17,19})");
private static readonly Regex _dynoRegex = new("Message ID: (\\d{17,19})"); private static readonly Regex _dynoRegex = new("Message ID: (\\d{17,19})");
private static readonly Regex _carlRegex = new("ID: (\\d{17,19})"); private static readonly Regex _carlRegex = new("Message ID: (\\d{17,19})");
private static readonly Regex _circleRegex = new("\\(`(\\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 _loggerARegex = new("Message = (\\d{17,19})");
private static readonly Regex _loggerBRegex = new("MessageID:(\\d{17,19})"); private static readonly Regex _loggerBRegex = new("MessageID:(\\d{17,19})");
@ -44,7 +44,7 @@ public class LoggerCleanService
private static readonly Dictionary<ulong, LoggerBot> _bots = new[] private static readonly Dictionary<ulong, LoggerBot> _bots = new[]
{ {
new LoggerBot("Carl-bot", 235148962103951360, fuzzyExtractFunc: ExtractCarlBot), // webhooks new LoggerBot("Carl-bot", 235148962103951360, ExtractCarlBot), // webhooks
new LoggerBot("Circle", 497196352866877441, fuzzyExtractFunc: ExtractCircle), new LoggerBot("Circle", 497196352866877441, fuzzyExtractFunc: ExtractCircle),
new LoggerBot("Pancake", 239631525350604801, fuzzyExtractFunc: ExtractPancake), new LoggerBot("Pancake", 239631525350604801, fuzzyExtractFunc: ExtractPancake),
new LoggerBot("Logger", 298822483060981760, ExtractLogger), // webhook new LoggerBot("Logger", 298822483060981760, ExtractLogger), // webhook
@ -217,22 +217,14 @@ public class LoggerCleanService
return match.Success ? ulong.Parse(match.Groups[1].Value) : null; return match.Success ? ulong.Parse(match.Groups[1].Value) : null;
} }
private static FuzzyExtractResult? ExtractCarlBot(Message msg) private static ulong? ExtractCarlBot(Message msg)
{ {
// Embed, title is "Message deleted in [channel], **user** ID in the footer, timestamp as, well, timestamp in embed. // Embed, title is "Message deleted in [channel]", description is message content followed by "Message ID: [id]"
// This is the *deletion* timestamp, which we can assume is a couple seconds at most after the message was originally sent
var embed = msg.Embeds?.FirstOrDefault(); var embed = msg.Embeds?.FirstOrDefault();
if (embed?.Footer == null || embed.Timestamp == null || if (embed?.Footer == null || embed.Timestamp == null ||
!(embed.Title?.StartsWith("Message deleted in") ?? false)) return null; !(embed.Title?.StartsWith("Message deleted in") ?? false)) return null;
var match = _carlRegex.Match(embed.Footer.Text ?? ""); var match = _carlRegex.Match(embed.Description);
return match.Success return match.Success ? ulong.Parse(match.Groups[1].Value) : null;
? new FuzzyExtractResult
{
User = ulong.Parse(match.Groups[1].Value),
ApproxTimestamp = OffsetDateTimePattern.Rfc3339.Parse(embed.Timestamp).GetValueOrThrow()
.ToInstant()
}
: null;
} }
private static FuzzyExtractResult? ExtractCircle(Message msg) private static FuzzyExtractResult? ExtractCircle(Message msg)

View File

@ -23,7 +23,7 @@ This requires you to have the *Manage Server* permission on the server.
At the moment, log cleanup works with the following bots: At the moment, log cleanup works with the following bots:
- [Auttaja](https://auttaja.io/) (precise) - [Auttaja](https://auttaja.io/) (precise)
- [blargbot](https://blargbot.xyz/) (precise) - [blargbot](https://blargbot.xyz/) (precise)
- [Carl-bot](https://carl.gg/) (fuzzy) - [Carl-bot](https://carl.gg/) (precise)
- [Circle](https://circlebot.xyz/) (fuzzy) - [Circle](https://circlebot.xyz/) (fuzzy)
- [Dyno](https://dyno.gg/) (precise) - [Dyno](https://dyno.gg/) (precise)
- [GearBot](https://gearbot.rocks/) (fuzzy) - [GearBot](https://gearbot.rocks/) (fuzzy)