3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-03-14 21:31:50 +00:00

automod: create archives for matched spam

This commit is contained in:
Dragory 2020-07-29 22:42:31 +03:00
parent b73c8668e3
commit 63b77d1aaf
No known key found for this signature in database
GPG key ID: 5F387BA66DF8AAC1

View file

@ -1,7 +1,7 @@
import { RecentActionType } from "../constants";
import { automodTrigger } from "../helpers";
import { getBaseUrl } from "../../../pluginUtils";
import { convertDelayStringToMS, tDelayString, tNullable } from "../../../utils";
import { convertDelayStringToMS, sorter, tDelayString, tNullable } from "../../../utils";
import { humanizeDurationShort } from "../../../humanizeDurationShort";
import { findRecentSpam } from "./findRecentSpam";
import { getMatchingMessageRecentActions } from "./getMatchingMessageRecentActions";
@ -30,7 +30,12 @@ export function createMessageSpamTrigger(spamType: RecentActionType, prettyName:
const recentSpam = findRecentSpam(pluginData, spamType, context.message.user_id);
if (recentSpam) {
// TODO: Combine with old archive
await pluginData.state.archives.addSavedMessagesToArchive(
recentSpam.archiveId,
[context.message],
pluginData.guild,
);
return {
silentClean: true,
};
@ -47,8 +52,12 @@ export function createMessageSpamTrigger(spamType: RecentActionType, prettyName:
);
if (matchedSpam) {
// TODO: Generate archive link
const archiveId = "TODO";
const messages = matchedSpam.recentActions
.map(action => action.context.message)
.filter(Boolean)
.sort(sorter("posted_at"));
const archiveId = await pluginData.state.archives.createFromSavedMessages(messages, pluginData.guild);
pluginData.state.recentSpam.push({
type: spamType,