halbot 1993.2.66 → 1993.2.67

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/skills/70_chat.mjs +11 -7
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "halbot",
3
3
  "description": "Just another `ChatGPT` / `Gemini` / `Ollama` Telegram bob, which is simple design, easy to use, extendable and fun.",
4
- "version": "1993.2.66",
4
+ "version": "1993.2.67",
5
5
  "private": false,
6
6
  "homepage": "https://github.com/Leask/halbot",
7
7
  "type": "module",
@@ -6,11 +6,14 @@ const [joinL1, joinL2] = [a => a.join(LN2), a => a.join(LN2)];
6
6
  const log = content => utilitas.log(content, import.meta.url);
7
7
 
8
8
  const action = async (ctx, next) => {
9
- const ais = await alan.getAi(null, { all: true });
10
9
  if (!ctx.prompt && !ctx.carry.attachments.length) { return await next(); }
11
- const [YOU, msgs, tts, rsm, pms, extra, lock]
12
- = [`${ctx.avatar} You:`, {}, {}, {}, [], { buttons: [] }, 1000 * 5];
13
- let [lastMsg, lastSent, references, audio] = [null, 0, null, null];
10
+ let [
11
+ ais, YOU, msgs, tts, rsm, pms, extra, lock, sResp, lastMsg, lastSent,
12
+ references, audio
13
+ ] = [
14
+ await alan.getAi(null, { all: true }), `${ctx.avatar} You:`, {}, {},
15
+ {}, [], { buttons: [] }, 1000 * 5, null, null, 0, null, null,
16
+ ];
14
17
  const packMsg = options => {
15
18
  const said = !options?.tts && ctx.result ? ctx.result : '';
16
19
  const packed = [
@@ -42,12 +45,12 @@ const action = async (ctx, next) => {
42
45
  label: `❎ End context: \`${cmd}\``, text: '/clear',
43
46
  }));
44
47
  }
45
- const resp = await ctx.ok(curMsg, {
48
+ sResp = await ctx.ok(curMsg, {
46
49
  ...ctx.carry.keyboards ? { keyboards: ctx.carry.keyboards } : {},
47
50
  md: true, ...extra, ...options || {},
48
51
  });
49
52
  lastSent = curTime;
50
- return resp;
53
+ return sResp;
51
54
  };
52
55
  ctx.carry.threadInfo.length || await ok(onProgress);
53
56
  for (const n of ctx.selectedAi) {
@@ -79,7 +82,8 @@ const action = async (ctx, next) => {
79
82
  })(n));
80
83
  }
81
84
  await Promise.all(pms);
82
- await ok({ final: true });
85
+ if (Object.values(msgs).join('').trim()) { await ok({ final: true }); }
86
+ else { await ctx.deleteMessage(sResp[0].message_id); }
83
87
  ctx.tts = audio || packMsg({ tts: true });
84
88
  await next();
85
89
  };