halbot 1995.1.3 → 1995.1.5
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 +6 -5
- package/pipeline/010_broca.mjs +16 -24
- package/pipeline/030_echo.mjs +1 -1
- package/pipeline/090_ai.mjs +8 -6
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "halbot",
|
|
3
3
|
"description": "Just another AI powered Telegram bot, which is simple design, easy to use, extendable and fun.",
|
|
4
|
-
"version": "1995.1.
|
|
4
|
+
"version": "1995.1.5",
|
|
5
5
|
"private": false,
|
|
6
6
|
"homepage": "https://github.com/Leask/halbot",
|
|
7
7
|
"type": "module",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"@ffmpeg-installer/ffmpeg": "^1.1.0",
|
|
33
33
|
"@ffprobe-installer/ffprobe": "^2.1.2",
|
|
34
34
|
"@google-cloud/discoveryengine": "^2.5.2",
|
|
35
|
-
"@google/genai": "^1.
|
|
35
|
+
"@google/genai": "^1.34.0",
|
|
36
36
|
"@mozilla/readability": "^0.6.0",
|
|
37
37
|
"fluent-ffmpeg": "^2.1.3",
|
|
38
38
|
"google-gax": "^5.0.6",
|
|
@@ -40,14 +40,15 @@
|
|
|
40
40
|
"jsdom": "^27.3.0",
|
|
41
41
|
"lorem-ipsum": "^2.0.8",
|
|
42
42
|
"mime": "^4.1.0",
|
|
43
|
-
"mysql2": "^3.
|
|
43
|
+
"mysql2": "^3.16.0",
|
|
44
44
|
"office-text-extractor": "^3.0.3",
|
|
45
|
-
"openai": "^6.
|
|
45
|
+
"openai": "^6.15.0",
|
|
46
46
|
"pg": "^8.16.3",
|
|
47
47
|
"pgvector": "^0.2.1",
|
|
48
48
|
"telegraf": "^4.16.3",
|
|
49
|
+
"tellegram": "^1.1.2",
|
|
49
50
|
"tesseract.js": "^7.0.0",
|
|
50
|
-
"utilitas": "^2001.1.
|
|
51
|
+
"utilitas": "^2001.1.84",
|
|
51
52
|
"youtube-transcript": "^1.2.1"
|
|
52
53
|
}
|
|
53
54
|
}
|
package/pipeline/010_broca.mjs
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { alan, bot, hal, uoid, utilitas } from '../index.mjs';
|
|
2
|
+
import { paginate } from 'tellegram';
|
|
2
3
|
|
|
3
4
|
const _name = 'Broca';
|
|
4
5
|
const [PRIVATE_LIMIT, GROUP_LIMIT] = [60 / 60, 60 / 20].map(x => x * 1000);
|
|
5
6
|
const log = (c, o) => utilitas.log(c, _name, { time: 1, ...o || {} });
|
|
6
7
|
const getKey = s => s?.toLowerCase?.()?.startsWith?.('http') ? 'url' : 'source';
|
|
7
8
|
const isMarkdownError = e => e?.description?.includes?.("can't parse entities");
|
|
8
|
-
|
|
9
|
-
const [CALLBACK_LIMIT, parse_mode] = [30, bot.parse_mode];
|
|
9
|
+
const [CALLBACK_LIMIT, parse_mode] = [30, bot.PARSE_MODE_MD_V2];
|
|
10
10
|
|
|
11
11
|
const KNOWN_UPDATE_TYPES = [
|
|
12
12
|
'callback_query', 'channel_post', 'edited_message', 'message',
|
|
@@ -54,8 +54,8 @@ const resp = async (ctx, text, md, extra) => {
|
|
|
54
54
|
resp = await (extra?.reply_parameters?.message_id
|
|
55
55
|
? ctx.replyWithMarkdown(text, { parse_mode, ...extra })
|
|
56
56
|
: ctx.sendMessage(text, { parse_mode, ...extra }));
|
|
57
|
-
} catch (err) {
|
|
58
|
-
|
|
57
|
+
} catch (err) {
|
|
58
|
+
log(err);
|
|
59
59
|
await ctx.timeout();
|
|
60
60
|
}
|
|
61
61
|
}
|
|
@@ -81,8 +81,8 @@ const edit = async (ctx, lastMsgId, text, md, extra) => {
|
|
|
81
81
|
resp = await ctx.telegram.editMessageText(
|
|
82
82
|
ctx._.chatId, lastMsgId, '', text, { parse_mode, ...extra }
|
|
83
83
|
);
|
|
84
|
-
} catch (err) {
|
|
85
|
-
|
|
84
|
+
} catch (err) {
|
|
85
|
+
log(err);
|
|
86
86
|
await ctx.timeout();
|
|
87
87
|
}
|
|
88
88
|
}
|
|
@@ -125,7 +125,7 @@ const ctxExt = ctx => {
|
|
|
125
125
|
ctx.edit = async (lastMsgId, text, md, extra) =>
|
|
126
126
|
await edit(ctx, lastMsgId, text, md, extra);
|
|
127
127
|
ctx.ok = async (message, options) => {
|
|
128
|
-
let pages =
|
|
128
|
+
let pages = paginate(message, options);
|
|
129
129
|
const extra = ctx.getExtra(options);
|
|
130
130
|
const [pageIds, pageMap] = [[], {}];
|
|
131
131
|
options?.pageBreak || ctx._.done.filter(x => x).map(x => {
|
|
@@ -135,22 +135,13 @@ const ctxExt = ctx => {
|
|
|
135
135
|
for (let i in pages) {
|
|
136
136
|
const lastPage = ~~i === pages.length - 1;
|
|
137
137
|
const shouldExtra = options?.lastMessageId || lastPage;
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
if (
|
|
141
|
-
|
|
142
|
-
} else if (options?.onProgress) { // progress: ongoing, edit text
|
|
143
|
-
await ctx.edit(
|
|
144
|
-
pageIds[~~i], pages[i], false, shouldExtra ? extra : {}
|
|
145
|
-
);
|
|
146
|
-
} else if (options?.lastMessageId || pageIds[~~i]) { // progress: final, edit markdown
|
|
147
|
-
await ctx.edit(
|
|
148
|
-
options?.lastMessageId || pageIds[~~i],
|
|
149
|
-
pages[i], true, shouldExtra ? extra : {}
|
|
150
|
-
);
|
|
151
|
-
} else { // never progress, reply markdown
|
|
152
|
-
await ctx.resp(pages[i], true, extra);
|
|
138
|
+
const _extra = shouldExtra ? extra : {};
|
|
139
|
+
const lastMsgId = ~~(options?.lastMessageId || pageIds[~~i]);
|
|
140
|
+
if (lastMsgId && pageMap[lastMsgId]?.text === pages[i]) {
|
|
141
|
+
continue;
|
|
153
142
|
}
|
|
143
|
+
await (lastMsgId ? ctx.edit(lastMsgId, pages[i], options?.md, _extra) // ongoing, edit
|
|
144
|
+
: ctx.resp(pages[i], options?.md, _extra)); // new page, reply
|
|
154
145
|
await ctx.timeout();
|
|
155
146
|
}
|
|
156
147
|
return ctx._.done;
|
|
@@ -256,6 +247,7 @@ const action = async (ctx, next) => {
|
|
|
256
247
|
await ctx.shouldReply(errStr);
|
|
257
248
|
};
|
|
258
249
|
|
|
259
|
-
export const { name, run, priority, func } = {
|
|
260
|
-
|
|
250
|
+
export const { _NEED, name, run, priority, func } = {
|
|
251
|
+
_NEED: ['telegramifyMarkdown'], name: _name,
|
|
252
|
+
run: true, priority: 10, func: action,
|
|
261
253
|
};
|
package/pipeline/030_echo.mjs
CHANGED
|
@@ -38,7 +38,7 @@ const action = async (ctx, next) => {
|
|
|
38
38
|
await ctx.ok(bot.EMOJI_THINKING);
|
|
39
39
|
for (let i = 0; i < 2; i++) {
|
|
40
40
|
await ctx.timeout();
|
|
41
|
-
await ctx.ok(ipsum(), { ...extra,
|
|
41
|
+
await ctx.ok(ipsum(), { ...extra, processing: true });
|
|
42
42
|
}
|
|
43
43
|
await ctx.timeout();
|
|
44
44
|
await ctx.ok(ipsum(), { ...extra, md });
|
package/pipeline/090_ai.mjs
CHANGED
|
@@ -5,17 +5,19 @@ const TOP = 'top';
|
|
|
5
5
|
|
|
6
6
|
const listAIs = async ctx => {
|
|
7
7
|
const lastMessageId = ctx?.update?.callback_query?.message?.message_id;
|
|
8
|
-
const message =
|
|
9
|
-
+ hal.uList(Object.entries(alan.FEATURE_ICONS).
|
|
10
|
-
x =>
|
|
11
|
-
)
|
|
8
|
+
const message = `*Time:* \n${new Date().toLocaleString()}\n\n`
|
|
9
|
+
+ `*Features:*\n` + hal.uList(Object.entries(alan.FEATURE_ICONS).filter(
|
|
10
|
+
x => x[0] !== 'hidden'
|
|
11
|
+
).map(
|
|
12
|
+
x => `${x[1]} \`${x[0]}\``
|
|
13
|
+
)) + `\n\n*AI${ais.length > 0 ? 's' : ''}:*\n`;
|
|
12
14
|
const buttons = ais.map((x, i) => ({
|
|
13
15
|
label: `${ctx._.session.config?.ai === x.id
|
|
14
16
|
|| (!ctx._.session.config?.ai && i === 0) ? `${hal.CHECK} `
|
|
15
|
-
: ''}${x.
|
|
17
|
+
: ''}${x.label}`,
|
|
16
18
|
text: `/set --ai=${x.id}`,
|
|
17
19
|
}));
|
|
18
|
-
return await ctx.ok(message, { lastMessageId, buttons });
|
|
20
|
+
return await ctx.ok(message, { lastMessageId, buttons, md: true });
|
|
19
21
|
};
|
|
20
22
|
|
|
21
23
|
const action = async (ctx, next) => {
|