@alemonjs/onebot 2.1.0-alpha.14 → 2.1.0-alpha.16
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/lib/db.d.ts +0 -2
- package/lib/db.js +1 -3
- package/lib/index.d.ts +2 -2
- package/lib/index.js +40 -30
- package/package.json +2 -3
package/lib/db.d.ts
CHANGED
package/lib/db.js
CHANGED
package/lib/index.d.ts
CHANGED
package/lib/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { cbpPlatform, createResult, ResultCode } from 'alemonjs';
|
|
1
|
+
import { definePlatform, cbpPlatform, createResult, ResultCode } from 'alemonjs';
|
|
2
2
|
import { getBufferByURL } from 'alemonjs/utils';
|
|
3
3
|
import { readFileSync } from 'fs';
|
|
4
4
|
import { getOneBotConfig, getMaster, platform } from './config.js';
|
|
@@ -128,10 +128,46 @@ const main = () => {
|
|
|
128
128
|
return empty;
|
|
129
129
|
}
|
|
130
130
|
else if (item.type === 'Image') {
|
|
131
|
+
if (item.value.startsWith('http://') || item.value.startsWith('https://')) {
|
|
132
|
+
const res = await getBufferByURL(item.value);
|
|
133
|
+
return {
|
|
134
|
+
type: 'image',
|
|
135
|
+
data: {
|
|
136
|
+
file: `base64://${res.toString('base64')}`
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
else if (item.value.startsWith('base64://')) {
|
|
141
|
+
const base64Str = item.value.replace('base64://', '');
|
|
142
|
+
return {
|
|
143
|
+
type: 'image',
|
|
144
|
+
data: {
|
|
145
|
+
file: `base64://${base64Str}`
|
|
146
|
+
}
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
else if (item.value.startsWith('buffer://')) {
|
|
150
|
+
const base64Str = item.value.replace('buffer://', '');
|
|
151
|
+
return {
|
|
152
|
+
type: 'image',
|
|
153
|
+
data: {
|
|
154
|
+
file: `base64://${base64Str}`
|
|
155
|
+
}
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
else if (item.value.startsWith('file://')) {
|
|
159
|
+
const db = readFileSync(item.value);
|
|
160
|
+
return {
|
|
161
|
+
type: 'image',
|
|
162
|
+
data: {
|
|
163
|
+
file: `base64://${db.toString('base64')}`
|
|
164
|
+
}
|
|
165
|
+
};
|
|
166
|
+
}
|
|
131
167
|
return {
|
|
132
168
|
type: 'image',
|
|
133
169
|
data: {
|
|
134
|
-
file: `base64://${item.value}`
|
|
170
|
+
file: `base64://${item.value.toString('base64')}`
|
|
135
171
|
}
|
|
136
172
|
};
|
|
137
173
|
}
|
|
@@ -358,32 +394,6 @@ const main = () => {
|
|
|
358
394
|
};
|
|
359
395
|
cbp.onapis((data, consume) => void onapis(data, consume));
|
|
360
396
|
};
|
|
361
|
-
|
|
362
|
-
['SIGINT', 'SIGTERM', 'SIGQUIT', 'disconnect'].forEach(sig => {
|
|
363
|
-
process?.on?.(sig, () => {
|
|
364
|
-
logger.info?.(`[@alemonjs/onebot][${sig}] 收到信号,正在关闭...`);
|
|
365
|
-
setImmediate(() => process.exit(0));
|
|
366
|
-
});
|
|
367
|
-
});
|
|
368
|
-
process?.on?.('exit', code => {
|
|
369
|
-
logger.info?.(`[@alemonjs/onebot][exit] 进程退出,code=${code}`);
|
|
370
|
-
});
|
|
371
|
-
process.on('message', msg => {
|
|
372
|
-
try {
|
|
373
|
-
const data = typeof msg === 'string' ? JSON.parse(msg) : msg;
|
|
374
|
-
if (data?.type === 'start') {
|
|
375
|
-
main();
|
|
376
|
-
}
|
|
377
|
-
else if (data?.type === 'stop') {
|
|
378
|
-
process.exit(0);
|
|
379
|
-
}
|
|
380
|
-
}
|
|
381
|
-
catch { }
|
|
382
|
-
});
|
|
383
|
-
if (process.send) {
|
|
384
|
-
process.send(JSON.stringify({ type: 'ready' }));
|
|
385
|
-
}
|
|
386
|
-
};
|
|
387
|
-
mainProcess();
|
|
397
|
+
var index = definePlatform({ main });
|
|
388
398
|
|
|
389
|
-
export {
|
|
399
|
+
export { index as default, platform };
|
package/package.json
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alemonjs/onebot",
|
|
3
|
-
"version": "2.1.0-alpha.
|
|
3
|
+
"version": "2.1.0-alpha.16",
|
|
4
4
|
"description": "oneBot v11",
|
|
5
5
|
"author": "lemonade",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"main": "lib/index.js",
|
|
9
|
-
"types": "lib",
|
|
10
9
|
"scripts": {
|
|
11
10
|
"build": "lvy build"
|
|
12
11
|
},
|
|
@@ -26,7 +25,7 @@
|
|
|
26
25
|
"ws": "^8.18.1"
|
|
27
26
|
},
|
|
28
27
|
"peerDependencies": {
|
|
29
|
-
"alemonjs": "^2.1.
|
|
28
|
+
"alemonjs": "^2.1.14"
|
|
30
29
|
},
|
|
31
30
|
"alemonjs": {
|
|
32
31
|
"desktop": {
|