Add support for UnbelievaBoat

This commit is contained in:
Ske 2020-02-15 01:41:26 +01:00
parent ccf81b0826
commit 55671b45d6
2 changed files with 14 additions and 2 deletions

View File

@ -24,6 +24,7 @@ namespace PluralKit.Bot
private static Regex _auttajaRegex = new Regex("Message (\\d{17,19}) deleted"); private static Regex _auttajaRegex = new Regex("Message (\\d{17,19}) deleted");
private static Regex _mantaroRegex = new Regex("Message \\(?ID:? (\\d{17,19})\\)? created by .* in channel .* was deleted\\."); private static Regex _mantaroRegex = new Regex("Message \\(?ID:? (\\d{17,19})\\)? created by .* in channel .* was deleted\\.");
private static Regex _pancakeRegex = new Regex("Message from <@(\\d{17,19})> deleted in"); private static Regex _pancakeRegex = new Regex("Message from <@(\\d{17,19})> deleted in");
private static Regex _unbelievaboatRegex = new Regex("Message ID: (\\d{17,19})");
private static readonly Dictionary<ulong, LoggerBot> _bots = new[] private static readonly Dictionary<ulong, LoggerBot> _bots = new[]
{ {
@ -40,6 +41,7 @@ namespace PluralKit.Bot
new LoggerBot("GenericBot", 295329346590343168, ExtractGenericBot), new LoggerBot("GenericBot", 295329346590343168, ExtractGenericBot),
new LoggerBot("blargbot", 134133271750639616, ExtractBlargBot), new LoggerBot("blargbot", 134133271750639616, ExtractBlargBot),
new LoggerBot("Mantaro", 213466096718708737, ExtractMantaro), new LoggerBot("Mantaro", 213466096718708737, ExtractMantaro),
new LoggerBot("UnbelievaBoat", 292953664492929025, ExtractUnbelievaBoat, webhookName: "UnbelievaBoat"),
}.ToDictionary(b => b.Id); }.ToDictionary(b => b.Id);
private static readonly Dictionary<string, LoggerBot> _botsByWebhookName = _bots.Values private static readonly Dictionary<string, LoggerBot> _botsByWebhookName = _bots.Values
@ -222,7 +224,7 @@ namespace PluralKit.Bot
private static FuzzyExtractResult? ExtractPancake(SocketMessage msg) private static FuzzyExtractResult? ExtractPancake(SocketMessage msg)
{ {
// Embed, title is "Message Deleted", description includes a mention, timestamp is *message send time* (but no ID) // Embed, author is "Message Deleted", description includes a mention, timestamp is *message send time* (but no ID)
// so we use the message timestamp to get somewhere *after* the message was proxied // so we use the message timestamp to get somewhere *after* the message was proxied
var embed = msg.Embeds.FirstOrDefault(); var embed = msg.Embeds.FirstOrDefault();
if (embed?.Description == null || embed.Author?.Name != "Message Deleted") return null; if (embed?.Description == null || embed.Author?.Name != "Message Deleted") return null;
@ -232,6 +234,15 @@ namespace PluralKit.Bot
: (FuzzyExtractResult?) null; : (FuzzyExtractResult?) null;
} }
private static ulong? ExtractUnbelievaBoat(SocketMessage msg)
{
// Embed author is "Message Deleted", footer contains message ID per regex
var embed = msg.Embeds.FirstOrDefault();
if (embed?.Footer == null || embed.Author?.Name != "Message Deleted") return null;
var match = _unbelievaboatRegex.Match(embed.Footer.Value.Text ?? "");
return match.Success ? ulong.Parse(match.Groups[1].Value) : (ulong?) null;
}
public class LoggerBot public class LoggerBot
{ {
public string Name; public string Name;

View File

@ -495,6 +495,7 @@ This requires you to have the *Manage Server* permission on the server. At the m
- Logger (#6088 and #6278) - Logger (#6088 and #6278)
- Mantaro - Mantaro
- Pancake - Pancake
- UnbelievaBoat
If you want support for another logging bot, [let me know on the support server](https://discord.gg/PczBt78). If you want support for another logging bot, [let me know on the support server](https://discord.gg/PczBt78).