halbot 1989.6.27 → 1989.6.29

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/bin/halbot.mjs CHANGED
@@ -27,6 +27,6 @@ const log = content => utilitas.log(content, import.meta.url);
27
27
  // })();
28
28
 
29
29
  try {
30
- const { config } = await storage.getConfig({ pack: { name: 'halbot' } });
30
+ const { config } = await storage.getConfig();
31
31
  await halbot(config);
32
32
  } catch (err) { debug ? utilitas.throwError(err) : log(err); }
package/index.mjs CHANGED
@@ -1,5 +1,6 @@
1
1
  import { bot, hal, speech, utilitas } from 'utilitas';
2
2
 
3
+ await utilitas.locate(utilitas.__(import.meta.url, 'package.json'));
3
4
  const skillPath = utilitas.__(import.meta.url, 'skills');
4
5
 
5
6
  const init = async (options) => {
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.27",
4
+ "version": "1989.6.29",
5
5
  "private": false,
6
6
  "homepage": "https://github.com/Leask/halbot",
7
7
  "type": "module",
@@ -31,8 +31,8 @@
31
31
  "dependencies": {
32
32
  "@google-cloud/speech": "^5.4.0",
33
33
  "@google-cloud/text-to-speech": "^4.2.1",
34
- "@waylaidwanderer/chatgpt-api": "^1.32.0",
34
+ "@waylaidwanderer/chatgpt-api": "^1.32.10",
35
35
  "telegraf": "^4.12.2",
36
- "utilitas": "^1992.4.6"
36
+ "utilitas": "^1992.4.38"
37
37
  }
38
38
  }
package/skills/ai.mjs CHANGED
@@ -7,7 +7,8 @@ const [joinL1, joinL2] = [a => a.join('${LN2}---${LN2}'), a => a.join(LN2)];
7
7
  const action = async (bot) => {
8
8
  bot.use(async (ctx, next) => {
9
9
  if (ctx.end || !ctx.text) { return await next(); }
10
- const [multiAi, msgs, tts, pms] = [ctx.session.ai.size > 1, {}, {}, []];
10
+ const [multiAi, msgs, tts, pms, extra]
11
+ = [ctx.session.ai.size > 1, {}, {}, [], {}];
11
12
  let [lastMsg, lastSent] = ['', 0];
12
13
  const packMsg = (options) => {
13
14
  const packed = [...ctx.stt ? joinL2([YOU, ctx.stt]) : []];
@@ -29,7 +30,7 @@ const action = async (bot) => {
29
30
  curTime - lastSent < ctx.limit || lastMsg === curMsg
30
31
  )) { return; }
31
32
  [lastSent, lastMsg] = [curTime, curMsg];
32
- return await ctx.ok(curMsg, options);
33
+ return await ctx.ok(curMsg, { ...options || {}, ...extra });
33
34
  };
34
35
  await ok(onProgress);
35
36
  for (let name of ctx.session.ai.size ? ctx.session.ai : [ctx.firstAi]) {
@@ -48,6 +49,17 @@ const action = async (bot) => {
48
49
  );
49
50
  msgs[name] = ctx.session.raw ? resp.response : resp.responseRendered;
50
51
  tts[name] = resp.spokenText;
52
+ if (resp.suggestedResponses) {
53
+ extra.reply_markup = {
54
+ inline_keyboard: resp.suggestedResponses.map(
55
+ text => [{
56
+ text, callback_data: JSON.stringify({ text: `/bing ${text}` })
57
+ }]
58
+ )
59
+ };
60
+ // button debug
61
+ // console.log(JSON.stringify(extra.reply_markup, null, 2));
62
+ }
51
63
  } catch (err) {
52
64
  msgs[name] = `[ERROR] ${err?.message || err}`;
53
65
  tts[name] = msgs[name];