mirror of
https://github.com/legop3/MultiRoombaRover.git
synced 2026-11-14 18:58:49 -05:00
this is a big slop that might backfire lol... new config system and UI!
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
// Operator Command Configuration
|
||||
// Purpose: Owns transport-neutral command names used by site chat and optional integrations.
|
||||
// Scope: Prevents Discord configuration from defining whether core server commands can be parsed.
|
||||
const { loadConfig } = require('../../helpers/configLoader');
|
||||
const { loadConfig } = require('../../configuration');
|
||||
|
||||
function getCommandConfig(config = loadConfig()) {
|
||||
const commandConfig = config.commands || {};
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
// Operator Command Configuration
|
||||
// Purpose: Defines the shared command prefix and optional bare time-status command.
|
||||
// Scope: Contains configuration metadata only and never builds command handlers.
|
||||
const { strictObject, string, nullableString } = require('../../configuration/schemaHelpers');
|
||||
|
||||
module.exports = {
|
||||
key: 'commands',
|
||||
defaultValue: { prefix: 'rs', timeStatusCommand: 'ts' },
|
||||
schema: strictObject({
|
||||
prefix: string({ minLength: 1, maxLength: 20 }),
|
||||
timeStatusCommand: nullableString({ description: 'Leave empty to disable the bare shortcut.', maxLength: 20 }),
|
||||
}, { title: 'Commands', required: ['prefix', 'timeStatusCommand'] }),
|
||||
};
|
||||
@@ -102,7 +102,7 @@ function createCommandHandlers(deps) {
|
||||
const mode = getMode();
|
||||
const commandDefinition = registry[action];
|
||||
if (commandDefinition?.requiredFeature && !deps.isFeatureEnabled(commandDefinition.requiredFeature)) {
|
||||
await request.reply({ content: `${commandDefinition.unavailableLabel || commandDefinition.requiredFeature} feature is not configured.` });
|
||||
await request.reply({ content: `${commandDefinition.unavailableLabel || commandDefinition.requiredFeature} feature is disabled.` });
|
||||
return;
|
||||
}
|
||||
// Actions in this set can change operational safety or access policy, so
|
||||
|
||||
@@ -127,7 +127,7 @@ test('status and help survive lockdown', async () => {
|
||||
|
||||
test('a disabled required feature is reported before any permission check', async () => {
|
||||
const run = createRouter({ featureEnabled: false });
|
||||
assert.match(await run('rs lights on', nonAdmin), /Home Assistant feature is not configured/);
|
||||
assert.match(await run('rs lights on', nonAdmin), /Home Assistant feature is disabled/);
|
||||
});
|
||||
|
||||
test('green mode remains available without optional Home Assistant features', async () => {
|
||||
|
||||
Reference in New Issue
Block a user