mirror of
https://github.com/PluralKit/PluralKit.git
synced 2026-02-15 02:00:09 +00:00
feat: Added Sapphire bot log cleanup support
This commit is contained in:
parent
c639d877f8
commit
36e8daf597
1 changed files with 12 additions and 0 deletions
|
|
@ -23,6 +23,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("Message ID: (\\d{17,19})");
|
private static readonly Regex _carlRegex = new("Message ID: (\\d{17,19})");
|
||||||
|
private static readonly Regex _sapphireRegex = new("\\*\\*Message ID:\\*\\* \\[(\\d{17,19})\\]");
|
||||||
private static readonly Regex _makiRegex = 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 _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})");
|
||||||
|
|
@ -62,6 +63,7 @@ public class LoggerCleanService
|
||||||
new LoggerBot("Dyno#5714", 470723870270160917, ExtractDyno), // webhook
|
new LoggerBot("Dyno#5714", 470723870270160917, ExtractDyno), // webhook
|
||||||
new LoggerBot("Dyno#1961", 347378323418251264, ExtractDyno), // webhook
|
new LoggerBot("Dyno#1961", 347378323418251264, ExtractDyno), // webhook
|
||||||
new LoggerBot("Maki", 563434444321587202, ExtractMaki), // webhook
|
new LoggerBot("Maki", 563434444321587202, ExtractMaki), // webhook
|
||||||
|
new LoggerBot("Sapphire", 678344927997853742, ExtractSapphire), // webhook
|
||||||
new LoggerBot("Auttaja", 242730576195354624, ExtractAuttaja), // webhook
|
new LoggerBot("Auttaja", 242730576195354624, ExtractAuttaja), // webhook
|
||||||
new LoggerBot("GenericBot", 295329346590343168, ExtractGenericBot),
|
new LoggerBot("GenericBot", 295329346590343168, ExtractGenericBot),
|
||||||
new LoggerBot("blargbot", 134133271750639616, ExtractBlargBot),
|
new LoggerBot("blargbot", 134133271750639616, ExtractBlargBot),
|
||||||
|
|
@ -242,6 +244,16 @@ 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 ulong? ExtractSapphire(Message msg)
|
||||||
|
{
|
||||||
|
// Embed, Message title field: "Message deleted", description contains "**Message ID:** [[id]]"
|
||||||
|
// Example: "**Message ID:** [1297549791927996598]"
|
||||||
|
var embed = msg.Embeds?.FirstOrDefault();
|
||||||
|
if (!(embed.Title?.StartsWith("Message deleted") ?? false)) return null;
|
||||||
|
var match = _sapphireRegex.Match(embed.Description);
|
||||||
|
return match.Success ? ulong.Parse(match.Groups[1].Value) : null;
|
||||||
|
}
|
||||||
|
|
||||||
private static FuzzyExtractResult? ExtractCircle(Message msg)
|
private static FuzzyExtractResult? ExtractCircle(Message msg)
|
||||||
{
|
{
|
||||||
// Like Auttaja, Circle has both embed and compact modes, but the regex works for both.
|
// Like Auttaja, Circle has both embed and compact modes, but the regex works for both.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue