From 541b886a3be538c35049c0f19b802a84d9bd4936 Mon Sep 17 00:00:00 2001 From: Patrick Jones <64071912+pjones123@users.noreply.github.com> Date: Sat, 23 Oct 2021 21:58:00 +0100 Subject: Regex for automod (#28) * fix spelling in README * regex automod words --- src/lib/common/AutoMod.ts | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'src/lib/common') diff --git a/src/lib/common/AutoMod.ts b/src/lib/common/AutoMod.ts index 312beb3..5f0b8a0 100644 --- a/src/lib/common/AutoMod.ts +++ b/src/lib/common/AutoMod.ts @@ -29,7 +29,8 @@ export class AutoMod { severity: Severity.PERM_MUTE, ignoreSpaces: true, ignoreCapitalization: true, - reason: 'malicious link' + reason: 'malicious link', + regex: false, }; }); @@ -67,8 +68,15 @@ export class AutoMod { const matchedWords: BadWords = {}; for (const word in words) { const wordOptions = words[word]; - if (this.format(this.message.content, wordOptions).includes(this.format(word, wordOptions))) { - matchedWords[word] = wordOptions; + if (wordOptions.regex) { + if (new RegExp(word).test(this.format(word, wordOptions))) { + matchedWords[word] = wordOptions; + } + } + else { + if (this.format(this.message.content, wordOptions).includes(this.format(word, wordOptions))) { + matchedWords[word] = wordOptions; + } } } return matchedWords; @@ -239,6 +247,7 @@ interface BadWordDetails { ignoreSpaces: boolean; ignoreCapitalization: boolean; reason: string; + regex: boolean; } export interface BadWords { -- cgit From 9bc6ca4b2e42d8c55318710d115f3cdaeb5459eb Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sat, 23 Oct 2021 20:58:45 +0000 Subject: Automatically format code --- src/lib/badwords.ts | 72 +++++++++++++++++++++++------------------------ src/lib/common/AutoMod.ts | 5 ++-- 2 files changed, 38 insertions(+), 39 deletions(-) (limited to 'src/lib/common') diff --git a/src/lib/badwords.ts b/src/lib/badwords.ts index f878f45..1773274 100644 --- a/src/lib/badwords.ts +++ b/src/lib/badwords.ts @@ -10,70 +10,70 @@ export default { ignoreCapitalization: true, reason: "racial slur", regex: false, -}, + }, "nigga": { severity: Severity.PERM_MUTE, ignoreSpaces: true, ignoreCapitalization: true, reason: "racial slur", regex: false, -}, + }, "nigger": { severity: Severity.PERM_MUTE, ignoreSpaces: true, ignoreCapitalization: true, reason: "racial slur", regex: false, -}, + }, "nigra": { severity: Severity.PERM_MUTE, ignoreSpaces: true, ignoreCapitalization: true, reason: "racial slur", regex: false, -}, + }, "retard": { severity: Severity.TEMP_MUTE, ignoreSpaces: true, ignoreCapitalization: true, reason: "ableist slur", regex: false, -}, + }, "retarted": { severity: Severity.TEMP_MUTE, ignoreSpaces: true, ignoreCapitalization: true, reason: "ableist slur", regex: false, -}, + }, "slut": { severity: Severity.WARN, ignoreSpaces: false, ignoreCapitalization: true, reason: "derogatory term", regex: false, -}, + }, "tar baby": { severity: Severity.TEMP_MUTE, ignoreSpaces: true, ignoreCapitalization: true, reason: "racial slur", regex: false, -}, + }, "whore": { severity: Severity.WARN, ignoreSpaces: false, ignoreCapitalization: true, reason: "derogatory term", regex: false, -}, + }, "卍": { severity: Severity.PERM_MUTE, ignoreSpaces: true, ignoreCapitalization: true, reason: "racist symbol", regex: false, -}, + }, /* -------------------------------------------------------------------------- */ /* Steam Scams */ @@ -85,84 +85,84 @@ export default { ignoreCapitalization: true, reason: "steam scam phrase", regex: false, -}, + }, "hello i am leaving cs:go": { severity: Severity.PERM_MUTE, ignoreSpaces: true, ignoreCapitalization: true, reason: "steam scam phrase", regex: false, -}, + }, "hello! I'm done with csgo": { severity: Severity.PERM_MUTE, ignoreSpaces: true, ignoreCapitalization: true, reason: "steam scam phrase", regex: false, -}, + }, "hi bro, i'm leaving this fucking game, take my skin": { severity: Severity.PERM_MUTE, ignoreSpaces: true, ignoreCapitalization: true, reason: "steam scam phrase", regex: false, -}, + }, "hi friend, today i am leaving this fucking game": { severity: Severity.PERM_MUTE, ignoreSpaces: true, ignoreCapitalization: true, reason: "steam scam phrase", regex: false, -}, + }, "hi guys, i'm leaving this fucking game, take my": { severity: Severity.PERM_MUTE, ignoreSpaces: true, ignoreCapitalization: true, reason: "steam scam phrase", regex: false, -}, + }, "hi, bro h am leaving cs:go and giving away my skin": { severity: Severity.PERM_MUTE, ignoreSpaces: true, ignoreCapitalization: true, reason: "steam scam phrase", regex: false, -}, + }, "hi, bro i am leaving cs:go and giving away my skin": { severity: Severity.PERM_MUTE, ignoreSpaces: true, ignoreCapitalization: true, reason: "steam scam phrase", regex: false, -}, + }, "i confirm all exchanges, there won't be enough": { severity: Severity.PERM_MUTE, ignoreSpaces: true, ignoreCapitalization: true, reason: "steam scam phrase", regex: false, -}, + }, "i quit csgo": { severity: Severity.PERM_MUTE, ignoreSpaces: true, ignoreCapitalization: true, reason: "steam scam phrase", regex: false, -}, + }, "the first three who send a trade": { severity: Severity.PERM_MUTE, ignoreSpaces: true, ignoreCapitalization: true, reason: "steam scam phrase", regex: false, -}, + }, "you can choose any skin for yourself": { severity: Severity.PERM_MUTE, ignoreSpaces: true, ignoreCapitalization: true, reason: "steam scam phrase", regex: false, -}, + }, /* -------------------------------------------------------------------------- */ /* Nitro Scams */ @@ -173,63 +173,63 @@ export default { ignoreCapitalization: true, reason: "discord nitro scam phrase", regex: false, -}, + }, "discord nitro for free - steam store": { severity: Severity.PERM_MUTE, ignoreSpaces: true, ignoreCapitalization: true, reason: "discord nitro scam phrase", regex: false, -}, + }, "free 3 months of discord nitro": { severity: Severity.PERM_MUTE, ignoreSpaces: true, ignoreCapitalization: true, reason: "discord nitro scam phrase", regex: false, -}, + }, "free discord nitro airdrop": { severity: Severity.PERM_MUTE, ignoreSpaces: true, ignoreCapitalization: true, reason: "discord nitro scam phrase", regex: false, -}, + }, "get 3 months of discord nitro": { severity: Severity.PERM_MUTE, ignoreSpaces: true, ignoreCapitalization: true, reason: "discord nitro scam phrase", regex: false, -}, + }, "get discord nitro for free": { severity: Severity.PERM_MUTE, ignoreSpaces: true, ignoreCapitalization: true, reason: "discord nitro scam phrase", regex: false, -}, + }, "get free discord nitro from steam": { severity: Severity.PERM_MUTE, ignoreSpaces: true, ignoreCapitalization: true, reason: "discord nitro scam phrase", regex: false, -}, + }, "lol, jahjajha free discord nitro for 3 month!!": { severity: Severity.PERM_MUTE, ignoreSpaces: true, ignoreCapitalization: true, reason: "discord nitro scam phrase", regex: false, -}, + }, "steam is giving away 3 months of discord nitro for free to all no limited steam users": { severity: Severity.PERM_MUTE, ignoreSpaces: true, ignoreCapitalization: true, reason: "discord nitro scam phrase", regex: false, -}, + }, "Лол, бесплатный дискорд нитро на 1 месяц!": { //? Lol, 1 month free discord nitro! severity: Severity.PERM_MUTE, @@ -237,14 +237,14 @@ export default { ignoreCapitalization: true, reason: "discord nitro scam phrase", regex: false, -}, + }, "Airdrop Discord FREE NITRO from Steam —": { severity: Severity.PERM_MUTE, ignoreSpaces: true, ignoreCapitalization: true, reason: "discord nitro scam phrase", regex: false, -}, + }, /* -------------------------------------------------------------------------- */ /* Misc Scams */ @@ -255,7 +255,7 @@ export default { ignoreCapitalization: true, reason: "misc. scam phrase", regex: false, -}, + }, "there is a possible chance tomorrow there will be a cyber-attack event where on all social networks including Discord there will be people trying": { severity: Severity.WARN, @@ -263,7 +263,7 @@ export default { ignoreCapitalization: true, reason: "annoying copy pasta", regex: false, -}, + }, /* -------------------------------------------------------------------------- */ /* Frequently Advertised Discord Severs */ @@ -274,5 +274,5 @@ export default { ignoreCapitalization: true, reason: "blacklisted server link", regex: false, -}, + }, } as BadWords; diff --git a/src/lib/common/AutoMod.ts b/src/lib/common/AutoMod.ts index 5f0b8a0..adc629a 100644 --- a/src/lib/common/AutoMod.ts +++ b/src/lib/common/AutoMod.ts @@ -30,7 +30,7 @@ export class AutoMod { ignoreSpaces: true, ignoreCapitalization: true, reason: 'malicious link', - regex: false, + regex: false }; }); @@ -72,8 +72,7 @@ export class AutoMod { if (new RegExp(word).test(this.format(word, wordOptions))) { matchedWords[word] = wordOptions; } - } - else { + } else { if (this.format(this.message.content, wordOptions).includes(this.format(word, wordOptions))) { matchedWords[word] = wordOptions; } -- cgit