mirror of
https://github.com/matrix-org/mjolnir.git
synced 2024-10-01 01:36:06 -04:00
Add a command to perform permission checks
This commit is contained in:
parent
7bd23a17d9
commit
83e74af525
@ -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 <user|room|server> <glob> - 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 = `<b>Mjolnir help:</b><br><pre><code>${htmlEscape(menu)}</code></pre>`;
|
||||
const text = `Mjolnir help:\n${menu}`;
|
||||
|
22
src/commands/PermissionCheckCommand.ts
Normal file
22
src/commands/PermissionCheckCommand.ts
Normal file
@ -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();
|
||||
}
|
Loading…
Reference in New Issue
Block a user