Skip to content

Commit

Permalink
Use DurationMSProtectionSetting and add setting comments
Browse files Browse the repository at this point in the history
  • Loading branch information
MTRNord committed Mar 8, 2022
1 parent 6993f96 commit 219ecce
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/protections/MentionFlood.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ import { Mjolnir } from "../Mjolnir";
import { LogLevel, LogService } from "matrix-bot-sdk";
import config from "../config";
import { htmlEscape, isTrueJoinEvent } from "../utils";
import { BooleanProtectionSetting, NumberProtectionSetting, OptionListProtectionSetting } from "./ProtectionSettings";
import { BooleanProtectionSetting, DurationMSProtectionSetting, NumberProtectionSetting, OptionListProtectionSetting } from "./ProtectionSettings";

const DEFAULT_MINUTES_BEFORE_TRUSTING = 20;
const DEFAULT_MINUTES_BEFORE_TRUSTING = 20 * 60 * 1000;
const DEFAULT_MAX_MENTIONS_PER_MESSAGE = 20;
const DEFAULT_REDACT = true;
const DEFAULT_ACTION = "ban";
Expand All @@ -40,9 +40,13 @@ const PORT_REGEX = "(:[0-9]+)?";
export class MentionFlood extends Protection {

settings = {
minutesBeforeTrusting: new NumberProtectionSetting(DEFAULT_MINUTES_BEFORE_TRUSTING),
// Time in which this protection takes action on users
minutesBeforeTrusting: new DurationMSProtectionSetting(DEFAULT_MINUTES_BEFORE_TRUSTING),
// The minimum amount of mentions for this protection to take action
maxMentionsPerMessage: new NumberProtectionSetting(DEFAULT_MAX_MENTIONS_PER_MESSAGE),
// Defines if messages shall also get directly redacted or not
redact: new BooleanProtectionSetting(DEFAULT_REDACT),
// The action that is supposed to get taken
action: new OptionListProtectionSetting(["ban", "kick", "warn"])
};

Expand Down

0 comments on commit 219ecce

Please sign in to comment.