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 +1 -1
- package/index.mjs +1 -0
- package/package.json +3 -3
- package/skills/ai.mjs +14 -2
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(
|
|
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
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.
|
|
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.
|
|
34
|
+
"@waylaidwanderer/chatgpt-api": "^1.32.10",
|
|
35
35
|
"telegraf": "^4.12.2",
|
|
36
|
-
"utilitas": "^1992.4.
|
|
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
|
|
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];
|