mirror of
https://github.com/matrix-org/mjolnir.git
synced 2024-10-01 01:36:06 -04:00
Add confirmation for wildcard bans
This adds a default enabled option to require confirmation for wildcard bans (e.g. those containing `*` or `?`). Users will need to also add `--force` for the commands to be accepted.
This commit is contained in:
parent
e4e5c5e72d
commit
46192ac6f7
@ -107,6 +107,10 @@ commands:
|
|||||||
additionalPrefixes:
|
additionalPrefixes:
|
||||||
- "mjolnir_bot"
|
- "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
|
# Configuration specific to certain toggleable protections
|
||||||
protections:
|
protections:
|
||||||
# Configuration for the wordlist plugin, which can ban users based if they say certain
|
# Configuration for the wordlist plugin, which can ban users based if they say certain
|
||||||
|
@ -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 (!ruleType) replyMessage = "Please specify the type as either 'user', 'room', or 'server'";
|
||||||
else if (!entity) replyMessage = "No entity found";
|
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) {
|
if (replyMessage) {
|
||||||
const reply = RichReply.createFor(roomId, event, replyMessage, replyMessage);
|
const reply = RichReply.createFor(roomId, event, replyMessage, replyMessage);
|
||||||
reply["msgtype"] = "m.notice";
|
reply["msgtype"] = "m.notice";
|
||||||
|
@ -42,6 +42,7 @@ interface IConfig {
|
|||||||
commands: {
|
commands: {
|
||||||
allowNoPrefix: boolean;
|
allowNoPrefix: boolean;
|
||||||
additionalPrefixes: string[];
|
additionalPrefixes: string[];
|
||||||
|
confirmWildcardBan: boolean;
|
||||||
};
|
};
|
||||||
protections: {
|
protections: {
|
||||||
wordlist: {
|
wordlist: {
|
||||||
@ -94,6 +95,7 @@ const defaultConfig: IConfig = {
|
|||||||
commands: {
|
commands: {
|
||||||
allowNoPrefix: false,
|
allowNoPrefix: false,
|
||||||
additionalPrefixes: [],
|
additionalPrefixes: [],
|
||||||
|
confirmWildcardBan: true,
|
||||||
},
|
},
|
||||||
protections: {
|
protections: {
|
||||||
wordlist: {
|
wordlist: {
|
||||||
|
Loading…
Reference in New Issue
Block a user