diff --git a/lib/bot.mjs b/lib/bot.mjs index 2df2a80..958c937 100644 --- a/lib/bot.mjs +++ b/lib/bot.mjs @@ -775,13 +775,18 @@ const subconscious = [{ }, }, { run: true, priority: -8840, name: 'configuration', func: async (ctx, next) => { + let parsed = null; switch (ctx.cmd.cmd) { + case 'toggle': + parsed = {}; + Object.keys(parseArgs(ctx.cmd.args)).map(x => + parsed[x] = !ctx.session.config[x]); case 'set': try { const _config = { ...ctx.session.config = { ...ctx.session.config, - ...ctx.config = parseArgs(ctx.cmd.args), + ...ctx.config = parsed || parseArgs(ctx.cmd.args), } }; assert(countKeys(ctx.config), 'No option matched.'); @@ -804,6 +809,7 @@ const subconscious = [{ 'Configure the bot by UNIX/Linux CLI style.', 'Using [node:util.parseArgs](https://nodejs.org/docs/latest-v21.x/api/util.html#utilparseargsconfig) to parse arguments.', ]), cmds: { + toggle: 'Toggle configurations. Only works for boolean values.', set: 'Usage: /set --`OPTION` `VALUE` -`SHORT`', reset: 'Reset all configurations. Only erase `session.config`.', factory: 'Factory reset all memory areas. Erase the whole `session`.',