mirai-js 2.1.0 → 2.4.0
Sign up to get free protection for your applications and to get access to all the features.
- package/.eslintrc.json +45 -45
- package/.github/FUNDING.yml +12 -12
- package/.github/dependabot.yml +14 -14
- package/.github/workflows/codeql-analysis.yml +70 -0
- package/.husky/pre-commit +5 -5
- package/LICENSE +661 -661
- package/README.md +17 -283
- package/demo.html +1 -1
- package/demo.js +14 -92
- package/dist/browser/mirai-js.js +1 -1
- package/dist/node/BaseType.d.ts +3 -0
- package/dist/node/Bot.d.ts +95 -8
- package/dist/node/Bot.js +241 -18
- package/dist/node/FileManager.js +15 -6
- package/dist/node/Middleware.js +90 -16
- package/dist/node/core/anno/deleteAnno.js +67 -0
- package/dist/node/core/anno/getAnno.js +70 -0
- package/dist/node/core/anno/publishAnno.js +70 -0
- package/dist/node/core/auth.js +9 -11
- package/dist/node/core/fs/deleteGroupFile.js +71 -0
- package/dist/node/core/fs/getGroupFileInfo.js +77 -0
- package/dist/node/core/fs/getGroupFileList.js +82 -0
- package/dist/node/core/fs/makeGroupDir.js +73 -0
- package/dist/node/core/fs/moveGroupFile.js +77 -0
- package/dist/node/core/fs/renameGroupFile.js +73 -0
- package/dist/node/core/fs/uploadGroupFIle.js +81 -0
- package/dist/node/core/getFriendList.js +9 -11
- package/dist/node/core/getGroupConfig.js +9 -11
- package/dist/node/core/getGroupFileInfo.js +6 -2
- package/dist/node/core/getGroupFileList.js +6 -2
- package/dist/node/core/getGroupList.js +9 -11
- package/dist/node/core/getMemberInfo.js +13 -19
- package/dist/node/core/getMemberList.js +9 -11
- package/dist/node/core/getSessionConfig.js +9 -11
- package/dist/node/core/getUserProfile.js +78 -0
- package/dist/node/core/groupFileDelete.js +6 -2
- package/dist/node/core/groupFileMove.js +6 -2
- package/dist/node/core/groupFileRename.js +6 -2
- package/dist/node/core/mute.js +9 -11
- package/dist/node/core/muteAll.js +9 -11
- package/dist/node/core/quitGroup.js +9 -11
- package/dist/node/core/recall.js +9 -11
- package/dist/node/core/releaseSession.js +10 -11
- package/dist/node/core/removeFriend.js +64 -0
- package/dist/node/core/removeMember.js +9 -11
- package/dist/node/core/responseBotInvitedJoinGroupRequest.js +9 -11
- package/dist/node/core/responseFirendRequest.js +9 -11
- package/dist/node/core/responseMemberJoinRequest.js +9 -11
- package/dist/node/core/sendCommand.js +9 -11
- package/dist/node/core/sendFirendMessage.js +9 -11
- package/dist/node/core/sendGroupMessage.js +9 -11
- package/dist/node/core/sendNudge.js +9 -11
- package/dist/node/core/sendTempMessage.js +9 -11
- package/dist/node/core/setEssence.js +9 -11
- package/dist/node/core/setGroupConfig.js +9 -11
- package/dist/node/core/setMemberAdmin.js +70 -0
- package/dist/node/core/setMemberInfo.js +9 -11
- package/dist/node/core/setSessionConfig.js +9 -11
- package/dist/node/core/startListeningBrowser.js +8 -9
- package/dist/node/core/startListeningNode.js +8 -10
- package/dist/node/core/stopListeningBrowser.js +5 -1
- package/dist/node/core/stopListeningNode.js +5 -1
- package/dist/node/core/unmute.js +9 -11
- package/dist/node/core/unmuteAll.js +9 -11
- package/dist/node/core/uploadFileAndSend.js +6 -1
- package/dist/node/core/uploadImage.js +9 -10
- package/dist/node/core/uploadVoice.js +9 -10
- package/dist/node/core/verify.js +9 -11
- package/dist/node/polyfill/URL.js +5 -0
- package/dist/node/polyfill/wsListener.js +6 -0
- package/docs/checkDocShouldBuild.sh +4 -4
- package/package.json +51 -51
- package/src/BaseType.d.ts +3 -0
- package/src/Bot.d.ts +95 -8
- package/src/Bot.js +154 -9
- package/src/FileManager.js +10 -6
- package/src/Middleware.js +51 -3
- package/src/core/anno/deleteAnno.js +42 -0
- package/src/core/anno/getAnno.js +43 -0
- package/src/core/anno/publishAnno.js +43 -0
- package/src/core/auth.js +5 -7
- package/src/core/fs/deleteGroupFile.js +44 -0
- package/src/core/fs/getGroupFileInfo.js +45 -0
- package/src/core/fs/getGroupFileList.js +46 -0
- package/src/core/fs/makeGroupDir.js +44 -0
- package/src/core/fs/moveGroupFile.js +46 -0
- package/src/core/{groupFileRename.js → fs/renameGroupFile.js} +11 -13
- package/src/core/{uploadFileAndSend.js → fs/uploadGroupFIle.js} +9 -11
- package/src/core/getFriendList.js +5 -7
- package/src/core/getGroupConfig.js +5 -7
- package/src/core/getGroupList.js +5 -7
- package/src/core/getMemberInfo.js +8 -10
- package/src/core/getMemberList.js +5 -7
- package/src/core/getSessionConfig.js +5 -7
- package/src/core/getUserProfile.js +39 -0
- package/src/core/mute.js +5 -7
- package/src/core/muteAll.js +5 -7
- package/src/core/quitGroup.js +5 -7
- package/src/core/recall.js +5 -7
- package/src/core/releaseSession.js +6 -7
- package/src/core/{groupFileDelete.js → removeFriend.js} +11 -17
- package/src/core/removeMember.js +5 -7
- package/src/core/responseBotInvitedJoinGroupRequest.js +5 -7
- package/src/core/responseFirendRequest.js +5 -7
- package/src/core/responseMemberJoinRequest.js +5 -7
- package/src/core/sendCommand.js +5 -7
- package/src/core/sendFirendMessage.js +5 -7
- package/src/core/sendGroupMessage.js +5 -7
- package/src/core/sendNudge.js +5 -7
- package/src/core/sendTempMessage.js +5 -7
- package/src/core/setEssence.js +5 -7
- package/src/core/setGroupConfig.js +5 -7
- package/src/core/setMemberAdmin.js +43 -0
- package/src/core/setMemberInfo.js +5 -7
- package/src/core/setSessionConfig.js +5 -7
- package/src/core/startListeningBrowser.js +4 -6
- package/src/core/startListeningNode.js +4 -6
- package/src/core/stopListeningBrowser.js +3 -0
- package/src/core/stopListeningNode.js +3 -0
- package/src/core/unmute.js +5 -7
- package/src/core/unmuteAll.js +5 -7
- package/src/core/uploadImage.js +5 -7
- package/src/core/uploadVoice.js +5 -7
- package/src/core/verify.js +5 -7
- package/src/polyfill/URL.js +3 -0
- package/src/polyfill/wsListener.js +4 -0
- package/webpack.config.js +4 -0
- package/src/core/getGroupFileInfo.js +0 -44
- package/src/core/getGroupFileList.js +0 -40
- package/src/core/groupFileMove.js +0 -46
@@ -6,17 +6,15 @@ const {
|
|
6
6
|
|
7
7
|
const axios = require('axios').default;
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
({
|
13
|
-
URL
|
14
|
-
} = require('url'));
|
15
|
-
} else {
|
16
|
-
URL = window.URL;
|
17
|
-
}
|
9
|
+
const {
|
10
|
+
URL
|
11
|
+
} = require('../polyfill/URL');
|
18
12
|
|
19
13
|
const errorHandler = require('../util/errorHandler');
|
14
|
+
|
15
|
+
const path = require('path');
|
16
|
+
|
17
|
+
const locationStr = `core.${path.basename(__filename, path.extname(__filename))}`;
|
20
18
|
/**
|
21
19
|
* @description 设置群配置
|
22
20
|
* @param {string} baseUrl mirai-api-http server 的地址
|
@@ -30,7 +28,6 @@ const errorHandler = require('../util/errorHandler');
|
|
30
28
|
* @returns {Object} 结构 { message, code }
|
31
29
|
*/
|
32
30
|
|
33
|
-
|
34
31
|
module.exports = async ({
|
35
32
|
baseUrl,
|
36
33
|
sessionKey,
|
@@ -67,7 +64,7 @@ module.exports = async ({
|
|
67
64
|
}
|
68
65
|
} = responseData;
|
69
66
|
} catch (error) {
|
70
|
-
throw new Error('
|
67
|
+
throw new Error('请求返回格式出错,请检查 mirai-console');
|
71
68
|
} // 抛出 mirai 的异常,到 catch 中处理后再抛出
|
72
69
|
|
73
70
|
|
@@ -80,6 +77,7 @@ module.exports = async ({
|
|
80
77
|
code
|
81
78
|
};
|
82
79
|
} catch (error) {
|
80
|
+
console.error(`mirai-js: error ${locationStr}`);
|
83
81
|
errorHandler(error);
|
84
82
|
}
|
85
83
|
};
|
@@ -0,0 +1,70 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
const {
|
4
|
+
errCodeMap
|
5
|
+
} = require('../util/errCode');
|
6
|
+
|
7
|
+
const axios = require('axios');
|
8
|
+
|
9
|
+
const {
|
10
|
+
URL
|
11
|
+
} = require('../polyfill/URL');
|
12
|
+
|
13
|
+
const errorHandler = require('../util/errorHandler');
|
14
|
+
|
15
|
+
const path = require('path');
|
16
|
+
|
17
|
+
const locationStr = `core.${path.basename(__filename, path.extname(__filename))}`;
|
18
|
+
/**
|
19
|
+
* @description 设置群成员权限
|
20
|
+
* @param {string} baseUrl mirai-api-http server 的地址
|
21
|
+
* @param {string} sessionKey 会话标识
|
22
|
+
* @param {number} target 群成员所在群号
|
23
|
+
* @param {number} memberId 群成员的 qq 号
|
24
|
+
* @param {string} assign 是否设置为管理员
|
25
|
+
* @returns {Object} 结构 { message, code }
|
26
|
+
*/
|
27
|
+
|
28
|
+
module.exports = async ({
|
29
|
+
baseUrl,
|
30
|
+
sessionKey,
|
31
|
+
target,
|
32
|
+
memberId,
|
33
|
+
assign
|
34
|
+
}) => {
|
35
|
+
try {
|
36
|
+
// 拼接 url
|
37
|
+
const url = new URL('/memberAdmin', baseUrl).toString(); // 请求
|
38
|
+
|
39
|
+
const responseData = await axios.post(url, {
|
40
|
+
sessionKey,
|
41
|
+
target,
|
42
|
+
memberId,
|
43
|
+
assign
|
44
|
+
});
|
45
|
+
|
46
|
+
try {
|
47
|
+
var {
|
48
|
+
data: {
|
49
|
+
msg: message,
|
50
|
+
code
|
51
|
+
}
|
52
|
+
} = responseData;
|
53
|
+
} catch (error) {
|
54
|
+
throw new Error('请求返回格式出错,请检查 mirai-console');
|
55
|
+
} // 抛出 mirai 的异常,到 catch 中处理后再抛出
|
56
|
+
|
57
|
+
|
58
|
+
if (code in errCodeMap) {
|
59
|
+
throw new Error(message);
|
60
|
+
}
|
61
|
+
|
62
|
+
return {
|
63
|
+
message,
|
64
|
+
code
|
65
|
+
};
|
66
|
+
} catch (error) {
|
67
|
+
console.error(`mirai-js: error ${locationStr}`);
|
68
|
+
errorHandler(error);
|
69
|
+
}
|
70
|
+
};
|
@@ -6,17 +6,15 @@ const {
|
|
6
6
|
|
7
7
|
const axios = require('axios');
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
({
|
13
|
-
URL
|
14
|
-
} = require('url'));
|
15
|
-
} else {
|
16
|
-
URL = window.URL;
|
17
|
-
}
|
9
|
+
const {
|
10
|
+
URL
|
11
|
+
} = require('../polyfill/URL');
|
18
12
|
|
19
13
|
const errorHandler = require('../util/errorHandler');
|
14
|
+
|
15
|
+
const path = require('path');
|
16
|
+
|
17
|
+
const locationStr = `core.${path.basename(__filename, path.extname(__filename))}`;
|
20
18
|
/**
|
21
19
|
* @description 设置群成员信息
|
22
20
|
* @param {string} baseUrl mirai-api-http server 的地址
|
@@ -28,7 +26,6 @@ const errorHandler = require('../util/errorHandler');
|
|
28
26
|
* @returns {Object} 结构 { message, code }
|
29
27
|
*/
|
30
28
|
|
31
|
-
|
32
29
|
module.exports = async ({
|
33
30
|
baseUrl,
|
34
31
|
sessionKey,
|
@@ -59,7 +56,7 @@ module.exports = async ({
|
|
59
56
|
}
|
60
57
|
} = responseData;
|
61
58
|
} catch (error) {
|
62
|
-
throw new Error('
|
59
|
+
throw new Error('请求返回格式出错,请检查 mirai-console');
|
63
60
|
} // 抛出 mirai 的异常,到 catch 中处理后再抛出
|
64
61
|
|
65
62
|
|
@@ -72,6 +69,7 @@ module.exports = async ({
|
|
72
69
|
code
|
73
70
|
};
|
74
71
|
} catch (error) {
|
72
|
+
console.error(`mirai-js: error ${locationStr}`);
|
75
73
|
errorHandler(error);
|
76
74
|
}
|
77
75
|
};
|
@@ -6,17 +6,15 @@ const {
|
|
6
6
|
|
7
7
|
const axios = require('axios').default;
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
({
|
13
|
-
URL
|
14
|
-
} = require('url'));
|
15
|
-
} else {
|
16
|
-
URL = window.URL;
|
17
|
-
}
|
9
|
+
const {
|
10
|
+
URL
|
11
|
+
} = require('../polyfill/URL');
|
18
12
|
|
19
13
|
const errorHandler = require('../util/errorHandler');
|
14
|
+
|
15
|
+
const path = require('path');
|
16
|
+
|
17
|
+
const locationStr = `core.${path.basename(__filename, path.extname(__filename))}`;
|
20
18
|
/**
|
21
19
|
* @description 设置指定 session 的 config
|
22
20
|
* @param {string} baseUrl mirai-api-http server 的地址
|
@@ -26,7 +24,6 @@ const errorHandler = require('../util/errorHandler');
|
|
26
24
|
* @returns {Object} 结构 { message, code }
|
27
25
|
*/
|
28
26
|
|
29
|
-
|
30
27
|
module.exports = async ({
|
31
28
|
baseUrl,
|
32
29
|
sessionKey,
|
@@ -51,7 +48,7 @@ module.exports = async ({
|
|
51
48
|
}
|
52
49
|
} = responseData;
|
53
50
|
} catch (error) {
|
54
|
-
throw new Error('
|
51
|
+
throw new Error('请求返回格式出错,请检查 mirai-console');
|
55
52
|
} // 抛出 mirai 的异常,到 catch 中处理后再抛出
|
56
53
|
|
57
54
|
|
@@ -64,6 +61,7 @@ module.exports = async ({
|
|
64
61
|
code
|
65
62
|
};
|
66
63
|
} catch (error) {
|
64
|
+
console.error(`mirai-js: error ${locationStr}`);
|
67
65
|
errorHandler(error);
|
68
66
|
}
|
69
67
|
};
|
@@ -1,17 +1,16 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
3
|
const WebSocket = window.WebSocket;
|
4
|
-
let URL;
|
5
4
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
} = require('url'));
|
10
|
-
} else {
|
11
|
-
URL = window.URL;
|
12
|
-
}
|
5
|
+
const {
|
6
|
+
URL
|
7
|
+
} = require('../polyfill/URL');
|
13
8
|
|
14
9
|
const errorHandler = require('../util/errorHandler');
|
10
|
+
|
11
|
+
const path = require('path');
|
12
|
+
|
13
|
+
const locationStr = `core.${path.basename(__filename, path.extname(__filename))}`;
|
15
14
|
/**
|
16
15
|
* @description 开始侦听事件
|
17
16
|
* @param {string} baseUrl mirai-api-http server 的地址
|
@@ -22,7 +21,6 @@ const errorHandler = require('../util/errorHandler');
|
|
22
21
|
* @returns {WebSocket} 建立连接的 WebSocket 实例
|
23
22
|
*/
|
24
23
|
|
25
|
-
|
26
24
|
module.exports = async ({
|
27
25
|
baseUrl,
|
28
26
|
sessionKey,
|
@@ -82,6 +80,7 @@ module.exports = async ({
|
|
82
80
|
|
83
81
|
return ws;
|
84
82
|
} catch (error) {
|
83
|
+
console.error(`mirai-js: error ${locationStr}`);
|
85
84
|
errorHandler(error);
|
86
85
|
}
|
87
86
|
};
|
@@ -2,17 +2,15 @@
|
|
2
2
|
|
3
3
|
const WebSocket = require('ws');
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
({
|
9
|
-
URL
|
10
|
-
} = require('url'));
|
11
|
-
} else {
|
12
|
-
URL = window.URL;
|
13
|
-
}
|
5
|
+
const {
|
6
|
+
URL
|
7
|
+
} = require('../polyfill/URL');
|
14
8
|
|
15
9
|
const errorHandler = require('../util/errorHandler');
|
10
|
+
|
11
|
+
const path = require('path');
|
12
|
+
|
13
|
+
const locationStr = `core.${path.basename(__filename, path.extname(__filename))}`;
|
16
14
|
/**
|
17
15
|
* @description 开始侦听事件
|
18
16
|
* @param {string} baseUrl mirai-api-http server 的地址
|
@@ -24,7 +22,6 @@ const errorHandler = require('../util/errorHandler');
|
|
24
22
|
* @returns {WebSocket} 建立连接的 WebSocket 实例
|
25
23
|
*/
|
26
24
|
|
27
|
-
|
28
25
|
module.exports = async ({
|
29
26
|
baseUrl,
|
30
27
|
sessionKey,
|
@@ -92,6 +89,7 @@ module.exports = async ({
|
|
92
89
|
});
|
93
90
|
return ws;
|
94
91
|
} catch (error) {
|
92
|
+
console.error(`mirai-js: error ${locationStr}`);
|
95
93
|
errorHandler(error);
|
96
94
|
}
|
97
95
|
};
|
@@ -1,12 +1,15 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
3
|
const errorHandler = require('../util/errorHandler');
|
4
|
+
|
5
|
+
const path = require('path');
|
6
|
+
|
7
|
+
const locationStr = `core.${path.basename(__filename, path.extname(__filename))}`;
|
4
8
|
/**
|
5
9
|
* @description 停止侦听事件
|
6
10
|
* @param {WebSocket} 建立连接的 WebSocket 实例
|
7
11
|
*/
|
8
12
|
|
9
|
-
|
10
13
|
module.exports = async wsConnection => {
|
11
14
|
try {
|
12
15
|
// 由于在 ws open 之前关闭连接会抛异常,故应先判断此时是否正在连接中
|
@@ -27,6 +30,7 @@ module.exports = async wsConnection => {
|
|
27
30
|
// do nothing
|
28
31
|
}
|
29
32
|
} catch (error) {
|
33
|
+
console.error(`mirai-js: error ${locationStr}`);
|
30
34
|
errorHandler(error);
|
31
35
|
}
|
32
36
|
};
|
@@ -1,12 +1,15 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
3
|
const errorHandler = require('../util/errorHandler');
|
4
|
+
|
5
|
+
const path = require('path');
|
6
|
+
|
7
|
+
const locationStr = `core.${path.basename(__filename, path.extname(__filename))}`;
|
4
8
|
/**
|
5
9
|
* @description 停止侦听事件
|
6
10
|
* @param {WebSocket} 建立连接的 WebSocket 实例
|
7
11
|
*/
|
8
12
|
|
9
|
-
|
10
13
|
module.exports = async wsConnection => {
|
11
14
|
try {
|
12
15
|
// 由于在 ws open 之前关闭连接会抛异常,故应先判断此时是否正在连接中
|
@@ -27,6 +30,7 @@ module.exports = async wsConnection => {
|
|
27
30
|
// do nothing
|
28
31
|
}
|
29
32
|
} catch (error) {
|
33
|
+
console.error(`mirai-js: error ${locationStr}`);
|
30
34
|
errorHandler(error);
|
31
35
|
}
|
32
36
|
};
|
package/dist/node/core/unmute.js
CHANGED
@@ -6,17 +6,15 @@ const {
|
|
6
6
|
|
7
7
|
const axios = require('axios').default;
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
({
|
13
|
-
URL
|
14
|
-
} = require('url'));
|
15
|
-
} else {
|
16
|
-
URL = window.URL;
|
17
|
-
}
|
9
|
+
const {
|
10
|
+
URL
|
11
|
+
} = require('../polyfill/URL');
|
18
12
|
|
19
13
|
const errorHandler = require('../util/errorHandler');
|
14
|
+
|
15
|
+
const path = require('path');
|
16
|
+
|
17
|
+
const locationStr = `core.${path.basename(__filename, path.extname(__filename))}`;
|
20
18
|
/**
|
21
19
|
* @description 解除禁言
|
22
20
|
* @param {string} baseUrl mirai-api-http server 的主机地址
|
@@ -26,7 +24,6 @@ const errorHandler = require('../util/errorHandler');
|
|
26
24
|
* @returns {Object} 结构 { message, code }
|
27
25
|
*/
|
28
26
|
|
29
|
-
|
30
27
|
module.exports = async ({
|
31
28
|
baseUrl,
|
32
29
|
sessionKey,
|
@@ -51,7 +48,7 @@ module.exports = async ({
|
|
51
48
|
}
|
52
49
|
} = responseData;
|
53
50
|
} catch (error) {
|
54
|
-
throw new Error('
|
51
|
+
throw new Error('请求返回格式出错,请检查 mirai-console');
|
55
52
|
} // 抛出 mirai 的异常,到 catch 中处理后再抛出
|
56
53
|
|
57
54
|
|
@@ -64,6 +61,7 @@ module.exports = async ({
|
|
64
61
|
code
|
65
62
|
};
|
66
63
|
} catch (error) {
|
64
|
+
console.error(`mirai-js: error ${locationStr}`);
|
67
65
|
errorHandler(error);
|
68
66
|
}
|
69
67
|
};
|
@@ -6,17 +6,15 @@ const {
|
|
6
6
|
|
7
7
|
const axios = require('axios').default;
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
({
|
13
|
-
URL
|
14
|
-
} = require('url'));
|
15
|
-
} else {
|
16
|
-
URL = window.URL;
|
17
|
-
}
|
9
|
+
const {
|
10
|
+
URL
|
11
|
+
} = require('../polyfill/URL');
|
18
12
|
|
19
13
|
const errorHandler = require('../util/errorHandler');
|
14
|
+
|
15
|
+
const path = require('path');
|
16
|
+
|
17
|
+
const locationStr = `core.${path.basename(__filename, path.extname(__filename))}`;
|
20
18
|
/**
|
21
19
|
* @description 解除全员禁言
|
22
20
|
* @param {string} baseUrl mirai-api-http server 的主机地址
|
@@ -25,7 +23,6 @@ const errorHandler = require('../util/errorHandler');
|
|
25
23
|
* @returns {Object} 结构 { message, code }
|
26
24
|
*/
|
27
25
|
|
28
|
-
|
29
26
|
module.exports = async ({
|
30
27
|
baseUrl,
|
31
28
|
sessionKey,
|
@@ -48,7 +45,7 @@ module.exports = async ({
|
|
48
45
|
}
|
49
46
|
} = responseData;
|
50
47
|
} catch (error) {
|
51
|
-
throw new Error('
|
48
|
+
throw new Error('请求返回格式出错,请检查 mirai-console');
|
52
49
|
} // 抛出 mirai 的异常,到 catch 中处理后再抛出
|
53
50
|
|
54
51
|
|
@@ -61,6 +58,7 @@ module.exports = async ({
|
|
61
58
|
code
|
62
59
|
};
|
63
60
|
} catch (error) {
|
61
|
+
console.error(`mirai-js: error ${locationStr}`);
|
64
62
|
errorHandler(error);
|
65
63
|
}
|
66
64
|
};
|
@@ -18,6 +18,10 @@ if (!process.browser) {
|
|
18
18
|
|
19
19
|
const errorHandler = require('../util/errorHandler');
|
20
20
|
|
21
|
+
const path = require('path');
|
22
|
+
|
23
|
+
const locationStr = `core.${path.basename(__filename, path.extname(__filename))}`;
|
24
|
+
|
21
25
|
const FormData = require('form-data');
|
22
26
|
/**
|
23
27
|
* @description 上传文件至服务器并发送,返回文件 id
|
@@ -67,7 +71,7 @@ module.exports = async ({
|
|
67
71
|
}
|
68
72
|
} = responseData;
|
69
73
|
} catch (error) {
|
70
|
-
throw new Error('
|
74
|
+
throw new Error('请求返回格式出错,请检查 mirai-console');
|
71
75
|
} // 抛出 mirai 的异常,到 catch 中处理后再抛出
|
72
76
|
|
73
77
|
|
@@ -77,6 +81,7 @@ module.exports = async ({
|
|
77
81
|
|
78
82
|
return id;
|
79
83
|
} catch (error) {
|
84
|
+
console.error(`mirai-js: error ${locationStr}`);
|
80
85
|
errorHandler(error);
|
81
86
|
}
|
82
87
|
};
|
@@ -6,18 +6,16 @@ const {
|
|
6
6
|
|
7
7
|
const axios = require('axios').default;
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
({
|
13
|
-
URL
|
14
|
-
} = require('url'));
|
15
|
-
} else {
|
16
|
-
URL = window.URL;
|
17
|
-
}
|
9
|
+
const {
|
10
|
+
URL
|
11
|
+
} = require('../polyfill/URL');
|
18
12
|
|
19
13
|
const errorHandler = require('../util/errorHandler');
|
20
14
|
|
15
|
+
const path = require('path');
|
16
|
+
|
17
|
+
const locationStr = `core.${path.basename(__filename, path.extname(__filename))}`;
|
18
|
+
|
21
19
|
const FormData = require('form-data');
|
22
20
|
/**
|
23
21
|
* @description 上传图片至服务器,返回指定 type 的 imageId,url,及 path
|
@@ -64,7 +62,7 @@ module.exports = async ({
|
|
64
62
|
}
|
65
63
|
} = responseData;
|
66
64
|
} catch (error) {
|
67
|
-
throw new Error('
|
65
|
+
throw new Error('请求返回格式出错,请检查 mirai-console');
|
68
66
|
} // 抛出 mirai 的异常,到 catch 中处理后再抛出
|
69
67
|
|
70
68
|
|
@@ -78,6 +76,7 @@ module.exports = async ({
|
|
78
76
|
path
|
79
77
|
};
|
80
78
|
} catch (error) {
|
79
|
+
console.error(`mirai-js: error ${locationStr}`);
|
81
80
|
errorHandler(error);
|
82
81
|
}
|
83
82
|
};
|
@@ -6,18 +6,16 @@ const {
|
|
6
6
|
|
7
7
|
const axios = require('axios').default;
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
({
|
13
|
-
URL
|
14
|
-
} = require('url'));
|
15
|
-
} else {
|
16
|
-
URL = window.URL;
|
17
|
-
}
|
9
|
+
const {
|
10
|
+
URL
|
11
|
+
} = require('../polyfill/URL');
|
18
12
|
|
19
13
|
const errorHandler = require('../util/errorHandler');
|
20
14
|
|
15
|
+
const path = require('path');
|
16
|
+
|
17
|
+
const locationStr = `core.${path.basename(__filename, path.extname(__filename))}`;
|
18
|
+
|
21
19
|
const FormData = require('form-data');
|
22
20
|
/**
|
23
21
|
* FIXME: 目前该功能返回的 voiceId 无法正常使用,无法
|
@@ -65,7 +63,7 @@ module.exports = async ({
|
|
65
63
|
}
|
66
64
|
} = responseData;
|
67
65
|
} catch (error) {
|
68
|
-
throw new Error('
|
66
|
+
throw new Error('请求返回格式出错,请检查 mirai-console');
|
69
67
|
} // 抛出 mirai 的异常,到 catch 中处理后再抛出
|
70
68
|
|
71
69
|
|
@@ -79,6 +77,7 @@ module.exports = async ({
|
|
79
77
|
path
|
80
78
|
};
|
81
79
|
} catch (error) {
|
80
|
+
console.error(`mirai-js: error ${locationStr}`);
|
82
81
|
errorHandler(error);
|
83
82
|
}
|
84
83
|
};
|
package/dist/node/core/verify.js
CHANGED
@@ -6,17 +6,15 @@ const {
|
|
6
6
|
|
7
7
|
const axios = require('axios');
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
({
|
13
|
-
URL
|
14
|
-
} = require('url'));
|
15
|
-
} else {
|
16
|
-
URL = window.URL;
|
17
|
-
}
|
9
|
+
const {
|
10
|
+
URL
|
11
|
+
} = require('../polyfill/URL');
|
18
12
|
|
19
13
|
const errorHandler = require('../util/errorHandler');
|
14
|
+
|
15
|
+
const path = require('path');
|
16
|
+
|
17
|
+
const locationStr = `core.${path.basename(__filename, path.extname(__filename))}`;
|
20
18
|
/**
|
21
19
|
* @description 校验 sessionKey,将一个 session 绑定到指定的 qq 上
|
22
20
|
* @param {string} baseUrl mirai-api-http server 的地址
|
@@ -26,7 +24,6 @@ const errorHandler = require('../util/errorHandler');
|
|
26
24
|
* @returns {Object} 结构 { message, code }
|
27
25
|
*/
|
28
26
|
|
29
|
-
|
30
27
|
module.exports = async ({
|
31
28
|
baseUrl,
|
32
29
|
sessionKey,
|
@@ -50,7 +47,7 @@ module.exports = async ({
|
|
50
47
|
}
|
51
48
|
} = responseData;
|
52
49
|
} catch (error) {
|
53
|
-
throw new Error('
|
50
|
+
throw new Error('请求返回格式出错,请检查 mirai-console');
|
54
51
|
} // 抛出 mirai 的异常,到 catch 中处理后再抛出
|
55
52
|
|
56
53
|
|
@@ -63,6 +60,7 @@ module.exports = async ({
|
|
63
60
|
code
|
64
61
|
};
|
65
62
|
} catch (error) {
|
63
|
+
console.error(`mirai-js: error ${locationStr}`);
|
66
64
|
errorHandler(error);
|
67
65
|
}
|
68
66
|
};
|
@@ -0,0 +1,6 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
module.exports = {
|
4
|
+
wsStartListening: process.browser ? require('../core/startListeningBrowser') : require('../core/startListeningNode'),
|
5
|
+
wsStopListening: process.browser ? require('../core/stopListeningBrowser') : require('../core/stopListeningNode')
|
6
|
+
};
|
@@ -1,4 +1,4 @@
|
|
1
|
-
#!/bin/bash
|
2
|
-
|
3
|
-
echo "🛑 - Build cancelled"
|
4
|
-
exit 0;
|
1
|
+
#!/bin/bash
|
2
|
+
|
3
|
+
echo "🛑 - Build cancelled"
|
4
|
+
exit 0;
|