diff --git a/src/commands/CommandHandler.ts b/src/commands/CommandHandler.ts index 81e6188..95de555 100644 --- a/src/commands/CommandHandler.ts +++ b/src/commands/CommandHandler.ts @@ -21,6 +21,7 @@ import { execDumpRulesCommand } from "./DumpRulesCommand"; import { LogService, RichReply } from "matrix-bot-sdk"; import * as htmlEscape from "escape-html"; import { execSyncCommand } from "./SyncCommand"; +import { execPermissionCheckCommand } from "./PermissionCheckCommand"; export const COMMAND_PREFIX = "!mjolnir"; @@ -39,6 +40,8 @@ export function handleCommand(roomId: string, event: any, mjolnir: Mjolnir) { return execDumpRulesCommand(roomId, event, mjolnir); } else if (parts[1] === 'sync') { return execSyncCommand(roomId, event, mjolnir); + } else if (parts[1] === 'verify') { + return execPermissionCheckCommand(roomId, event, mjolnir); } else { // Help menu const menu = "" + @@ -48,6 +51,7 @@ export function handleCommand(roomId: string, event: any, mjolnir: Mjolnir) { "!mjolnir unban - Removes an entity from the ban list\n" + "!mjolnir rules - Lists the rules currently in use by Mjolnir\n" + "!mjolnir sync - Force updates of all lists and re-apply rules\n" + + "!mjolnir verify - Ensures Mjolnir can moderate all your rooms\n" + "!mjolnir help - This menu\n"; const html = `Mjolnir help:
${htmlEscape(menu)}
`; const text = `Mjolnir help:\n${menu}`; diff --git a/src/commands/PermissionCheckCommand.ts b/src/commands/PermissionCheckCommand.ts new file mode 100644 index 0000000..bc9e032 --- /dev/null +++ b/src/commands/PermissionCheckCommand.ts @@ -0,0 +1,22 @@ +/* +Copyright 2019 The Matrix.org Foundation C.I.C. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +import { Mjolnir } from "../Mjolnir"; + +// !mjolnir verify +export async function execPermissionCheckCommand(roomId: string, event: any, mjolnir: Mjolnir) { + return mjolnir.verifyPermissions(); +}