aboutsummaryrefslogtreecommitdiff
path: root/src/lib/common/AutoMod.ts
diff options
context:
space:
mode:
authorPatrick Jones <64071912+pjones123@users.noreply.github.com>2021-10-23 21:58:00 +0100
committerGitHub <noreply@github.com>2021-10-23 16:58:00 -0400
commit541b886a3be538c35049c0f19b802a84d9bd4936 (patch)
tree094267a7d83bb35036c91921a68ee4bde8d7c3a7 /src/lib/common/AutoMod.ts
parent44521f4560dc8b0bab055685437d8fa65a34377f (diff)
downloadtanzanite-541b886a3be538c35049c0f19b802a84d9bd4936.tar.gz
tanzanite-541b886a3be538c35049c0f19b802a84d9bd4936.tar.bz2
tanzanite-541b886a3be538c35049c0f19b802a84d9bd4936.zip
Regex for automod (#28)
* fix spelling in README * regex automod words
Diffstat (limited to 'src/lib/common/AutoMod.ts')
-rw-r--r--src/lib/common/AutoMod.ts15
1 files changed, 12 insertions, 3 deletions
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 {