node-karin 0.12.0 → 0.12.2-5.pr.206.027f2f2
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/CHANGELOG.md +1029 -0
- package/default/comment/config.json +34 -0
- package/default/comment/friendDirect.json +10 -0
- package/default/comment/groupGuild.json +11 -0
- package/default/comment/server.json +17 -0
- package/default/config/adapter.json +28 -0
- package/default/config/config.json +47 -0
- package/default/config/groups.json +47 -0
- package/default/config/groups.yaml +70 -0
- package/default/config/pm2.json +16 -0
- package/default/config/privates.json +23 -0
- package/default/config/privates.yaml +31 -0
- package/default/config/redis.json +10 -0
- package/default/config/render.json +19 -0
- package/default/view/group.yaml +73 -0
- package/dist/index.d.ts +9869 -0
- package/dist/index.js +12643 -0
- package/dist/module/art-template.cjs +11 -0
- package/dist/module/art-template.d.ts +1 -0
- package/dist/module/axios.cjs +22 -0
- package/dist/module/axios.d.ts +2 -0
- package/dist/module/chalk.cjs +22 -0
- package/dist/module/chalk.d.ts +2 -0
- package/dist/module/chokidar.cjs +22 -0
- package/dist/module/chokidar.d.ts +2 -0
- package/dist/module/commander.cjs +35 -0
- package/dist/module/commander.d.ts +3 -0
- package/dist/module/commander.js +3 -0
- package/dist/module/dotenv.cjs +22 -0
- package/dist/module/dotenv.d.ts +2 -0
- package/dist/module/dotenv.js +2 -0
- package/dist/module/express.cjs +112 -0
- package/dist/module/express.d.ts +1 -0
- package/dist/module/express.js +1 -0
- package/dist/module/level.cjs +22 -0
- package/dist/module/level.d.ts +2 -0
- package/dist/module/lodash.cjs +11 -0
- package/dist/module/lodash.d.ts +1 -0
- package/dist/module/log4js.cjs +22 -0
- package/dist/module/log4js.d.ts +2 -0
- package/dist/module/moment.cjs +11 -0
- package/dist/module/moment.d.ts +1 -0
- package/dist/module/node-schedule.cjs +22 -0
- package/dist/module/node-schedule.d.ts +2 -0
- package/dist/module/redis.cjs +22 -0
- package/dist/module/redis.d.ts +2 -0
- package/dist/module/ws.cjs +28 -0
- package/dist/module/ws.d.ts +1 -0
- package/dist/module/ws.js +1 -0
- package/dist/module/yaml.cjs +22 -0
- package/dist/module/yaml.d.ts +2 -0
- package/dist/root.d.ts +40 -0
- package/dist/root.js +44 -0
- package/package.json +142 -128
- package/LICENSE +0 -674
- package/README.md +0 -56
- package/config/defSet/App.yaml +0 -42
- package/config/defSet/config.yaml +0 -65
- package/config/defSet/group.yaml +0 -56
- package/config/defSet/pm2.yaml +0 -21
- package/config/defSet/redis.yaml +0 -18
- package/config/defSet/server.yaml +0 -42
- package/config/view/group.yaml +0 -92
- package/lib/adapter/index.d.ts +0 -2
- package/lib/adapter/index.js +0 -2
- package/lib/adapter/input/index.d.ts +0 -78
- package/lib/adapter/input/index.js +0 -205
- package/lib/adapter/onebot/11/convert.d.ts +0 -12
- package/lib/adapter/onebot/11/convert.js +0 -167
- package/lib/adapter/onebot/11/event.d.ts +0 -25
- package/lib/adapter/onebot/11/event.js +0 -442
- package/lib/adapter/onebot/11/index.d.ts +0 -508
- package/lib/adapter/onebot/11/index.js +0 -1047
- package/lib/cli/index.d.ts +0 -92
- package/lib/cli/index.js +0 -307
- package/lib/cli/init.d.ts +0 -2
- package/lib/cli/init.js +0 -22
- package/lib/cli/karin.d.ts +0 -2
- package/lib/cli/karin.js +0 -16
- package/lib/cli/pkg.d.ts +0 -4
- package/lib/cli/pkg.js +0 -14
- package/lib/cli/start.d.ts +0 -1
- package/lib/cli/start.js +0 -8
- package/lib/core/index.d.ts +0 -10
- package/lib/core/index.js +0 -10
- package/lib/core/init/config.d.ts +0 -43
- package/lib/core/init/config.js +0 -201
- package/lib/core/init/dir.d.ts +0 -4
- package/lib/core/init/dir.js +0 -7
- package/lib/core/init/init.d.ts +0 -1
- package/lib/core/init/init.js +0 -47
- package/lib/core/karin/karin.d.ts +0 -198
- package/lib/core/karin/karin.js +0 -226
- package/lib/core/listener/listener.d.ts +0 -145
- package/lib/core/listener/listener.js +0 -235
- package/lib/core/plugin/base.d.ts +0 -156
- package/lib/core/plugin/base.js +0 -131
- package/lib/core/plugin/loader.d.ts +0 -141
- package/lib/core/plugin/loader.js +0 -618
- package/lib/core/process/process.d.ts +0 -18
- package/lib/core/process/process.js +0 -96
- package/lib/core/server/server.d.ts +0 -25
- package/lib/core/server/server.js +0 -295
- package/lib/db/index.d.ts +0 -2
- package/lib/db/index.js +0 -2
- package/lib/db/level/level.d.ts +0 -19
- package/lib/db/level/level.js +0 -36
- package/lib/db/redis/redis.d.ts +0 -2
- package/lib/db/redis/redis.js +0 -135
- package/lib/db/redis/redis_level.d.ts +0 -112
- package/lib/db/redis/redis_level.js +0 -281
- package/lib/event/handler/base.d.ts +0 -42
- package/lib/event/handler/base.js +0 -200
- package/lib/event/handler/message.d.ts +0 -29
- package/lib/event/handler/message.js +0 -307
- package/lib/event/handler/notice.d.ts +0 -18
- package/lib/event/handler/notice.js +0 -214
- package/lib/event/handler/request.d.ts +0 -18
- package/lib/event/handler/request.js +0 -115
- package/lib/event/handler/review.d.ts +0 -55
- package/lib/event/handler/review.js +0 -386
- package/lib/event/index.d.ts +0 -5
- package/lib/event/index.js +0 -5
- package/lib/index.d.ts +0 -8
- package/lib/index.js +0 -8
- package/lib/modules/art-template.d.ts +0 -1
- package/lib/modules/axios.d.ts +0 -2
- package/lib/modules/chalk.d.ts +0 -2
- package/lib/modules/chokidar.d.ts +0 -2
- package/lib/modules/commander.d.ts +0 -2
- package/lib/modules/commander.js +0 -2
- package/lib/modules/express.d.ts +0 -3
- package/lib/modules/express.js +0 -3
- package/lib/modules/level.d.ts +0 -2
- package/lib/modules/lodash.d.ts +0 -1
- package/lib/modules/log4js.d.ts +0 -2
- package/lib/modules/moment.d.ts +0 -1
- package/lib/modules/node-schedule.d.ts +0 -2
- package/lib/modules/redis.d.ts +0 -2
- package/lib/modules/ws.d.ts +0 -3
- package/lib/modules/ws.js +0 -3
- package/lib/modules/yaml.d.ts +0 -2
- package/lib/modules.d.ts +0 -15
- package/lib/modules.js +0 -15
- package/lib/render/app.d.ts +0 -56
- package/lib/render/app.js +0 -120
- package/lib/render/base.d.ts +0 -30
- package/lib/render/base.js +0 -69
- package/lib/render/client.d.ts +0 -41
- package/lib/render/client.js +0 -238
- package/lib/render/http.d.ts +0 -19
- package/lib/render/http.js +0 -50
- package/lib/render/index.d.ts +0 -6
- package/lib/render/index.js +0 -6
- package/lib/render/server.d.ts +0 -25
- package/lib/render/server.js +0 -101
- package/lib/render/wormhole.d.ts +0 -1
- package/lib/render/wormhole.js +0 -156
- package/lib/types/adapter/api.d.ts +0 -399
- package/lib/types/adapter/api.js +0 -1
- package/lib/types/adapter/base.d.ts +0 -560
- package/lib/types/adapter/base.js +0 -1
- package/lib/types/config/config.d.ts +0 -379
- package/lib/types/config/config.js +0 -1
- package/lib/types/element/element.d.ts +0 -565
- package/lib/types/element/element.js +0 -1
- package/lib/types/element/qqbot.d.ts +0 -123
- package/lib/types/element/qqbot.js +0 -1
- package/lib/types/event/contact.d.ts +0 -28
- package/lib/types/event/contact.js +0 -1
- package/lib/types/event/event.d.ts +0 -305
- package/lib/types/event/event.js +0 -1
- package/lib/types/event/index.d.ts +0 -12
- package/lib/types/event/index.js +0 -7
- package/lib/types/event/message.d.ts +0 -109
- package/lib/types/event/message.js +0 -74
- package/lib/types/event/notice.d.ts +0 -513
- package/lib/types/event/notice.js +0 -52
- package/lib/types/event/reply.d.ts +0 -50
- package/lib/types/event/reply.js +0 -1
- package/lib/types/event/request.d.ts +0 -126
- package/lib/types/event/request.js +0 -52
- package/lib/types/event/sender.d.ts +0 -44
- package/lib/types/event/sender.js +0 -1
- package/lib/types/index.d.ts +0 -13
- package/lib/types/index.js +0 -13
- package/lib/types/logger/logger.d.ts +0 -110
- package/lib/types/logger/logger.js +0 -1
- package/lib/types/onebot11/api.d.ts +0 -53
- package/lib/types/onebot11/api.js +0 -1
- package/lib/types/onebot11/event.d.ts +0 -619
- package/lib/types/onebot11/event.js +0 -2
- package/lib/types/onebot11/index.d.ts +0 -6
- package/lib/types/onebot11/index.js +0 -6
- package/lib/types/onebot11/params.d.ts +0 -609
- package/lib/types/onebot11/params.js +0 -1
- package/lib/types/onebot11/response.d.ts +0 -516
- package/lib/types/onebot11/response.js +0 -1
- package/lib/types/onebot11/segment.d.ts +0 -269
- package/lib/types/onebot11/segment.js +0 -1
- package/lib/types/onebot11/sender.d.ts +0 -59
- package/lib/types/onebot11/sender.js +0 -1
- package/lib/types/plugin/app.d.ts +0 -71
- package/lib/types/plugin/app.js +0 -1
- package/lib/types/plugin/plugin.d.ts +0 -473
- package/lib/types/plugin/plugin.js +0 -1
- package/lib/types/render/render.d.ts +0 -118
- package/lib/types/render/render.js +0 -1
- package/lib/types/type/global.d.ts +0 -25
- package/lib/types/type/global.js +0 -1
- package/lib/utils/common/common.d.ts +0 -236
- package/lib/utils/common/common.js +0 -708
- package/lib/utils/config/config.d.ts +0 -193
- package/lib/utils/config/config.js +0 -328
- package/lib/utils/config/updateVersion.d.ts +0 -33
- package/lib/utils/config/updateVersion.js +0 -145
- package/lib/utils/config/yamlEditor.d.ts +0 -101
- package/lib/utils/config/yamlEditor.js +0 -330
- package/lib/utils/core/handler.d.ts +0 -18
- package/lib/utils/core/handler.js +0 -46
- package/lib/utils/core/logger.d.ts +0 -3
- package/lib/utils/core/logger.js +0 -105
- package/lib/utils/core/segment.d.ts +0 -279
- package/lib/utils/core/segment.js +0 -451
- package/lib/utils/index.d.ts +0 -13
- package/lib/utils/index.js +0 -13
- package/lib/utils/tools/button.d.ts +0 -2
- package/lib/utils/tools/button.js +0 -27
- package/lib/utils/tools/exec.d.ts +0 -20
- package/lib/utils/tools/exec.js +0 -54
- package/lib/utils/tools/ffmpeg.d.ts +0 -12
- package/lib/utils/tools/ffmpeg.js +0 -25
- package/lib/utils/tools/restart.d.ts +0 -15
- package/lib/utils/tools/restart.js +0 -39
- package/lib/utils/tools/stop.d.ts +0 -7
- package/lib/utils/tools/stop.js +0 -13
- package/lib/utils/tools/update.d.ts +0 -67
- package/lib/utils/tools/update.js +0 -151
- /package/{config → default}/view/App.yaml +0 -0
- /package/{config → default}/view/config.yaml +0 -0
- /package/{config → default}/view/pm2.yaml +0 -0
- /package/{config → default}/view/redis.yaml +0 -0
- /package/{config → default}/view/server.yaml +0 -0
- /package/{lib/modules → dist/module}/art-template.js +0 -0
- /package/{lib/modules → dist/module}/axios.js +0 -0
- /package/{lib/modules → dist/module}/chalk.js +0 -0
- /package/{lib/modules → dist/module}/chokidar.js +0 -0
- /package/{lib/modules → dist/module}/level.js +0 -0
- /package/{lib/modules → dist/module}/lodash.js +0 -0
- /package/{lib/modules → dist/module}/log4js.js +0 -0
- /package/{lib/modules → dist/module}/moment.js +0 -0
- /package/{lib/modules → dist/module}/node-schedule.js +0 -0
- /package/{lib/modules → dist/module}/redis.js +0 -0
- /package/{lib/modules → dist/module}/yaml.js +0 -0
package/lib/render/server.js
DELETED
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
import { render } from './app.js';
|
|
2
|
-
import { RenderBase } from './base.js';
|
|
3
|
-
import { randomUUID } from 'crypto';
|
|
4
|
-
import { logger } from '../utils/index.js';
|
|
5
|
-
import { listener } from '../core/index.js';
|
|
6
|
-
class Puppeteer extends RenderBase {
|
|
7
|
-
socket;
|
|
8
|
-
id;
|
|
9
|
-
type;
|
|
10
|
-
host;
|
|
11
|
-
url;
|
|
12
|
-
index;
|
|
13
|
-
constructor() {
|
|
14
|
-
super();
|
|
15
|
-
this.id = 0;
|
|
16
|
-
this.index = 0;
|
|
17
|
-
this.type = '';
|
|
18
|
-
this.host = '';
|
|
19
|
-
this.url = '';
|
|
20
|
-
}
|
|
21
|
-
async server(socket, request) {
|
|
22
|
-
this.socket = socket;
|
|
23
|
-
this.id = request.headers['renderer-id'];
|
|
24
|
-
this.type = request.headers['renderer-type'];
|
|
25
|
-
/** 注册渲染器 */
|
|
26
|
-
this.host = request.headers.host;
|
|
27
|
-
this.url = `ws://${this.host + request.url}`;
|
|
28
|
-
logger.info(`[渲染器:${this.id}] 收到新的连接请求:` + logger.green(this.url));
|
|
29
|
-
/** 监听上报事件 */
|
|
30
|
-
this.socket.on('message', data => {
|
|
31
|
-
const json = JSON.parse(data.toString());
|
|
32
|
-
if (json.echo) {
|
|
33
|
-
listener.emit(json.echo, json);
|
|
34
|
-
}
|
|
35
|
-
else if (json.action === 'heartbeat') {
|
|
36
|
-
logger.debug(`[渲染器:${this.id}] 收到心跳:${this.url}`);
|
|
37
|
-
}
|
|
38
|
-
else {
|
|
39
|
-
logger.warn(`[渲染器:${this.id}] 收到未知数据:`, data);
|
|
40
|
-
}
|
|
41
|
-
});
|
|
42
|
-
/** 监听断开 */
|
|
43
|
-
this.socket.on('close', () => {
|
|
44
|
-
logger.warn(`[渲染器:${this.id}] 连接断开:${this.url}`);
|
|
45
|
-
/** 卸载渲染器 */
|
|
46
|
-
this.index && render.unapp(this.index);
|
|
47
|
-
this.index = 0;
|
|
48
|
-
});
|
|
49
|
-
/** 注册渲染器 */
|
|
50
|
-
try {
|
|
51
|
-
const index = render.app({
|
|
52
|
-
id: this.id,
|
|
53
|
-
type: this.type,
|
|
54
|
-
render: this.render.bind(this),
|
|
55
|
-
});
|
|
56
|
-
this.index = index;
|
|
57
|
-
}
|
|
58
|
-
catch (error) {
|
|
59
|
-
logger.error(`[渲染器:${this.id}] 注册渲染器失败:`, error);
|
|
60
|
-
/** 断开连接 */
|
|
61
|
-
this.socket.close();
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* 渲染模板
|
|
66
|
-
* @param options 模板参数
|
|
67
|
-
*/
|
|
68
|
-
async render(options) {
|
|
69
|
-
/** 渲染模板 */
|
|
70
|
-
let file = '';
|
|
71
|
-
if (options.file.includes('http') || options.vue) {
|
|
72
|
-
file = options.file;
|
|
73
|
-
}
|
|
74
|
-
else {
|
|
75
|
-
file = 'file://' + this.dealTpl(options);
|
|
76
|
-
}
|
|
77
|
-
if (!file)
|
|
78
|
-
throw new Error(`[渲染器:${this.id}] 模板文件不存在:${options.name}`);
|
|
79
|
-
const echo = randomUUID();
|
|
80
|
-
const action = 'render';
|
|
81
|
-
const data = options;
|
|
82
|
-
/** 移除掉模板参数 */
|
|
83
|
-
if (data.data)
|
|
84
|
-
delete data.data;
|
|
85
|
-
data.file = file;
|
|
86
|
-
logger.debug(`[渲染器:${this.id}][反向WS] \n请求:${this.url} \nhtml: ${options.file} \ndata: ${JSON.stringify(data)}`);
|
|
87
|
-
this.socket.send(JSON.stringify({ echo, action, data }));
|
|
88
|
-
return new Promise((resolve, reject) => {
|
|
89
|
-
listener.once(echo, data => {
|
|
90
|
-
if (data.ok)
|
|
91
|
-
return resolve(data.data);
|
|
92
|
-
reject(new Error(JSON.stringify(data)));
|
|
93
|
-
});
|
|
94
|
-
});
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
export const RenderServer = {
|
|
98
|
-
type: 'render',
|
|
99
|
-
path: '/puppeteer',
|
|
100
|
-
adapter: Puppeteer,
|
|
101
|
-
};
|
package/lib/render/wormhole.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function Wormhole(): void;
|
package/lib/render/wormhole.js
DELETED
|
@@ -1,156 +0,0 @@
|
|
|
1
|
-
import fs from 'fs';
|
|
2
|
-
import path from 'path';
|
|
3
|
-
import { URL } from 'url';
|
|
4
|
-
import WebSocket from 'ws';
|
|
5
|
-
import { render } from './index.js';
|
|
6
|
-
import { HttpRenderer } from './http.js';
|
|
7
|
-
import { config } from '../utils/index.js';
|
|
8
|
-
let ws;
|
|
9
|
-
let reConnect;
|
|
10
|
-
const chunkSize = 1024 * 1024 * 3; // 文件分片大小
|
|
11
|
-
export function Wormhole() {
|
|
12
|
-
let heartbeat;
|
|
13
|
-
let index = 0;
|
|
14
|
-
reConnect = undefined;
|
|
15
|
-
const wsUrl = config.Server.HttpRender.WormholeClient;
|
|
16
|
-
ws = new WebSocket(wsUrl);
|
|
17
|
-
ws.on('open', function open() {
|
|
18
|
-
logger.info('连接到wormhole服务器' + wsUrl);
|
|
19
|
-
// 发送心跳
|
|
20
|
-
heartbeat = setInterval(() => {
|
|
21
|
-
ws.send(JSON.stringify({ type: 'heartbeat', date: new Date() }));
|
|
22
|
-
}, 30000); // 每30秒发送一次心跳
|
|
23
|
-
});
|
|
24
|
-
ws.on('message', msg => {
|
|
25
|
-
let data = '';
|
|
26
|
-
try {
|
|
27
|
-
data = JSON.parse(msg.toString());
|
|
28
|
-
}
|
|
29
|
-
catch (error) {
|
|
30
|
-
logger.warn(`收到非法消息${data}`);
|
|
31
|
-
}
|
|
32
|
-
const echo = data.echo;
|
|
33
|
-
switch (data.type) {
|
|
34
|
-
case 'msg': {
|
|
35
|
-
const { post, token, WormholeClient } = config.Server.HttpRender;
|
|
36
|
-
const parsedUrl = new URL(WormholeClient);
|
|
37
|
-
const { hostname, port, pathname } = parsedUrl;
|
|
38
|
-
const ishttps = WormholeClient.includes('wss://');
|
|
39
|
-
const host = `${ishttps ? 'https' : 'http'}://${hostname}${port ? `:${port}` : ''}${pathname.replace(/ws\/(?=[^ws/]*$)/, 'web/')}${data.date}`;
|
|
40
|
-
logger.mark(`web渲染器已连接,地址:${host}`);
|
|
41
|
-
/** 注册渲染器 */
|
|
42
|
-
const rd = new HttpRenderer(host, post, token);
|
|
43
|
-
index = render.app({ id: 'puppeteer', type: 'image', render: rd.render.bind(rd) });
|
|
44
|
-
break;
|
|
45
|
-
}
|
|
46
|
-
case 'web':
|
|
47
|
-
if (data.path) {
|
|
48
|
-
const filePath = data.path;
|
|
49
|
-
const query = data.query;
|
|
50
|
-
if (query.html) {
|
|
51
|
-
ws.send(JSON.stringify({ type: 'web', command: 'redirect', path: filePath, target: query.html.startsWith('/') ? query.html.slice(1) : query.html, echo }));
|
|
52
|
-
return;
|
|
53
|
-
}
|
|
54
|
-
const list = ['.css', '.html', '.ttf', '.jpg', '.jpeg', '.png', '.gif', '.bmp', '.ico', '.woff', '.woff2'];
|
|
55
|
-
if (!list.some(ext => path.extname(filePath).endsWith(ext))) {
|
|
56
|
-
logger.warn(`拦截非资源文件${filePath}`);
|
|
57
|
-
ws.send(JSON.stringify({ type: 'web', state: 'error', error: '非资源文件', echo }));
|
|
58
|
-
return;
|
|
59
|
-
}
|
|
60
|
-
/** 判断一下是否为html 如果是需要特殊处理 */
|
|
61
|
-
if (path.extname(filePath) === '.html') {
|
|
62
|
-
let html = filePath;
|
|
63
|
-
/** 获取文件路径 对路径进行处理,去掉../、./ */
|
|
64
|
-
html = `./${html.replace(/\\/g, '/').replace(/(\.\/|\.\.\/)/g, '')}`;
|
|
65
|
-
/** 判断是否为html文件且路径存在 */
|
|
66
|
-
if (!fs.existsSync(html)) {
|
|
67
|
-
return ws.send(JSON.stringify({ type: 'web', state: 'error', error: '文件不存在', echo }));
|
|
68
|
-
}
|
|
69
|
-
let content = fs.readFileSync(html, 'utf-8');
|
|
70
|
-
/** 处理所有绝对路径、相对路径 */
|
|
71
|
-
content = content.replace(new RegExp(`(${process.cwd()}|${process.cwd().replace(/\\/g, '/')})`, 'g'), '');
|
|
72
|
-
// 保存到本地
|
|
73
|
-
// filePath = './1.html'
|
|
74
|
-
// fs.writeFileSync(filePath, content, 'utf-8')
|
|
75
|
-
return ws.send(JSON.stringify({
|
|
76
|
-
type: 'web',
|
|
77
|
-
path: data.path,
|
|
78
|
-
command: 'resource',
|
|
79
|
-
data: Buffer.from(content),
|
|
80
|
-
state: 'complete',
|
|
81
|
-
part: 0,
|
|
82
|
-
echo,
|
|
83
|
-
}));
|
|
84
|
-
}
|
|
85
|
-
logger.info(`获取网页文件数据:${filePath}`);
|
|
86
|
-
// 获取文件
|
|
87
|
-
const stream = fs.createReadStream(filePath, { highWaterMark: chunkSize });
|
|
88
|
-
let part = 0;
|
|
89
|
-
stream.on('data', chunk => {
|
|
90
|
-
part++;
|
|
91
|
-
const message = {
|
|
92
|
-
type: 'web',
|
|
93
|
-
path: data.path,
|
|
94
|
-
command: 'resource',
|
|
95
|
-
data: chunk,
|
|
96
|
-
state: 'part',
|
|
97
|
-
part,
|
|
98
|
-
echo,
|
|
99
|
-
};
|
|
100
|
-
ws.send(JSON.stringify(message));
|
|
101
|
-
});
|
|
102
|
-
stream.on('end', () => {
|
|
103
|
-
part++;
|
|
104
|
-
// 如果是最后一片段,则更新状态为 'complete'
|
|
105
|
-
if (stream.readableEnded) {
|
|
106
|
-
ws.send(JSON.stringify({
|
|
107
|
-
type: 'web',
|
|
108
|
-
path: data.path,
|
|
109
|
-
command: 'resource',
|
|
110
|
-
data: '',
|
|
111
|
-
state: 'complete',
|
|
112
|
-
part,
|
|
113
|
-
echo,
|
|
114
|
-
}));
|
|
115
|
-
}
|
|
116
|
-
});
|
|
117
|
-
stream.on('error', err => {
|
|
118
|
-
ws.send(JSON.stringify({ type: 'web', state: 'error', error: err.message, echo }));
|
|
119
|
-
});
|
|
120
|
-
}
|
|
121
|
-
else {
|
|
122
|
-
ws.send(JSON.stringify({ type: 'web', state: 'error', error: '错误的文件路径', echo }));
|
|
123
|
-
}
|
|
124
|
-
break;
|
|
125
|
-
default:
|
|
126
|
-
logger.warn(`未知消息类型${JSON.stringify(data)}`);
|
|
127
|
-
break;
|
|
128
|
-
}
|
|
129
|
-
});
|
|
130
|
-
ws.on('close', function close() {
|
|
131
|
-
/** 卸载渲染器 */
|
|
132
|
-
index && render.unapp(index);
|
|
133
|
-
index = 0;
|
|
134
|
-
if (heartbeat) {
|
|
135
|
-
clearInterval(heartbeat);
|
|
136
|
-
heartbeat = null;
|
|
137
|
-
}
|
|
138
|
-
logger.warn('连接关闭,10秒后尝试重新连接');
|
|
139
|
-
if (!reConnect) {
|
|
140
|
-
reConnect = setTimeout(Wormhole, 10000);
|
|
141
|
-
}
|
|
142
|
-
});
|
|
143
|
-
ws.on('error', function error() {
|
|
144
|
-
/** 卸载渲染器 */
|
|
145
|
-
index && render.unapp(index);
|
|
146
|
-
index = 0;
|
|
147
|
-
if (heartbeat) {
|
|
148
|
-
clearInterval(heartbeat);
|
|
149
|
-
heartbeat = null;
|
|
150
|
-
}
|
|
151
|
-
logger.warn('连接错误,10秒后尝试重新连接');
|
|
152
|
-
if (!reConnect) {
|
|
153
|
-
reConnect = setTimeout(Wormhole, 10000);
|
|
154
|
-
}
|
|
155
|
-
});
|
|
156
|
-
}
|
|
@@ -1,399 +0,0 @@
|
|
|
1
|
-
import { Contact, KarinElement, Role, Sender } from '../index.js';
|
|
2
|
-
/**
|
|
3
|
-
* - 基本消息结构
|
|
4
|
-
*/
|
|
5
|
-
export interface PushMessageBody {
|
|
6
|
-
/**
|
|
7
|
-
* - 消息发送时间
|
|
8
|
-
*/
|
|
9
|
-
time: number;
|
|
10
|
-
/**
|
|
11
|
-
* - 消息ID
|
|
12
|
-
*/
|
|
13
|
-
message_id: string;
|
|
14
|
-
/**
|
|
15
|
-
* - 消息序列号
|
|
16
|
-
*/
|
|
17
|
-
message_seq: number;
|
|
18
|
-
/**
|
|
19
|
-
* - 消息来源
|
|
20
|
-
*/
|
|
21
|
-
contact: Contact;
|
|
22
|
-
/**
|
|
23
|
-
* - 消息发送者
|
|
24
|
-
*/
|
|
25
|
-
sender: Sender;
|
|
26
|
-
/**
|
|
27
|
-
* - 消息元素
|
|
28
|
-
*/
|
|
29
|
-
elements: Array<KarinElement>;
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* - 精华消息返回的结构
|
|
33
|
-
*/
|
|
34
|
-
export interface EssenceMessageBody {
|
|
35
|
-
/**
|
|
36
|
-
* - 群ID
|
|
37
|
-
*/
|
|
38
|
-
group_id: string;
|
|
39
|
-
/**
|
|
40
|
-
* - 发送者uid
|
|
41
|
-
*/
|
|
42
|
-
sender_uid: string;
|
|
43
|
-
/**
|
|
44
|
-
* - 发送者uin
|
|
45
|
-
*/
|
|
46
|
-
sender_uin: string;
|
|
47
|
-
/**
|
|
48
|
-
* - 发送者昵称
|
|
49
|
-
*/
|
|
50
|
-
sender_nick: string;
|
|
51
|
-
/**
|
|
52
|
-
* - 操作者uid
|
|
53
|
-
*/
|
|
54
|
-
operator_uid: string;
|
|
55
|
-
/**
|
|
56
|
-
* - 操作者uin
|
|
57
|
-
*/
|
|
58
|
-
operator_uin: string;
|
|
59
|
-
/**
|
|
60
|
-
* - 操作者昵称
|
|
61
|
-
*/
|
|
62
|
-
operator_nick: string;
|
|
63
|
-
/**
|
|
64
|
-
* - 操作时间
|
|
65
|
-
*/
|
|
66
|
-
operation_time: number;
|
|
67
|
-
/**
|
|
68
|
-
* - 消息时间
|
|
69
|
-
*/
|
|
70
|
-
message_time: number;
|
|
71
|
-
/**
|
|
72
|
-
* - 消息ID
|
|
73
|
-
*/
|
|
74
|
-
message_id: string;
|
|
75
|
-
/**
|
|
76
|
-
* - 消息序列号
|
|
77
|
-
*/
|
|
78
|
-
message_seq: number;
|
|
79
|
-
/**
|
|
80
|
-
* - 被设置的精华消息元素文本
|
|
81
|
-
*/
|
|
82
|
-
json_elements: string;
|
|
83
|
-
}
|
|
84
|
-
/**
|
|
85
|
-
* - QQ好友信息
|
|
86
|
-
*/
|
|
87
|
-
export interface FriendInfo {
|
|
88
|
-
/**
|
|
89
|
-
* - 用户UID
|
|
90
|
-
*/
|
|
91
|
-
uid: string;
|
|
92
|
-
/**
|
|
93
|
-
* - 用户UIN
|
|
94
|
-
*/
|
|
95
|
-
uin: string;
|
|
96
|
-
/**
|
|
97
|
-
* - qid
|
|
98
|
-
*/
|
|
99
|
-
qid: string;
|
|
100
|
-
/**
|
|
101
|
-
* - 名称
|
|
102
|
-
*/
|
|
103
|
-
nick: string;
|
|
104
|
-
/**
|
|
105
|
-
* - 备注
|
|
106
|
-
*/
|
|
107
|
-
remark?: string;
|
|
108
|
-
/**
|
|
109
|
-
* - 用户等级
|
|
110
|
-
*/
|
|
111
|
-
level?: number;
|
|
112
|
-
/**
|
|
113
|
-
* - 生日
|
|
114
|
-
*/
|
|
115
|
-
birthday?: string;
|
|
116
|
-
/**
|
|
117
|
-
* - 登录天数
|
|
118
|
-
*/
|
|
119
|
-
login_day?: number;
|
|
120
|
-
/**
|
|
121
|
-
* - 点赞数
|
|
122
|
-
*/
|
|
123
|
-
vote_cnt?: number;
|
|
124
|
-
/**
|
|
125
|
-
* - 学校是否已核实
|
|
126
|
-
*/
|
|
127
|
-
is_school_verified?: boolean;
|
|
128
|
-
/**
|
|
129
|
-
* - 年龄
|
|
130
|
-
* - 拓展字段
|
|
131
|
-
*/
|
|
132
|
-
age?: number;
|
|
133
|
-
/**
|
|
134
|
-
* - 性别
|
|
135
|
-
* - 拓展字段
|
|
136
|
-
*/
|
|
137
|
-
sex?: 'male' | 'female' | 'unknown';
|
|
138
|
-
ext?: {
|
|
139
|
-
/**
|
|
140
|
-
* 大会员
|
|
141
|
-
*/
|
|
142
|
-
big_vip?: boolean;
|
|
143
|
-
/**
|
|
144
|
-
* 好莱坞/腾讯视频会员
|
|
145
|
-
*/
|
|
146
|
-
hollywood_vip?: boolean;
|
|
147
|
-
/**
|
|
148
|
-
* QQ会员
|
|
149
|
-
*/
|
|
150
|
-
qq_vip?: boolean;
|
|
151
|
-
/**
|
|
152
|
-
* QQ超级会员
|
|
153
|
-
*/
|
|
154
|
-
super_vip?: boolean;
|
|
155
|
-
/**
|
|
156
|
-
* 是否已经赞过
|
|
157
|
-
*/
|
|
158
|
-
voted?: boolean;
|
|
159
|
-
};
|
|
160
|
-
}
|
|
161
|
-
/**
|
|
162
|
-
* - QQ群信息
|
|
163
|
-
*/
|
|
164
|
-
export interface GroupInfo {
|
|
165
|
-
/**
|
|
166
|
-
* - 群ID
|
|
167
|
-
*/
|
|
168
|
-
group_id: string;
|
|
169
|
-
/**
|
|
170
|
-
* - 群名称
|
|
171
|
-
*/
|
|
172
|
-
group_name: string;
|
|
173
|
-
/**
|
|
174
|
-
* - 群备注
|
|
175
|
-
*/
|
|
176
|
-
group_remark?: string;
|
|
177
|
-
/**
|
|
178
|
-
* - 群主UID
|
|
179
|
-
*/
|
|
180
|
-
owner: string;
|
|
181
|
-
/**
|
|
182
|
-
* - 群管理员UID列表
|
|
183
|
-
*/
|
|
184
|
-
admins: Array<string>;
|
|
185
|
-
/**
|
|
186
|
-
* - 最大成员数
|
|
187
|
-
*/
|
|
188
|
-
max_member_count: number;
|
|
189
|
-
/**
|
|
190
|
-
* - 当前成员数
|
|
191
|
-
*/
|
|
192
|
-
member_count: number;
|
|
193
|
-
/**
|
|
194
|
-
* - 群UIN
|
|
195
|
-
*/
|
|
196
|
-
group_uin?: string;
|
|
197
|
-
/**
|
|
198
|
-
* - 群描述
|
|
199
|
-
*/
|
|
200
|
-
group_desc?: string;
|
|
201
|
-
}
|
|
202
|
-
/**
|
|
203
|
-
* - 群成员信息
|
|
204
|
-
*/
|
|
205
|
-
export interface GroupMemberInfo {
|
|
206
|
-
/**
|
|
207
|
-
* - 用户UID
|
|
208
|
-
*/
|
|
209
|
-
uid: string;
|
|
210
|
-
/**
|
|
211
|
-
* - 用户UIN
|
|
212
|
-
*/
|
|
213
|
-
uin: string;
|
|
214
|
-
/**
|
|
215
|
-
* - 用户角色
|
|
216
|
-
*/
|
|
217
|
-
role: Role;
|
|
218
|
-
/**
|
|
219
|
-
* - 用户昵称
|
|
220
|
-
*/
|
|
221
|
-
nick: string;
|
|
222
|
-
/**
|
|
223
|
-
* - 年龄
|
|
224
|
-
*/
|
|
225
|
-
age: number;
|
|
226
|
-
/**
|
|
227
|
-
* - 群内头衔
|
|
228
|
-
*/
|
|
229
|
-
unique_title: string;
|
|
230
|
-
/**
|
|
231
|
-
* - 群内头衔过期时间
|
|
232
|
-
*/
|
|
233
|
-
unique_title_expire_time: number;
|
|
234
|
-
/**
|
|
235
|
-
* - 群名片
|
|
236
|
-
*/
|
|
237
|
-
card?: string;
|
|
238
|
-
/**
|
|
239
|
-
* - 加群时间
|
|
240
|
-
*/
|
|
241
|
-
join_time?: number;
|
|
242
|
-
/**
|
|
243
|
-
* - 最后活跃时间
|
|
244
|
-
*/
|
|
245
|
-
last_active_time?: number;
|
|
246
|
-
/**
|
|
247
|
-
* - 用户等级
|
|
248
|
-
*/
|
|
249
|
-
level: number;
|
|
250
|
-
/**
|
|
251
|
-
* - 禁言时间
|
|
252
|
-
*/
|
|
253
|
-
shut_up_time: number;
|
|
254
|
-
/**
|
|
255
|
-
* - 距离
|
|
256
|
-
*/
|
|
257
|
-
distance?: number;
|
|
258
|
-
/**
|
|
259
|
-
* - 荣誉列表
|
|
260
|
-
*/
|
|
261
|
-
honors?: Array<number>;
|
|
262
|
-
/**
|
|
263
|
-
* - 是否好友
|
|
264
|
-
*/
|
|
265
|
-
unfriendly?: boolean;
|
|
266
|
-
/**
|
|
267
|
-
* - 是否可修改群名片
|
|
268
|
-
*/
|
|
269
|
-
card_changeable?: boolean;
|
|
270
|
-
}
|
|
271
|
-
/**
|
|
272
|
-
* 群荣誉信息
|
|
273
|
-
*/
|
|
274
|
-
export interface GroupHonorInfo {
|
|
275
|
-
/**
|
|
276
|
-
* - 荣誉成员uid
|
|
277
|
-
*/
|
|
278
|
-
uid: string;
|
|
279
|
-
/**
|
|
280
|
-
* - 荣誉成员uin
|
|
281
|
-
*/
|
|
282
|
-
uin: string;
|
|
283
|
-
/**
|
|
284
|
-
* - 荣誉成员昵称
|
|
285
|
-
*/
|
|
286
|
-
nick: string;
|
|
287
|
-
/**
|
|
288
|
-
* - 荣誉名称
|
|
289
|
-
*/
|
|
290
|
-
honor_name: string;
|
|
291
|
-
/**
|
|
292
|
-
* - 荣誉图标url
|
|
293
|
-
*/
|
|
294
|
-
avatar: string;
|
|
295
|
-
/**
|
|
296
|
-
* - 荣誉id
|
|
297
|
-
*/
|
|
298
|
-
id: number;
|
|
299
|
-
/**
|
|
300
|
-
* - 荣誉描述
|
|
301
|
-
*/
|
|
302
|
-
description: string;
|
|
303
|
-
}
|
|
304
|
-
/**
|
|
305
|
-
* - 群文件信息
|
|
306
|
-
*/
|
|
307
|
-
export interface GroupFileInfo {
|
|
308
|
-
/**
|
|
309
|
-
* - 文件ID
|
|
310
|
-
*/
|
|
311
|
-
file_id: string;
|
|
312
|
-
/**
|
|
313
|
-
* - 文件名
|
|
314
|
-
*/
|
|
315
|
-
file_name: string;
|
|
316
|
-
/**
|
|
317
|
-
* - 文件大小
|
|
318
|
-
*/
|
|
319
|
-
file_size: number;
|
|
320
|
-
/**
|
|
321
|
-
* - 上传时间
|
|
322
|
-
*/
|
|
323
|
-
upload_time: number;
|
|
324
|
-
/**
|
|
325
|
-
* - 过期时间
|
|
326
|
-
*/
|
|
327
|
-
expire_time: number;
|
|
328
|
-
/**
|
|
329
|
-
* - 修改时间
|
|
330
|
-
*/
|
|
331
|
-
modify_time: number;
|
|
332
|
-
/**
|
|
333
|
-
* - 下载次数
|
|
334
|
-
*/
|
|
335
|
-
download_times: number;
|
|
336
|
-
/**
|
|
337
|
-
* - 上传者UID
|
|
338
|
-
*/
|
|
339
|
-
uploader: string;
|
|
340
|
-
/**
|
|
341
|
-
* - 上传者昵称
|
|
342
|
-
*/
|
|
343
|
-
uploader_name: string;
|
|
344
|
-
/**
|
|
345
|
-
* - SHA1
|
|
346
|
-
*/
|
|
347
|
-
sha: string;
|
|
348
|
-
/**
|
|
349
|
-
* - SHA3
|
|
350
|
-
*/
|
|
351
|
-
sha3: string;
|
|
352
|
-
/**
|
|
353
|
-
* - MD5
|
|
354
|
-
*/
|
|
355
|
-
md5: string;
|
|
356
|
-
}
|
|
357
|
-
/**
|
|
358
|
-
* - 群文件夹信息
|
|
359
|
-
*/
|
|
360
|
-
export interface GroupFolderInfo {
|
|
361
|
-
/**
|
|
362
|
-
* - 文件夹ID
|
|
363
|
-
*/
|
|
364
|
-
folder_id: string;
|
|
365
|
-
/**
|
|
366
|
-
* - 文件夹名
|
|
367
|
-
*/
|
|
368
|
-
folder_name: string;
|
|
369
|
-
/**
|
|
370
|
-
* - 文件数量
|
|
371
|
-
*/
|
|
372
|
-
total_file_count: number;
|
|
373
|
-
/**
|
|
374
|
-
* - 创建时间
|
|
375
|
-
*/
|
|
376
|
-
create_time: number;
|
|
377
|
-
/**
|
|
378
|
-
* - 创建者UID
|
|
379
|
-
*/
|
|
380
|
-
creator: string;
|
|
381
|
-
/**
|
|
382
|
-
* - 创建者昵称
|
|
383
|
-
*/
|
|
384
|
-
creator_name: string;
|
|
385
|
-
}
|
|
386
|
-
export interface GetRemainCountAtAllResponse {
|
|
387
|
-
/**
|
|
388
|
-
* - 是否允许at全体成员
|
|
389
|
-
*/
|
|
390
|
-
access_at_all: boolean;
|
|
391
|
-
/**
|
|
392
|
-
* - 全群剩余次数
|
|
393
|
-
*/
|
|
394
|
-
remain_count_for_group: number;
|
|
395
|
-
/**
|
|
396
|
-
* - 个人剩余次数
|
|
397
|
-
*/
|
|
398
|
-
remain_count_for_self: number;
|
|
399
|
-
}
|
package/lib/types/adapter/api.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|