diff --git a/app/discord/automod.ts b/app/discord/automod.ts index 2306473..12f0fab 100644 --- a/app/discord/automod.ts +++ b/app/discord/automod.ts @@ -16,22 +16,13 @@ const spamKeywords = [ "deepfake", "poki", ].map((x) => new RegExp(x)); -const spamPings = ["@everyone", "@here"]; + const safeKeywords = ["forhire", "hiring", "remote", "onsite"]; const checkWords = (message: string, wordList: string[]) => message.split(/\b/).some((word) => wordList.includes(word.toLowerCase())); -const getPingCount = (content: string) => { - return spamPings.reduce( - (sum, pingKeyword) => (content.includes(pingKeyword) ? sum + 1 : sum), - 0, - ); -}; - export const isSpam = (content: string, threshold = 4) => { - const pingCount = getPingCount(content); - const numberOfSpamKeywords = spamKeywords.reduce( (accum, spamTrigger) => (spamTrigger.test(content) ? accum + 1 : accum), 0, @@ -44,8 +35,6 @@ export const isSpam = (content: string, threshold = 4) => { const score = Number(hasLink) * 2 + numberOfSpamKeywords + - // Pinging everyone is always treated as spam - pingCount * 5 + Number(hasBareInvite) * 5 - // If it's a job post, then it's probably not spam Number(hasSafeKeywords) * 10; @@ -86,7 +75,7 @@ export default async (bot: Client) => { member.kick("Autokicked for spamming"); modLog.send(`Automatically kicked <@${message.author.id}> for spam`); } - } else if (getPingCount(message.content) > 0) { + } else if (msg.mentions.everyone) { await reportUser({ reason: ReportReasons.ping, message: message,