halbot 1995.1.8 → 1995.1.9
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 AI powered Telegram bot, which is simple design, easy to use, extendable and fun.",
|
|
4
|
-
"version": "1995.1.
|
|
4
|
+
"version": "1995.1.9",
|
|
5
5
|
"private": false,
|
|
6
6
|
"homepage": "https://github.com/Leask/halbot",
|
|
7
7
|
"type": "module",
|
package/pipeline/010_broca.mjs
CHANGED
|
@@ -48,6 +48,7 @@ const resp = async (ctx, text, extra) => {
|
|
|
48
48
|
// if (ctx._.type === 'inline_query') {
|
|
49
49
|
// return await ctx.answerInlineQuery([{}, {}]);
|
|
50
50
|
// }
|
|
51
|
+
extra = getExtra(ctx, extra);
|
|
51
52
|
let resp;
|
|
52
53
|
if (!extra?.noMd) {
|
|
53
54
|
const txt = extra?.parsed ? text : convert(text);
|
|
@@ -64,17 +65,18 @@ const resp = async (ctx, text, extra) => {
|
|
|
64
65
|
), hal.logOptions
|
|
65
66
|
);
|
|
66
67
|
}
|
|
67
|
-
resp && ctx._.done.push(resp);
|
|
68
|
+
resp && ctx._.done.push({ ...resp, raw: text });
|
|
68
69
|
return resp;
|
|
69
70
|
};
|
|
70
71
|
|
|
71
72
|
const replyWith = async (ctx, func, src, options) => ctx._.done.push(
|
|
72
73
|
await ctx[func](Array.isArray(src) ? src.map(x => ({
|
|
73
74
|
type: x.type || 'photo', media: { [getKey(x.src)]: x.src },
|
|
74
|
-
})) : { [getKey(src)]: src },
|
|
75
|
+
})) : { [getKey(src)]: src }, getExtra(ctx, options))
|
|
75
76
|
);
|
|
76
77
|
|
|
77
78
|
const edit = async (ctx, lastMsgId, text, extra) => {
|
|
79
|
+
extra = getExtra(ctx, extra);
|
|
78
80
|
let resp;
|
|
79
81
|
if (!extra?.noMd) {
|
|
80
82
|
const txt = extra?.parsed ? text : convert(text);
|
|
@@ -90,7 +92,7 @@ const edit = async (ctx, lastMsgId, text, extra) => {
|
|
|
90
92
|
ctx._.chatId, lastMsgId, '', text, extra
|
|
91
93
|
), hal.logOptions);
|
|
92
94
|
}
|
|
93
|
-
resp && ctx._.done.push(resp);
|
|
95
|
+
resp && ctx._.done.push({ ...resp, raw: text });
|
|
94
96
|
return resp;
|
|
95
97
|
};
|
|
96
98
|
|
|
@@ -120,16 +122,15 @@ const ctxExt = ctx => {
|
|
|
120
122
|
ctx.collect(str, null, { refresh: true });
|
|
121
123
|
return str;
|
|
122
124
|
};
|
|
123
|
-
ctx.getExtra = (options) => getExtra(ctx, options);
|
|
124
125
|
ctx.resp = async (text, extra) => await resp(ctx, text, extra);
|
|
125
126
|
ctx.edit = async (lastMsgId, text, extra) =>
|
|
126
127
|
await edit(ctx, lastMsgId, text, extra);
|
|
127
128
|
ctx.ok = async (message, options) => {
|
|
128
129
|
let pages = paginate(message, options);
|
|
129
|
-
const extra = { ...
|
|
130
|
+
const extra = { ...getExtra(ctx, options), parsed: true };
|
|
130
131
|
const [pageIds, pageMap] = [[], {}];
|
|
131
132
|
options?.pageBreak || ctx._.done.filter(x => x).map(x => {
|
|
132
|
-
pageMap[x?.message_id] ||
|
|
133
|
+
pageMap[x?.message_id] || pageIds.push(x?.message_id);
|
|
133
134
|
pageMap[x?.message_id] = x;
|
|
134
135
|
});
|
|
135
136
|
for (let i in pages) {
|
|
@@ -137,7 +138,7 @@ const ctxExt = ctx => {
|
|
|
137
138
|
const shouldExtra = options?.lastMessageId || lastPage;
|
|
138
139
|
const _extra = shouldExtra ? extra : {};
|
|
139
140
|
const lastMsgId = ~~(options?.lastMessageId || pageIds[~~i]);
|
|
140
|
-
if (lastMsgId && pageMap[lastMsgId]?.
|
|
141
|
+
if (lastMsgId && pageMap[lastMsgId]?.raw === pages[i]) {
|
|
141
142
|
continue;
|
|
142
143
|
}
|
|
143
144
|
await (lastMsgId ? ctx.edit(lastMsgId, pages[i], _extra) // ongoing, edit
|
package/pipeline/080_history.mjs
CHANGED
|
@@ -78,15 +78,13 @@ const action = async (ctx, next) => {
|
|
|
78
78
|
|| ctx._.message.message_id,
|
|
79
79
|
}
|
|
80
80
|
};
|
|
81
|
-
result.length === hal.SEARCH_LIMIT ? await ctx.resp(
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
...options,
|
|
89
|
-
})) : await ctx.err('No more records.', options);
|
|
81
|
+
result.length === hal.SEARCH_LIMIT ? await ctx.resp('___', {
|
|
82
|
+
buttons: [{
|
|
83
|
+
label: '🔍 More',
|
|
84
|
+
text: `/search@${ctx.botInfo.username} ${keywords} `
|
|
85
|
+
+ `--skip=${offset + result.length}`,
|
|
86
|
+
}], ...options,
|
|
87
|
+
}) : await ctx.err('No more records.', options);
|
|
90
88
|
break;
|
|
91
89
|
default:
|
|
92
90
|
await next();
|
package/pipeline/100_chat.mjs
CHANGED
|
@@ -6,7 +6,7 @@ const log = (c, o) => utilitas.log(c, _name, { time: 1, ...o || {} });
|
|
|
6
6
|
const action = async (ctx, next) => {
|
|
7
7
|
if (!ctx._.text && !ctx._.collected.length) { return await next(); }
|
|
8
8
|
let [resp, extra, lock, sResp, lastMsg, lastSent] =
|
|
9
|
-
[null, { buttons: [] }, 1000 *
|
|
9
|
+
[null, { buttons: [] }, 1000 * 3, null, null, 0];
|
|
10
10
|
const ok = async options => {
|
|
11
11
|
const curTime = Date.now();
|
|
12
12
|
if (options?.processing && (
|
|
@@ -42,6 +42,7 @@ const action = async (ctx, next) => {
|
|
|
42
42
|
await ctx.audio(audio.data, { caption: audio.caption });
|
|
43
43
|
}
|
|
44
44
|
// print(resp);
|
|
45
|
+
await ctx.timeout();
|
|
45
46
|
await resp.text.trim() ? ok({ processing: false })
|
|
46
47
|
: ctx.deleteMessage(ctx._.done[0].message_id);
|
|
47
48
|
ctx._.request = resp.request;
|