Skip to content

Commit

Permalink
Frozen @ Sat Jul 27 05:02:00 EDT 2024
Browse files Browse the repository at this point in the history
  • Loading branch information
Leask committed Jul 27, 2024
1 parent a622458 commit e60dc44
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/bot.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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.');
Expand All @@ -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`.',
Expand Down

0 comments on commit e60dc44

Please sign in to comment.