utilitas 1998.2.46 → 1998.2.48
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/dist/utilitas.lite.mjs +1 -1
- package/dist/utilitas.lite.mjs.map +1 -1
- package/lib/bot.mjs +32 -37
- package/lib/manifest.mjs +1 -1
- package/lib/shot.mjs +3 -5
- package/package.json +1 -1
package/lib/bot.mjs
CHANGED
|
@@ -1,24 +1,26 @@
|
|
|
1
1
|
// @todo: New text of the message, 1-4096 characters after entities parsing
|
|
2
2
|
|
|
3
3
|
import {
|
|
4
|
+
log as _log,
|
|
4
5
|
base64Encode, countKeys, ensureArray, ensureString, getTimeIcon,
|
|
5
6
|
humanReadableBoolean, ignoreErrFunc, insensitiveCompare, insensitiveHas,
|
|
6
|
-
isSet, lastItem,
|
|
7
|
-
|
|
7
|
+
isSet, lastItem,
|
|
8
|
+
need, parseJson, prettyJson, splitArgs,
|
|
9
|
+
throwError,
|
|
10
|
+
timeout, trim, which,
|
|
8
11
|
} from './utilitas.mjs';
|
|
9
12
|
|
|
10
|
-
import {
|
|
13
|
+
import { readdirSync } from 'fs';
|
|
14
|
+
import { parseArgs as _parseArgs } from 'node:util';
|
|
11
15
|
import { basename, join } from 'path';
|
|
16
|
+
import { jpeg, ogg, wav } from './alan.mjs';
|
|
17
|
+
import { isPrimary, on, report } from './callosum.mjs';
|
|
18
|
+
import { cleanSql, encodeVector, MYSQL, POSTGRESQL } from './dbio.mjs';
|
|
12
19
|
import { convertAudioTo16kNanoPcmWave } from './media.mjs';
|
|
13
|
-
import { distill } from './web.mjs';
|
|
14
|
-
import { fakeUuid } from './uoid.mjs';
|
|
15
20
|
import { get } from './shot.mjs';
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import { MYSQL, POSTGRESQL, cleanSql, encodeVector } from './dbio.mjs';
|
|
19
|
-
import { parseArgs as _parseArgs } from 'node:util';
|
|
21
|
+
import { BASE64, BUFFER, convert, FILE, isTextFile, tryRm } from './storage.mjs';
|
|
22
|
+
import { fakeUuid } from './uoid.mjs';
|
|
20
23
|
import { parseOfficeFile } from './vision.mjs';
|
|
21
|
-
import { readdirSync } from 'fs';
|
|
22
24
|
|
|
23
25
|
const _NEED = ['mime', 'telegraf'];
|
|
24
26
|
// 👇 https://core.telegram.org/bots/faq#my-bot-is-hitting-limits-how-do-i-avoid-this
|
|
@@ -730,20 +732,20 @@ const subconscious = [{
|
|
|
730
732
|
);
|
|
731
733
|
await next();
|
|
732
734
|
},
|
|
733
|
-
}, {
|
|
734
|
-
run: true, priority: -8870, name: 'web', func: async (ctx, next) => {
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
},
|
|
735
|
+
// }, {
|
|
736
|
+
// run: true, priority: -8870, name: 'web', func: async (ctx, next) => {
|
|
737
|
+
// if (ctx.entities.some(e => e.type === 'url')) {
|
|
738
|
+
// await ctx.ok(EMOJI_LOOK);
|
|
739
|
+
// for (let e of ctx.entities) {
|
|
740
|
+
// if (e.type !== 'url') { continue; }
|
|
741
|
+
// const content = await ignoreErrFunc(async () => (
|
|
742
|
+
// await distill(e.matched)
|
|
743
|
+
// )?.summary);
|
|
744
|
+
// content && ctx.collect(content, 'URL');
|
|
745
|
+
// }
|
|
746
|
+
// }
|
|
747
|
+
// await next();
|
|
748
|
+
// },
|
|
747
749
|
}, {
|
|
748
750
|
run: true, priority: -8860, name: 'vision', func: async (ctx, next) => {
|
|
749
751
|
ctx.collect(ctx.m?.caption || '');
|
|
@@ -1146,21 +1148,14 @@ export {
|
|
|
1146
1148
|
COMMAND_LIMIT,
|
|
1147
1149
|
EMOJI_BOT,
|
|
1148
1150
|
EMOJI_SPEECH,
|
|
1149
|
-
EMOJI_THINKING,
|
|
1150
|
-
|
|
1151
|
-
HELLO,
|
|
1152
|
-
MESSAGE_LENGTH_LIMIT,
|
|
1153
|
-
MESSAGE_SOFT_LIMIT,
|
|
1154
|
-
PRIVATE_LIMIT,
|
|
1155
|
-
end,
|
|
1156
|
-
init,
|
|
1151
|
+
EMOJI_THINKING, end, GROUP_LIMIT,
|
|
1152
|
+
HELLO, init,
|
|
1157
1153
|
lines,
|
|
1158
1154
|
lines2,
|
|
1159
|
-
map,
|
|
1160
|
-
newCommand,
|
|
1155
|
+
map, MESSAGE_LENGTH_LIMIT,
|
|
1156
|
+
MESSAGE_SOFT_LIMIT, newCommand,
|
|
1161
1157
|
oList,
|
|
1162
|
-
paging,
|
|
1163
|
-
send,
|
|
1158
|
+
paging, PRIVATE_LIMIT, send,
|
|
1164
1159
|
sendMd,
|
|
1165
|
-
uList
|
|
1160
|
+
uList
|
|
1166
1161
|
};
|
package/lib/manifest.mjs
CHANGED
package/lib/shot.mjs
CHANGED
|
@@ -20,7 +20,7 @@ const [_JSON, _PARSED] = ['JSON', 'PARSED'];
|
|
|
20
20
|
const getJson = async (u, o) => await get(u, { encode: _JSON, ...o || {} });
|
|
21
21
|
const getParsedHtml = async (u, o) => await get(u, { encode: _PARSED, ...o || {} });
|
|
22
22
|
|
|
23
|
-
let
|
|
23
|
+
let googleApiKey, googleCx;
|
|
24
24
|
|
|
25
25
|
const defFetchOpt = {
|
|
26
26
|
redirect: 'follow', follow: 3, timeout: 1000 * 10, headers: {
|
|
@@ -153,11 +153,9 @@ const get = async (url, options) => {
|
|
|
153
153
|
|
|
154
154
|
const initSearch = (options) => {
|
|
155
155
|
assert(
|
|
156
|
-
options?.
|
|
157
|
-
'Invalid search options.'
|
|
156
|
+
options?.apiKey && options?.cx, 'Invalid search options.'
|
|
158
157
|
);
|
|
159
|
-
return [
|
|
160
|
-
= [options.provider, options.apiKey, options.cx];
|
|
158
|
+
return [googleApiKey, googleCx] = [options.apiKey, options.cx];
|
|
161
159
|
};
|
|
162
160
|
|
|
163
161
|
const search = async (query, options) => {
|