halbot 1993.2.57 → 1993.2.58

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` / `Gemini` / `Ollama` Telegram bob, which is simple design, easy to use, extendable and fun.",
4
- "version": "1993.2.57",
4
+ "version": "1993.2.58",
5
5
  "private": false,
6
6
  "homepage": "https://github.com/Leask/halbot",
7
7
  "type": "module",
@@ -51,7 +51,7 @@
51
51
  "pgvector": "^0.2.0",
52
52
  "telegraf": "^4.16.3",
53
53
  "tesseract.js": "^6.0.0",
54
- "utilitas": "^1999.1.8",
54
+ "utilitas": "^1999.1.9",
55
55
  "youtube-transcript": "^1.2.1"
56
56
  }
57
57
  }
@@ -12,8 +12,9 @@ const [BOT, BOTS, LN2] = [`${bot.EMOJI_BOT} `, {
12
12
 
13
13
  const action = async (ctx, next) => {
14
14
  if (!ctx.prompt && !ctx.carry.attachments.length) { return await next(); }
15
- const [YOU, msgs, tts, rsm, pms, extra, firstResp, images] = [
16
- `${ctx.avatar} You:`, {}, {}, {}, [], { buttons: [] }, Date.now(), []
15
+ const [YOU, msgs, tts, rsm, pms, extra, firstResp, lock] = [
16
+ `${ctx.avatar} You:`, {}, {}, {}, [], { buttons: [] }, Date.now(),
17
+ 1000 * 5
17
18
  ];
18
19
  let [lastMsg, lastSent, references, audio] = [null, 0, null, null];
19
20
  const packMsg = options => {
@@ -35,10 +36,9 @@ const action = async (ctx, next) => {
35
36
  const ok = async options => {
36
37
  const [curTime, curMsg] = [Date.now(), packMsg(options)];
37
38
  if (options?.onProgress && (
38
- (curTime - lastSent) < (ctx.limit * (curTime - firstResp > 1000 * 60 ? 2 : 1))
39
- || lastMsg === curMsg
39
+ curTime - lastSent < ctx.limit || lastMsg === curMsg
40
40
  )) { return; }
41
- [lastSent, lastMsg] = [curTime, curMsg];
41
+ [lastSent, lastMsg] = [curTime + lock, curMsg];
42
42
  const cmd = ctx.session.context?.cmd;
43
43
  if (options?.final) {
44
44
  (references?.links || []).map((x, i) => extra.buttons.push({
@@ -48,10 +48,12 @@ const action = async (ctx, next) => {
48
48
  label: `❎ End context: \`${cmd}\``, text: '/clear',
49
49
  }));
50
50
  }
51
- return await ctx.ok(curMsg, {
51
+ const resp = await ctx.ok(curMsg, {
52
52
  ...ctx.carry.keyboards ? { keyboards: ctx.carry.keyboards } : {},
53
53
  md: true, ...extra, ...options || {},
54
54
  });
55
+ lastSent = curTime;
56
+ return resp;
55
57
  };
56
58
  ctx.carry.threadInfo.length || await ok(onProgress);
57
59
  for (const n of ctx.selectedAi) {