mirror of
https://github.com/the-draupnir-project/Draupnir.git
synced 2026-07-29 06:49:21 +00:00
Add draupnir command to switch to safe mode.
Works, but safe mode isn't hooked up to respond to any events.
This commit is contained in:
@@ -47,6 +47,7 @@ import {
|
||||
DraupnirWatchPolicyRoomCommand,
|
||||
} from "./WatchUnwatchCommand";
|
||||
import { DraupnirTopLevelCommands } from "./DraupnirCommandTable";
|
||||
import { DraupnirSafeModeCommand } from "./SafeModeCommand";
|
||||
|
||||
// TODO: These commands should all be moved to subdirectories tbh and this
|
||||
// should be split like an index file for each subdirectory.
|
||||
@@ -88,6 +89,7 @@ const DraupnirCommands = new StandardCommandTable("draupnir")
|
||||
.internCommand(DraupnirRoomsRemoveCommand, ["rooms", "remove"])
|
||||
.internCommand(DraupnirListRulesCommand, ["rules"])
|
||||
.internCommand(DraupnirRulesMatchingCommand, ["rules", "matching"])
|
||||
.internCommand(DraupnirSafeModeCommand, ["safe", "mode"])
|
||||
.internCommand(DraupnirDisplaynameCommand, ["displayname"])
|
||||
.internCommand(DraupnirSetPowerLevelCommand, ["powerlevel"])
|
||||
.internCommand(DraupnirStatusCommand, ["status"])
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
// SPDX-FileCopyrightText: 2024 Gnuxie <Gnuxie@protonmail.com>
|
||||
//
|
||||
// SPDX-License-Identifier: AFL-3.0
|
||||
|
||||
import { describeCommand } from "@the-draupnir-project/interface-manager";
|
||||
import { SafeModeDraupnir } from "../safemode/DraupnirSafeMode";
|
||||
import { Result } from "@gnuxie/typescript-result";
|
||||
import { Draupnir } from "../Draupnir";
|
||||
import { SafeModeReason } from "../safemode/SafeModeCause";
|
||||
import { DraupnirInterfaceAdaptor } from "./DraupnirCommandPrerequisites";
|
||||
|
||||
export const DraupnirSafeModeCommand = describeCommand({
|
||||
summary: "Enter into safe mode.",
|
||||
parameters: [],
|
||||
async executor({
|
||||
safeModeToggle,
|
||||
}: Draupnir): Promise<Result<SafeModeDraupnir>> {
|
||||
return safeModeToggle.switchToSafeMode({
|
||||
reason: SafeModeReason.ByRequest,
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
DraupnirInterfaceAdaptor.describeRenderer(DraupnirSafeModeCommand, {
|
||||
isAlwaysSupposedToUseDefaultRenderer: true,
|
||||
});
|
||||
Reference in New Issue
Block a user