halbot 1990.1.53 → 1990.1.55

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "halbot",
3
3
  "description": "Just another ChatGPT/Bing Chat Telegram bob, which is simple design, easy to use, extendable and fun.",
4
- "version": "1990.1.53",
4
+ "version": "1990.1.55",
5
5
  "private": false,
6
6
  "homepage": "https://github.com/Leask/halbot",
7
7
  "type": "module",
@@ -39,7 +39,7 @@
39
39
  "jsdom": "^21.1.1",
40
40
  "mysql2": "^3.2.0",
41
41
  "telegraf": "^4.12.2",
42
- "utilitas": "^1993.3.39",
42
+ "utilitas": "^1993.3.40",
43
43
  "youtube-transcript": "^1.0.5"
44
44
  }
45
45
  }
package/skills/engine.mjs CHANGED
@@ -1,5 +1,9 @@
1
1
  import { bot, utilitas } from 'utilitas';
2
2
 
3
+ const [balanced, on] = ['balanced', 'on'];
4
+ const bingTones = [balanced, 'creative', 'precise'];
5
+ const binaryStr = [on, 'off'];
6
+
3
7
  let configuredAi;
4
8
 
5
9
  const action = async (ctx, next) => {
@@ -19,7 +23,7 @@ const action = async (ctx, next) => {
19
23
  await next();
20
24
  };
21
25
 
22
- const validate = val => {
26
+ const validateAi = val => {
23
27
  assert(configuredAi, 'Preparing data for this option. Please try later.');
24
28
  for (let name of [...configuredAi, '', '@']) {
25
29
  if (utilitas.insensitiveCompare(val, name)) { return name; }
@@ -27,6 +31,12 @@ const validate = val => {
27
31
  utilitas.throwError('No AI engine matched.');
28
32
  };
29
33
 
34
+ const validateTone = val => {
35
+ val = utilitas.trim(val, { case: 'LOW' });
36
+ assert([...bingTones.includes(val), ''], 'Unsupported tone-style.');
37
+ return val;
38
+ };
39
+
30
40
  export const { run, priority, func, help, args } = {
31
41
  run: true,
32
42
  priority: 10,
@@ -40,6 +50,8 @@ export const { run, priority, func, help, args } = {
40
50
  '¶ Tweak enhanced output rendering.',
41
51
  'Example 1: /set --render on',
42
52
  'Example 2: /set --render off',
53
+ '¶ Set tone-style for Bing.',
54
+ "Tip 4: Set `tone=''` to use default tone-style.",
43
55
  ]),
44
56
  args: {
45
57
  hello: {
@@ -49,12 +61,17 @@ export const { run, priority, func, help, args } = {
49
61
  ai: {
50
62
  type: 'string', short: 'a', default: '',
51
63
  desc: "`(ChatGPT, Bing, '', @)` Select AI engine.",
52
- validate,
64
+ validate: validateAi,
53
65
  },
54
66
  render: {
55
- type: 'string', short: 'r', default: 'on',
56
- desc: '`(on, off)` Enable/Disable enhanced output rendering.',
67
+ type: 'string', short: 'r', default: on,
68
+ desc: `\`(${binaryStr.join(', ')})\` Enable/Disable enhanced output rendering.`,
57
69
  validate: utilitas.humanReadableBoolean,
58
70
  },
71
+ tone: {
72
+ type: 'string', short: 't', default: balanced,
73
+ desc: `\`(${bingTones.join(', ')})\` Set tone-style for Bing.`,
74
+ validate: validateTone,
75
+ },
59
76
  },
60
77
  };
@@ -29,7 +29,11 @@ const action = async (ctx, next) => {
29
29
  ctx.text = utilitas.trim(ctx.text);
30
30
  additionInfo.filter(x => x).length && (ctx.text += '...');
31
31
  // next
32
- ctx.carry = { session: ctx.chatId, context: ctx.context };
32
+ ctx.carry = {
33
+ session: ctx.chatId,
34
+ context: ctx.context,
35
+ toneStyle: ctx.session.config?.tone,
36
+ };
33
37
  await next();
34
38
  };
35
39