utilitas 1999.1.26 → 1999.1.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/dist/utilitas.lite.mjs +1 -1
- package/dist/utilitas.lite.mjs.map +1 -1
- package/lib/alan.mjs +1 -0
- package/lib/bot.mjs +6 -6
- package/lib/manifest.mjs +1 -1
- package/lib/utilitas.mjs +6 -2
- package/package.json +1 -1
package/lib/alan.mjs
CHANGED
package/lib/bot.mjs
CHANGED
|
@@ -425,7 +425,7 @@ const subconscious = [{
|
|
|
425
425
|
}, getExtra(ctx, options)));
|
|
426
426
|
ctx.audio = async (sr, op) => await ctx.media('replyWithAudio', sr, op);
|
|
427
427
|
ctx.image = async (sr, op) => await ctx.media('replyWithPhoto', sr, op);
|
|
428
|
-
ctx.sendConfig = async (obj, options) => await ctx.ok(prettyJson(
|
|
428
|
+
ctx.sendConfig = async (obj, options, _ctx) => await ctx.ok(prettyJson(
|
|
429
429
|
obj, { code: true, md: true }
|
|
430
430
|
), options);
|
|
431
431
|
ctx.speech = async (cnt, options) => {
|
|
@@ -890,13 +890,13 @@ const subconscious = [{
|
|
|
890
890
|
try {
|
|
891
891
|
const _config = {
|
|
892
892
|
...ctx.session.config = {
|
|
893
|
-
...ctx.session.config,
|
|
894
|
-
|
|
893
|
+
...ctx.session.config, ...ctx.config = parsed
|
|
894
|
+
|| await parseArgs(ctx.cmd.args, ctx),
|
|
895
895
|
}
|
|
896
896
|
};
|
|
897
897
|
assert(countKeys(ctx.config), 'No option matched.');
|
|
898
898
|
Object.keys(ctx.config).map(x => _config[x] += ' 🖋');
|
|
899
|
-
await ctx.sendConfig(_config);
|
|
899
|
+
await ctx.sendConfig(_config, null, ctx);
|
|
900
900
|
} catch (err) {
|
|
901
901
|
await ctx.er(err.message || err);
|
|
902
902
|
}
|
|
@@ -1036,7 +1036,7 @@ const establish = (bot, module, options) => {
|
|
|
1036
1036
|
} : module.func);
|
|
1037
1037
|
};
|
|
1038
1038
|
|
|
1039
|
-
const parseArgs = async args => {
|
|
1039
|
+
const parseArgs = async (args, ctx) => {
|
|
1040
1040
|
const { values, tokens } = _parseArgs({
|
|
1041
1041
|
args: splitArgs((args || '').replaceAll('—', '--')),
|
|
1042
1042
|
options: bot._.args, tokens: true
|
|
@@ -1044,7 +1044,7 @@ const parseArgs = async args => {
|
|
|
1044
1044
|
const result = {};
|
|
1045
1045
|
for (let x of tokens) {
|
|
1046
1046
|
result[x.name] = bot._.args[x.name]?.validate
|
|
1047
|
-
? await bot._.args[x.name].validate(values[x.name])
|
|
1047
|
+
? await bot._.args[x.name].validate(values[x.name], ctx)
|
|
1048
1048
|
: values[x.name];
|
|
1049
1049
|
}
|
|
1050
1050
|
return result;
|
package/lib/manifest.mjs
CHANGED
package/lib/utilitas.mjs
CHANGED
|
@@ -268,7 +268,9 @@ const assembleUrl = (url, componens) => {
|
|
|
268
268
|
|
|
269
269
|
const prettyJson = (object, opt) => {
|
|
270
270
|
let resp = JSON.stringify(object, opt?.replacer ?? null, ~~opt?.space || 2);
|
|
271
|
-
opt?.code ? (
|
|
271
|
+
opt?.code ? (
|
|
272
|
+
resp = renderCode(resp, { ...opt || {}, md: opt?.md && 'json' })
|
|
273
|
+
) : (opt?.log && console.log(resp));
|
|
272
274
|
return resp;
|
|
273
275
|
};
|
|
274
276
|
|
|
@@ -549,7 +551,9 @@ const renderCode = (code, options) => {
|
|
|
549
551
|
const resp = arrCode.map(
|
|
550
552
|
x => `${String(i++).padStart(bits, '0')} ${s} ${ensureString(x).replace('```', '\\`\\`\\`')}`
|
|
551
553
|
);
|
|
552
|
-
const output =
|
|
554
|
+
const output = (
|
|
555
|
+
options?.md ? `\`\`\`${options.md === true ? '' : options.md}\n` : ''
|
|
556
|
+
) + (options?.asArray ? resp : resp.join('\n')) + (options.md ? '\n```' : '');
|
|
553
557
|
options?.log && console.log(output);
|
|
554
558
|
return output;
|
|
555
559
|
};
|