halbot 1990.1.20 → 1990.1.21
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 +2 -2
- package/skills/chat.mjs +3 -4
- package/skills/poll.mjs +33 -0
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "halbot",
|
|
3
3
|
"description": "Just another ChatGPT/Bing Chat Telegram bob, which is simple design, easy to use, extendable and fun.",
|
|
4
|
-
"version": "1990.1.
|
|
4
|
+
"version": "1990.1.21",
|
|
5
5
|
"private": false,
|
|
6
6
|
"homepage": "https://github.com/Leask/halbot",
|
|
7
7
|
"type": "module",
|
|
@@ -36,6 +36,6 @@
|
|
|
36
36
|
"ioredis": "^5.3.1",
|
|
37
37
|
"mysql2": "^3.2.0",
|
|
38
38
|
"telegraf": "^4.12.2",
|
|
39
|
-
"utilitas": "^1993.2.
|
|
39
|
+
"utilitas": "^1993.2.3"
|
|
40
40
|
}
|
|
41
41
|
}
|
package/skills/chat.mjs
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { utilitas } from 'utilitas';
|
|
2
2
|
|
|
3
|
-
// @todo: consider using md v2, see https://core.telegram.org/bots/api#markdownv2-style.
|
|
4
|
-
|
|
5
3
|
const onProgress = { onProgress: true };
|
|
6
4
|
const [YOU, BOT, LN2] = ['😸 You:', '🤖️ ', '\n\n'];
|
|
7
5
|
const [joinL1, joinL2] = [a => a.join(LN2), a => a.join(LN2)];
|
|
@@ -13,7 +11,7 @@ const action = async (ctx, next) => {
|
|
|
13
11
|
const [msgs, ctxs, tts, pms, extra] = [{}, {}, {}, [], {}];
|
|
14
12
|
let [lastMsg, lastSent] = ['', 0];
|
|
15
13
|
const packMsg = options => {
|
|
16
|
-
const addition = !options?.tts && (ctx._text || ctx.action) ? (ctx.
|
|
14
|
+
const addition = !options?.tts && (ctx._text || ctx.action) ? (ctx.text || ctx.action) : '';
|
|
17
15
|
const packed = [...addition ? [joinL2([YOU, addition])] : []];
|
|
18
16
|
const source = options?.tts ? tts : msgs;
|
|
19
17
|
const pure = [];
|
|
@@ -64,12 +62,13 @@ const action = async (ctx, next) => {
|
|
|
64
62
|
}
|
|
65
63
|
await Promise.all(pms);
|
|
66
64
|
await ok();
|
|
65
|
+
ctx.responses = msgs;
|
|
67
66
|
ctx.tts = packMsg({ tts: true });
|
|
68
67
|
await next();
|
|
69
68
|
};
|
|
70
69
|
|
|
71
70
|
export const { run, priority, func } = {
|
|
72
71
|
run: true,
|
|
73
|
-
priority:
|
|
72
|
+
priority: 70,
|
|
74
73
|
func: action,
|
|
75
74
|
};
|
package/skills/poll.mjs
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { bot } from 'utilitas';
|
|
2
|
+
|
|
3
|
+
const action = async (ctx, next) => {
|
|
4
|
+
if (!ctx.update.message.poll) { return next(); }
|
|
5
|
+
ctx.text = bot.lines([
|
|
6
|
+
'Please help me select the best option in this poll.',
|
|
7
|
+
'Try your best to choose between these options.',
|
|
8
|
+
'If you know the answer, please select the best one and justify it.',
|
|
9
|
+
'If you do not have enough info to pick one, explain why.',
|
|
10
|
+
'If you can choose, put option id in the box brackets like [1].',
|
|
11
|
+
'',
|
|
12
|
+
'Question:',
|
|
13
|
+
ctx.update.message.poll.question,
|
|
14
|
+
'',
|
|
15
|
+
'Options:',
|
|
16
|
+
bot.oList(ctx.update.message.poll.options.map(x => x.text)),
|
|
17
|
+
]);
|
|
18
|
+
await next();
|
|
19
|
+
// let id;
|
|
20
|
+
// for (let key in ctx.responses) {
|
|
21
|
+
// for (let line of ctx.responses[key].split('\n')) {
|
|
22
|
+
// id = ~~line.match(/\[\d+\]/)?.[0]?.replace(/^\[(.*)\]$/i, '$1');
|
|
23
|
+
// if (id) { break; }
|
|
24
|
+
// }
|
|
25
|
+
// if (id) { break; }
|
|
26
|
+
// }
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export const { run, priority, func } = {
|
|
30
|
+
run: true,
|
|
31
|
+
priority: 60,
|
|
32
|
+
func: action,
|
|
33
|
+
};
|