halbot 1990.1.10 → 1990.1.11

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/index.mjs CHANGED
@@ -63,6 +63,7 @@ const init = async (options) => {
63
63
  skillPath: options?.skillPath || skillPath,
64
64
  speech: _speech,
65
65
  });
66
+ _bot._.lang = options?.lang || 'English';
66
67
  _bot._.prompts = await fetchPrompts();
67
68
  return _bot;
68
69
  };
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.10",
4
+ "version": "1990.1.11",
5
5
  "private": false,
6
6
  "homepage": "https://github.com/Leask/halbot",
7
7
  "type": "module",
package/skills/engine.mjs CHANGED
@@ -3,6 +3,11 @@ import { bot, utilitas } from 'utilitas';
3
3
  let configuredAi;
4
4
 
5
5
  const action = async (ctx, next) => {
6
+ ctx.isDefaultAi = name => name === ctx.firstAi;
7
+ ctx.clear = () => (ctx.selectedAi || []).map(n => {
8
+ ctx._.ai[n].clear(ctx.chatId);
9
+ ctx.hello();
10
+ });
6
11
  ctx.firstAi = (configuredAi = Object.keys(ctx._.ai))[0];
7
12
  switch (ctx.session.config?.ai) {
8
13
  case '': ctx.selectedAi = [ctx.firstAi]; break;
@@ -11,11 +16,6 @@ const action = async (ctx, next) => {
11
16
  ? ctx.session.config?.ai : ctx.firstAi];
12
17
  }
13
18
  ctx.multiAi = ctx.selectedAi.length > 1;
14
- ctx.isDefaultAi = name => name === ctx.firstAi;
15
- ctx.clear = () => (ctx.selectedAi || []).map(n => {
16
- ctx._.ai[n].clear(ctx.chatId);
17
- ctx.hello();
18
- });
19
19
  await next();
20
20
  };
21
21
 
@@ -1,4 +1,4 @@
1
- import { bot } from 'utilitas';
1
+ import { bot, utilitas } from 'utilitas';
2
2
 
3
3
  // Inspired by:
4
4
  // https://github.com/yetone/bob-plugin-openai-translator/blob/main/src/main.js
@@ -14,8 +14,25 @@ const getPolishPrompt = () =>
14
14
 
15
15
  const action = async (ctx, next) => {
16
16
  switch (ctx.cmd.cmd) {
17
+ case 'lang':
18
+ if (!ctx.cmd.args) {
19
+ return await ctx.ok('Please specify a language.');
20
+ }
21
+ const cnf = {
22
+ ...ctx.session.config = {
23
+ ...ctx.session.config, ...ctx.config = {
24
+ lang: ctx.cmd.args,
25
+ hello: `Hello! I speak ${ctx.cmd.args}.`,
26
+ }
27
+ }
28
+ };
29
+ Object.keys(ctx.config).map(x => cnf[x] = `${cnf[x]} <-- SET`);
30
+ await ctx.map(cnf);
31
+ await utilitas.timeout(1000);
32
+ await ctx.hello();
33
+ break;
17
34
  case 'translate':
18
- ctx.overwrite(getTranslatePrompt(ctx.cmd.args || 'English'));
35
+ ctx.overwrite(getTranslatePrompt(ctx.cmd.args || ctx.session.config?.lang || ctx._.lang));
19
36
  break;
20
37
  case 'polish':
21
38
  ctx.overwrite(getPolishPrompt());
@@ -41,12 +58,15 @@ export const { run, priority, func, cmds, help } = {
41
58
  priority: 50,
42
59
  func: action,
43
60
  help: bot.lines([
61
+ 'Set your default language.',
44
62
  'Prompt the AI engine to translate or polish your text.',
45
- 'If `TO_LANG` is not specified, English is used by default.',
46
- 'Example: /translate français',
63
+ 'If `LANG` is not specified, English is used by default.',
64
+ 'Example 1: /lang Français',
65
+ 'Example 2: /translate Chinese',
47
66
  ]),
48
67
  cmds: {
49
- translate: 'Translate your text to any language: /translate `TO_LANG`',
68
+ lang: 'Set your default language: /lang `LANG`',
69
+ translate: 'Translate your text to any language: /translate `LANG`',
50
70
  polish: 'Polish your text.',
51
71
  toen: 'Translate your text to English.',
52
72
  tofr: 'Translate your text to French.',