Add a help command

This commit is contained in:
Travis Ralston 2019-09-27 16:12:53 -06:00
parent 4d16ff3e51
commit 149d6dfa2e

View File

@ -18,6 +18,8 @@ import { Mjolnir } from "../Mjolnir";
import { execStatusCommand } from "./StatusCommand";
import { execBanCommand, execUnbanCommand } from "./UnbanBanCommand";
import { execDumpRulesCommand } from "./DumpRulesCommand";
import { RichReply } from "matrix-bot-sdk";
import * as htmlEscape from "escape-html";
export const COMMAND_PREFIX = "!mjolnir";
@ -34,6 +36,18 @@ export function handleCommand(roomId: string, event: any, mjolnir: Mjolnir) {
} else if (parts[1] === 'rules') {
return execDumpRulesCommand(roomId, event, mjolnir);
} else {
// TODO: Help menu
// Help menu
const menu = "" +
"!mjolnir - Print status information\n" +
"!mjolnir status - Print status information\n" +
"!mjolnir ban <user|room|server> <glob> [reason] - Adds an entity to the ban list\n" +
"!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 help - This menu\n";
const html = `<b>Mjolnir help:</b><br><pre><code>${htmlEscape(menu)}</code></pre>`;
const text = `Mjolnir help:\n${menu}`;
const reply = RichReply.createFor(roomId, event, text, html);
reply["msgtype"] = "m.notice";
return mjolnir.client.sendMessage(roomId, reply);
}
}