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/lib/alan.mjs CHANGED
@@ -1514,6 +1514,7 @@ export {
1514
1514
  CODE_INTERPRETER,
1515
1515
  DEEPSEEK_R1,
1516
1516
  DEFAULT_MODELS,
1517
+ FEATURE_ICONS,
1517
1518
  FUNCTION,
1518
1519
  GEMINI_20_FLASH_THINKING,
1519
1520
  GEMINI_20_FLASH,
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
- ...ctx.config = parsed || await parseArgs(ctx.cmd.args),
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
@@ -1,7 +1,7 @@
1
1
  const manifest = {
2
2
  "name": "utilitas",
3
3
  "description": "Just another common utility for JavaScript.",
4
- "version": "1999.1.26",
4
+ "version": "1999.1.28",
5
5
  "private": false,
6
6
  "homepage": "https://github.com/Leask/utilitas",
7
7
  "main": "index.mjs",
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 ? (resp = renderCode(resp, opt)) : (opt?.log && console.log(resp));
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 = options?.asArray ? resp : resp.join('\n');
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
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "utilitas",
3
3
  "description": "Just another common utility for JavaScript.",
4
- "version": "1999.1.26",
4
+ "version": "1999.1.28",
5
5
  "private": false,
6
6
  "homepage": "https://github.com/Leask/utilitas",
7
7
  "main": "index.mjs",