From 3aada93a8091d39268caf4ba070a2890b3da444b Mon Sep 17 00:00:00 2001 From: Dragory <2606411+Dragory@users.noreply.github.com> Date: Fri, 16 Oct 2020 02:01:07 +0300 Subject: [PATCH] Add sticker_spam automod trigger --- backend/package-lock.json | 11 +++++------ backend/package.json | 2 +- backend/src/data/GuildSavedMessages.ts | 1 + backend/src/data/entities/SavedMessage.ts | 2 ++ backend/src/plugins/Automod/constants.ts | 1 + .../functions/addRecentActionsFromMessage.ts | 17 +++++++++++++++++ .../Automod/triggers/availableTriggers.ts | 3 +++ .../src/plugins/Automod/triggers/stickerSpam.ts | 4 ++++ 8 files changed, 34 insertions(+), 7 deletions(-) create mode 100644 backend/src/plugins/Automod/triggers/stickerSpam.ts diff --git a/backend/package-lock.json b/backend/package-lock.json index b43c8acf..a940245c 100644 --- a/backend/package-lock.json +++ b/backend/package-lock.json @@ -1562,9 +1562,8 @@ "dev": true }, "eris": { - "version": "0.13.3", - "resolved": "https://registry.npmjs.org/eris/-/eris-0.13.3.tgz", - "integrity": "sha512-WBtLyknOWZpYZL9yPhez0oKUWvYpunSg43hGxawwjwSf3gFXmbEPYrT8KlmZXtpJnX16eQ7mzIq+MgSh3LarEg==", + "version": "github:dragory/eris#9c1935b31a1c2972861464b54bb382a165674b93", + "from": "github:dragory/eris#stickers", "requires": { "opusscript": "^0.0.7", "tweetnacl": "^1.0.1", @@ -4568,9 +4567,9 @@ } }, "ws": { - "version": "7.3.0", - "resolved": "https://registry.npmjs.org/ws/-/ws-7.3.0.tgz", - "integrity": "sha512-iFtXzngZVXPGgpTlP1rBqsUK82p9tKqsWRPg5L56egiljujJT3vGAYnHANvFxBieXrTFavhzhxW52jnaWV+w2w==" + "version": "7.3.1", + "resolved": "https://registry.npmjs.org/ws/-/ws-7.3.1.tgz", + "integrity": "sha512-D3RuNkynyHmEJIpD2qrgVkc9DQ23OrN/moAwZX4L8DfvszsJxpjQuUq3LMx6HoYji9fbIOBY18XWBsAux1ZZUA==" }, "xdg-basedir": { "version": "4.0.0", diff --git a/backend/package.json b/backend/package.json index b067ec38..5a81c24b 100644 --- a/backend/package.json +++ b/backend/package.json @@ -30,7 +30,7 @@ "deep-diff": "^1.0.2", "dotenv": "^4.0.0", "emoji-regex": "^8.0.0", - "eris": "^0.13.3", + "eris": "github:dragory/eris#stickers", "erlpack": "github:abalabahaha/erlpack", "escape-string-regexp": "^1.0.5", "express": "^4.17.0", diff --git a/backend/src/data/GuildSavedMessages.ts b/backend/src/data/GuildSavedMessages.ts index 67d0e4e5..3abac626 100644 --- a/backend/src/data/GuildSavedMessages.ts +++ b/backend/src/data/GuildSavedMessages.ts @@ -46,6 +46,7 @@ export class GuildSavedMessages extends BaseGuildRepository { if (msg.attachments.length) data.attachments = msg.attachments; if (msg.embeds.length) data.embeds = msg.embeds; + if (msg.stickers?.length) data.stickers = msg.stickers; return data; } diff --git a/backend/src/data/entities/SavedMessage.ts b/backend/src/data/entities/SavedMessage.ts index 8212abf9..8b4f6468 100644 --- a/backend/src/data/entities/SavedMessage.ts +++ b/backend/src/data/entities/SavedMessage.ts @@ -1,5 +1,6 @@ import { Column, Entity, PrimaryColumn } from "typeorm"; import { createEncryptedJsonTransformer } from "../encryptedJsonTransformer"; +import { Sticker } from "eris"; export interface ISavedMessageData { attachments?: object[]; @@ -9,6 +10,7 @@ export interface ISavedMessageData { }; content: string; embeds?: object[]; + stickers?: Sticker[]; timestamp: number; } diff --git a/backend/src/plugins/Automod/constants.ts b/backend/src/plugins/Automod/constants.ts index a2445c3e..d6f30b86 100644 --- a/backend/src/plugins/Automod/constants.ts +++ b/backend/src/plugins/Automod/constants.ts @@ -14,4 +14,5 @@ export enum RecentActionType { Character, VoiceChannelMove, MemberJoin, + Sticker, } diff --git a/backend/src/plugins/Automod/functions/addRecentActionsFromMessage.ts b/backend/src/plugins/Automod/functions/addRecentActionsFromMessage.ts index 289c6f5c..78ebd0a2 100644 --- a/backend/src/plugins/Automod/functions/addRecentActionsFromMessage.ts +++ b/backend/src/plugins/Automod/functions/addRecentActionsFromMessage.ts @@ -126,4 +126,21 @@ export function addRecentActionsFromMessage(pluginData: GuildPluginData> = { match_words: MatchWordsTrigger, @@ -35,6 +36,7 @@ export const availableTriggers: Record line_spam: LineSpamTrigger, character_spam: CharacterSpamTrigger, member_join_spam: MemberJoinSpamTrigger, + sticker_spam: StickerSpamTrigger, }; export const AvailableTriggers = t.type({ @@ -55,4 +57,5 @@ export const AvailableTriggers = t.type({ line_spam: LineSpamTrigger.configType, character_spam: CharacterSpamTrigger.configType, member_join_spam: MemberJoinSpamTrigger.configType, + sticker_spam: StickerSpamTrigger.configType, }); diff --git a/backend/src/plugins/Automod/triggers/stickerSpam.ts b/backend/src/plugins/Automod/triggers/stickerSpam.ts new file mode 100644 index 00000000..05fcbc45 --- /dev/null +++ b/backend/src/plugins/Automod/triggers/stickerSpam.ts @@ -0,0 +1,4 @@ +import { RecentActionType } from "../constants"; +import { createMessageSpamTrigger } from "../functions/createMessageSpamTrigger"; + +export const StickerSpamTrigger = createMessageSpamTrigger(RecentActionType.Sticker, "sticker");