diff --git a/config/default.yaml b/config/default.yaml index 9e9505c..3e0b952 100644 --- a/config/default.yaml +++ b/config/default.yaml @@ -107,6 +107,10 @@ commands: additionalPrefixes: - "mjolnir_bot" + # If true, ban commands that use wildcard characters require confirmation with + # an extra `--force` argument + confirmWildcardBan: true + # Configuration specific to certain toggleable protections protections: # Configuration for the wordlist plugin, which can ban users based if they say certain diff --git a/src/commands/UnbanBanCommand.ts b/src/commands/UnbanBanCommand.ts index 983640d..66afcfa 100644 --- a/src/commands/UnbanBanCommand.ts +++ b/src/commands/UnbanBanCommand.ts @@ -89,6 +89,12 @@ export async function parseArguments(roomId: string, event: any, mjolnir: Mjolni else if (!ruleType) replyMessage = "Please specify the type as either 'user', 'room', or 'server'"; else if (!entity) replyMessage = "No entity found"; + if (config.commands.confirmWildcardBan && /[*?]/.test(entity)) { + if (!parts.includes("--force")) { + replyMessage = "Wildcard bans require an additional `--force` argument to confirm"; + } + } + if (replyMessage) { const reply = RichReply.createFor(roomId, event, replyMessage, replyMessage); reply["msgtype"] = "m.notice"; diff --git a/src/config.ts b/src/config.ts index 6dac3b7..2a64285 100644 --- a/src/config.ts +++ b/src/config.ts @@ -42,6 +42,7 @@ interface IConfig { commands: { allowNoPrefix: boolean; additionalPrefixes: string[]; + confirmWildcardBan: boolean; }; protections: { wordlist: { @@ -94,6 +95,7 @@ const defaultConfig: IConfig = { commands: { allowNoPrefix: false, additionalPrefixes: [], + confirmWildcardBan: true, }, protections: { wordlist: {