mirror of
https://github.com/PluralKit/PluralKit.git
synced 2026-02-04 04:56:49 +00:00
feat(bot): add Zeppelin logclean support (#737)
This commit is contained in:
parent
8bf738fbd3
commit
1013cf3755
1 changed files with 20 additions and 1 deletions
|
|
@ -45,6 +45,7 @@ public class LoggerCleanService
|
|||
private static readonly Regex _AnnabelleRegex = new("```\n(\\d{17,19})\n```");
|
||||
private static readonly Regex _AnnabelleRegexFuzzy = new("\\<t:(\\d+)\\> A message from \\*\\*[\\w.]{2,32}\\*\\* \\(`(\\d{17,19})`\\) was deleted in <#\\d{17,19}>");
|
||||
private static readonly Regex _koiraRegex = new("ID:\\*\\* (\\d{17,19})");
|
||||
private static readonly Regex _zeppelinRegex = new("🗑 Message \\(`(\\d{17,19})`\\)");
|
||||
|
||||
private static readonly Regex _VortexRegex =
|
||||
new("`\\[(\\d\\d:\\d\\d:\\d\\d)\\]` .* \\(ID:(\\d{17,19})\\).* <#\\d{17,19}>:");
|
||||
|
|
@ -83,7 +84,8 @@ public class LoggerCleanService
|
|||
new LoggerBot("Dozer", 356535250932858885, ExtractDozer),
|
||||
new LoggerBot("Skyra", 266624760782258186, ExtractSkyra),
|
||||
new LoggerBot("Annabelle", 231241068383961088, ExtractAnnabelle, fuzzyExtractFunc: ExtractAnnabelleFuzzy),
|
||||
new LoggerBot("Koira", 1247013404569239624, ExtractKoira)
|
||||
new LoggerBot("Koira", 1247013404569239624, ExtractKoira),
|
||||
new LoggerBot("Zeppelin", 473868086773153793, ExtractZeppelin) // webhook
|
||||
}.ToDictionary(b => b.Id);
|
||||
|
||||
private static Dictionary<ulong, LoggerBot> _botsByApplicationId
|
||||
|
|
@ -441,6 +443,23 @@ public class LoggerCleanService
|
|||
return match.Success ? ulong.Parse(match.Groups[1].Value) : null;
|
||||
}
|
||||
|
||||
private static ulong? ExtractZeppelin(Message msg)
|
||||
{
|
||||
// zeppelin uses a non-embed format by default but can be configured to use a customizable embed
|
||||
// if it's an embed, assume the footer contains the message ID
|
||||
var embed = msg.Embeds?.FirstOrDefault();
|
||||
if (embed == null)
|
||||
{
|
||||
var match = _zeppelinRegex.Match(msg.Content ?? "");
|
||||
return match.Success ? ulong.Parse(match.Groups[1].Value) : null;
|
||||
}
|
||||
else
|
||||
{
|
||||
var match = _basicRegex.Match(embed.Footer?.Text ?? "");
|
||||
return match.Success ? ulong.Parse(match.Groups[1].Value) : null;
|
||||
}
|
||||
}
|
||||
|
||||
public class LoggerBot
|
||||
{
|
||||
public ulong Id;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue