mirai-js 2.2.0 → 2.4.1
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/.github/FUNDING.yml +1 -1
- package/README.md +17 -283
- package/demo.html +1 -1
- package/demo.js +13 -71
- package/dist/browser/mirai-js.js +1 -1
- package/dist/node/BaseType.d.ts +5 -2
- package/dist/node/Bot.d.ts +95 -8
- package/dist/node/Bot.js +233 -10
- package/dist/node/FileManager.js +15 -6
- 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/package.json +2 -2
- package/src/BaseType.d.ts +5 -2
- package/src/Bot.d.ts +95 -8
- package/src/Bot.js +154 -9
- package/src/FileManager.js +10 -6
- 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 的地址
|
@@ -27,7 +25,6 @@ const errorHandler = require('../util/errorHandler');
|
|
27
25
|
* @returns {Object} 结构 { message, code }
|
28
26
|
*/
|
29
27
|
|
30
|
-
|
31
28
|
module.exports = async ({
|
32
29
|
baseUrl,
|
33
30
|
sessionKey,
|
@@ -54,7 +51,7 @@ module.exports = async ({
|
|
54
51
|
}
|
55
52
|
} = responseData;
|
56
53
|
} catch (error) {
|
57
|
-
throw new Error('
|
54
|
+
throw new Error('请求返回格式出错,请检查 mirai-console');
|
58
55
|
} // 抛出 mirai 的异常,到 catch 中处理后再抛出
|
59
56
|
|
60
57
|
|
@@ -67,6 +64,7 @@ module.exports = async ({
|
|
67
64
|
code
|
68
65
|
};
|
69
66
|
} catch (error) {
|
67
|
+
console.error(`mirai-js: error ${locationStr}`);
|
70
68
|
errorHandler(error);
|
71
69
|
}
|
72
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
|
* ! 自动同意时,不会触发该事件
|
22
20
|
* @description 响应机器人被邀请入群请求
|
@@ -30,7 +28,6 @@ const errorHandler = require('../util/errorHandler');
|
|
30
28
|
* @returns {void}
|
31
29
|
*/
|
32
30
|
|
33
|
-
|
34
31
|
module.exports = async ({
|
35
32
|
baseUrl,
|
36
33
|
sessionKey,
|
@@ -61,7 +58,7 @@ module.exports = async ({
|
|
61
58
|
}
|
62
59
|
} = responseData;
|
63
60
|
} catch (error) {
|
64
|
-
throw new Error('
|
61
|
+
throw new Error('请求返回格式出错,请检查 mirai-console');
|
65
62
|
} // 抛出 mirai 的异常,到 catch 中处理后再抛出
|
66
63
|
|
67
64
|
|
@@ -69,6 +66,7 @@ module.exports = async ({
|
|
69
66
|
throw new Error(serverMessage);
|
70
67
|
}
|
71
68
|
} catch (error) {
|
69
|
+
console.error(`mirai-js: error ${locationStr}`);
|
72
70
|
errorHandler(error);
|
73
71
|
}
|
74
72
|
};
|
@@ -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 的地址
|
@@ -29,7 +27,6 @@ const errorHandler = require('../util/errorHandler');
|
|
29
27
|
* @returns {void}
|
30
28
|
*/
|
31
29
|
|
32
|
-
|
33
30
|
module.exports = async ({
|
34
31
|
baseUrl,
|
35
32
|
sessionKey,
|
@@ -60,7 +57,7 @@ module.exports = async ({
|
|
60
57
|
}
|
61
58
|
} = responseData;
|
62
59
|
} catch (error) {
|
63
|
-
throw new Error('
|
60
|
+
throw new Error('请求返回格式出错,请检查 mirai-console');
|
64
61
|
} // 抛出 mirai 的异常,到 catch 中处理后再抛出
|
65
62
|
|
66
63
|
|
@@ -68,6 +65,7 @@ module.exports = async ({
|
|
68
65
|
throw new Error(serverMessage);
|
69
66
|
}
|
70
67
|
} catch (error) {
|
68
|
+
console.error(`mirai-js: error ${locationStr}`);
|
71
69
|
errorHandler(error);
|
72
70
|
}
|
73
71
|
};
|
@@ -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
|
* FIXME: mirai-core 的问题,有时候收不到 MemberJoinRequestEvent 事件
|
22
20
|
* 该功能未经测试
|
@@ -31,7 +29,6 @@ const errorHandler = require('../util/errorHandler');
|
|
31
29
|
* @returns {void}
|
32
30
|
*/
|
33
31
|
|
34
|
-
|
35
32
|
module.exports = async ({
|
36
33
|
baseUrl,
|
37
34
|
sessionKey,
|
@@ -62,7 +59,7 @@ module.exports = async ({
|
|
62
59
|
}
|
63
60
|
} = responseData;
|
64
61
|
} catch (error) {
|
65
|
-
throw new Error('
|
62
|
+
throw new Error('请求返回格式出错,请检查 mirai-console');
|
66
63
|
} // 抛出 mirai 的异常,到 catch 中处理后再抛出
|
67
64
|
|
68
65
|
|
@@ -70,6 +67,7 @@ module.exports = async ({
|
|
70
67
|
throw new Error(serverMessage);
|
71
68
|
}
|
72
69
|
} catch (error) {
|
70
|
+
console.error(`mirai-js: error ${locationStr}`);
|
73
71
|
errorHandler(error);
|
74
72
|
}
|
75
73
|
};
|
@@ -6,17 +6,15 @@ const {
|
|
6
6
|
errCodeMap
|
7
7
|
} = require('../util/errCode');
|
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 向 mirai-console 发送指令
|
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,
|
@@ -49,7 +46,7 @@ module.exports = async ({
|
|
49
46
|
}
|
50
47
|
} = responseData;
|
51
48
|
} catch (error) {
|
52
|
-
throw new Error('
|
49
|
+
throw new Error('请求返回格式出错,请检查 mirai-console');
|
53
50
|
} // 抛出 mirai 的异常,到 catch 中处理后再抛出
|
54
51
|
|
55
52
|
|
@@ -62,6 +59,7 @@ module.exports = async ({
|
|
62
59
|
code
|
63
60
|
};
|
64
61
|
} catch (error) {
|
62
|
+
console.error(`mirai-js: error ${locationStr}`);
|
65
63
|
errorHandler(error);
|
66
64
|
}
|
67
65
|
};
|
@@ -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 向 qq 好友发送消息
|
22
20
|
* @param {string} baseUrl mirai-api-http server 的地址
|
@@ -27,7 +25,6 @@ const errorHandler = require('../util/errorHandler');
|
|
27
25
|
* @returns {Object} 结构 { message, code, messageId }
|
28
26
|
*/
|
29
27
|
|
30
|
-
|
31
28
|
module.exports = async ({
|
32
29
|
baseUrl,
|
33
30
|
sessionKey,
|
@@ -55,7 +52,7 @@ module.exports = async ({
|
|
55
52
|
}
|
56
53
|
} = responseData;
|
57
54
|
} catch (error) {
|
58
|
-
throw new Error('
|
55
|
+
throw new Error('请求返回格式出错,请检查 mirai-console');
|
59
56
|
} // 抛出 mirai 的异常,到 catch 中处理后再抛出
|
60
57
|
|
61
58
|
|
@@ -65,6 +62,7 @@ module.exports = async ({
|
|
65
62
|
|
66
63
|
return messageId;
|
67
64
|
} catch (error) {
|
65
|
+
console.error(`mirai-js: error ${locationStr}`);
|
68
66
|
errorHandler(error);
|
69
67
|
}
|
70
68
|
};
|
@@ -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 向 qq 群发送消息
|
22
20
|
* @param {string} baseUrl mirai-api-http server 的地址
|
@@ -27,7 +25,6 @@ const errorHandler = require('../util/errorHandler');
|
|
27
25
|
* @returns {Object} 结构 { message, code, messageId }
|
28
26
|
*/
|
29
27
|
|
30
|
-
|
31
28
|
module.exports = async ({
|
32
29
|
baseUrl,
|
33
30
|
sessionKey,
|
@@ -55,7 +52,7 @@ module.exports = async ({
|
|
55
52
|
}
|
56
53
|
} = responseData;
|
57
54
|
} catch (error) {
|
58
|
-
throw new Error('
|
55
|
+
throw new Error('请求返回格式出错,请检查 mirai-console');
|
59
56
|
} // 抛出 mirai 的异常,到 catch 中处理后再抛出
|
60
57
|
|
61
58
|
|
@@ -65,6 +62,7 @@ module.exports = async ({
|
|
65
62
|
|
66
63
|
return messageId;
|
67
64
|
} catch (error) {
|
65
|
+
console.error(`mirai-js: error ${locationStr}`);
|
68
66
|
errorHandler(error);
|
69
67
|
}
|
70
68
|
};
|
@@ -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 的地址
|
@@ -27,7 +25,6 @@ const errorHandler = require('../util/errorHandler');
|
|
27
25
|
* @returns {Object} 结构 { message, code, messageId }
|
28
26
|
*/
|
29
27
|
|
30
|
-
|
31
28
|
module.exports = async ({
|
32
29
|
baseUrl,
|
33
30
|
sessionKey,
|
@@ -54,7 +51,7 @@ module.exports = async ({
|
|
54
51
|
}
|
55
52
|
} = responseData;
|
56
53
|
} catch (error) {
|
57
|
-
throw new Error('
|
54
|
+
throw new Error('请求返回格式出错,请检查 mirai-console');
|
58
55
|
} // 抛出 mirai 的异常,到 catch 中处理后再抛出
|
59
56
|
|
60
57
|
|
@@ -67,6 +64,7 @@ module.exports = async ({
|
|
67
64
|
code
|
68
65
|
};
|
69
66
|
} catch (error) {
|
67
|
+
console.error(`mirai-js: error ${locationStr}`);
|
70
68
|
errorHandler(error);
|
71
69
|
}
|
72
70
|
};
|
@@ -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 的地址
|
@@ -28,7 +26,6 @@ const errorHandler = require('../util/errorHandler');
|
|
28
26
|
* @returns {Object} 结构 { message, code, messageId }
|
29
27
|
*/
|
30
28
|
|
31
|
-
|
32
29
|
module.exports = async ({
|
33
30
|
baseUrl,
|
34
31
|
sessionKey,
|
@@ -63,7 +60,7 @@ module.exports = async ({
|
|
63
60
|
}
|
64
61
|
} = responseData;
|
65
62
|
} catch (error) {
|
66
|
-
throw new Error('
|
63
|
+
throw new Error('请求返回格式出错,请检查 mirai-console');
|
67
64
|
} // 抛出 mirai 的异常,到 catch 中处理后再抛出
|
68
65
|
|
69
66
|
|
@@ -73,6 +70,7 @@ module.exports = async ({
|
|
73
70
|
|
74
71
|
return messageId;
|
75
72
|
} catch (error) {
|
73
|
+
console.error(`mirai-js: error ${locationStr}`);
|
76
74
|
errorHandler(error);
|
77
75
|
}
|
78
76
|
};
|
@@ -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
|
};
|
@@ -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
|
};
|