halbot 1989.6.30 → 1989.6.32

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 Telegram bob.",
4
- "version": "1989.6.30",
4
+ "version": "1989.6.32",
5
5
  "private": false,
6
6
  "homepage": "https://github.com/Leask/halbot",
7
7
  "type": "module",
@@ -33,6 +33,6 @@
33
33
  "@google-cloud/text-to-speech": "^4.2.1",
34
34
  "@waylaidwanderer/chatgpt-api": "^1.32.10",
35
35
  "telegraf": "^4.12.2",
36
- "utilitas": "^1992.4.39"
36
+ "utilitas": "^1992.4.40"
37
37
  }
38
38
  }
package/skills/ai.mjs CHANGED
@@ -2,29 +2,30 @@ import { utilitas } from 'utilitas';
2
2
 
3
3
  const onProgress = { onProgress: true };
4
4
  const [YOU, BOT, LN2] = ['😸 You:', '🤖️ ', '\n\n'];
5
- const [joinL1, joinL2] = [a => a.join('${LN2}---${LN2}'), a => a.join(LN2)];
5
+ const [joinL1, joinL2] = [a => a.join(`${LN2}---${LN2}`), a => a.join(LN2)];
6
6
  const enrich = name => name === 'Bing' ? `${name} (Sydney)` : name;
7
7
 
8
8
  const action = async (ctx, next) => {
9
- if (ctx.end || !ctx.text) { return await next(); }
9
+ if (!ctx.text) { return await next(); }
10
10
  const [multiAi, msgs, tts, pms, extra]
11
11
  = [ctx.session.ai.size > 1, {}, {}, [], {}];
12
12
  let [lastMsg, lastSent] = ['', 0];
13
- const packMsg = (options) => {
14
- const packed = [...ctx.stt ? joinL2([YOU, ctx.stt]) : []];
13
+ const packMsg = options => {
14
+ const packed = [...ctx.overwrite ? [joinL2([YOU, ctx.overwrite])] : []];
15
15
  const source = options?.tts ? tts : msgs;
16
16
  for (let name of ctx.session.ai.size ? ctx.session.ai : [ctx.firstAi]) {
17
17
  const defaultAi = name === ctx.firstAi;
18
18
  packed.push(joinL2([
19
- ...multiAi || !defaultAi || ctx.stt ? [`${BOT}${enrich(name)}:`] : [],
19
+ ...multiAi || !defaultAi || ctx.overwrite ? [`${BOT}${enrich(name)}:`] : [],
20
20
  options?.onProgress ? (
21
- source[name] ? `${source[name].trim()} |` : '...'
21
+ source[name] ? `${source[name].trim()} █` : '💬'
22
22
  ) : (source[name] || ''),
23
23
  ]));
24
24
  }
25
+ console.log(packed);
25
26
  return joinL1(packed);
26
27
  };
27
- const ok = async (options) => {
28
+ const ok = async options => {
28
29
  const [curTime, curMsg] = [Date.now(), packMsg(options)];
29
30
  if (options?.onProgress && (
30
31
  curTime - lastSent < ctx.limit || lastMsg === curMsg
package/skills/cmd.mjs CHANGED
@@ -3,7 +3,7 @@ import { utilitas } from 'utilitas';
3
3
  const matchReg = /^\/([^\ ]*)(.*)$/ig;
4
4
 
5
5
  const action = async (ctx, next) => {
6
- if (ctx.end || !ctx.text) { return await next(); }
6
+ if (!ctx.text) { return await next(); }
7
7
  ctx.session.ai || (ctx.session.ai = new Set());
8
8
  const curAi = new Set();
9
9
  ctx.cmd = ctx.text.split('\n')?.[0]?.replace(matchReg, '$1');
@@ -6,7 +6,7 @@ const getPolishPrompt = () => // https://github.com/yetone/bob-plugin-openai-pol
6
6
  + ' Please note that you need to list the changes and briefly explain why: ';
7
7
 
8
8
  const action = async (ctx, next) => {
9
- if (ctx.end || !ctx.text) { return await next(); }
9
+ if (!ctx.text) { return await next(); }
10
10
  switch (ctx.cmd) {
11
11
  case '2en':
12
12
  ctx.text = ctx.text.replace(`/${ctx.cmd}`, getTranslatePrompt('English'));