mirai-js 2.2.0 → 2.3.0
Sign up to get free protection for your applications and to get access to all the features.
- package/.github/FUNDING.yml +1 -1
- package/demo.html +1 -1
- package/demo.js +19 -73
- package/dist/browser/mirai-js.js +1 -1
- package/dist/node/Bot.d.ts +16 -4
- package/dist/node/Bot.js +67 -11
- package/dist/node/FileManager.js +15 -6
- package/dist/node/core/auth.js +6 -2
- package/dist/node/core/fs/deleteGroupFile.js +77 -0
- package/dist/node/core/fs/getGroupFileInfo.js +83 -0
- package/dist/node/core/fs/getGroupFileList.js +88 -0
- package/dist/node/core/fs/makeGroupDir.js +79 -0
- package/dist/node/core/fs/moveGroupFile.js +83 -0
- package/dist/node/core/fs/renameGroupFile.js +79 -0
- package/dist/node/core/fs/uploadGroupFIle.js +87 -0
- package/dist/node/core/getFriendList.js +6 -2
- package/dist/node/core/getGroupConfig.js +6 -2
- package/dist/node/core/getGroupFileInfo.js +6 -2
- package/dist/node/core/getGroupFileList.js +6 -2
- package/dist/node/core/getGroupList.js +6 -2
- package/dist/node/core/getMemberInfo.js +6 -2
- package/dist/node/core/getMemberList.js +6 -2
- package/dist/node/core/getSessionConfig.js +6 -2
- 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 +6 -2
- package/dist/node/core/muteAll.js +6 -2
- package/dist/node/core/quitGroup.js +6 -2
- package/dist/node/core/recall.js +6 -2
- package/dist/node/core/releaseSession.js +7 -2
- package/dist/node/core/removeFriend.js +70 -0
- package/dist/node/core/removeMember.js +6 -2
- package/dist/node/core/responseBotInvitedJoinGroupRequest.js +6 -2
- package/dist/node/core/responseFirendRequest.js +6 -2
- package/dist/node/core/responseMemberJoinRequest.js +6 -2
- package/dist/node/core/sendCommand.js +6 -2
- package/dist/node/core/sendFirendMessage.js +6 -2
- package/dist/node/core/sendGroupMessage.js +6 -2
- package/dist/node/core/sendNudge.js +6 -2
- package/dist/node/core/sendTempMessage.js +6 -2
- package/dist/node/core/setEssence.js +6 -2
- package/dist/node/core/setGroupConfig.js +6 -2
- package/dist/node/core/setMemberAdmin.js +76 -0
- package/dist/node/core/setMemberInfo.js +6 -2
- package/dist/node/core/setSessionConfig.js +6 -2
- package/dist/node/core/startListeningBrowser.js +5 -1
- package/dist/node/core/startListeningNode.js +5 -1
- package/dist/node/core/stopListeningBrowser.js +5 -1
- package/dist/node/core/stopListeningNode.js +5 -1
- package/dist/node/core/unmute.js +6 -2
- package/dist/node/core/unmuteAll.js +6 -2
- package/dist/node/core/uploadFileAndSend.js +6 -1
- package/dist/node/core/uploadImage.js +6 -1
- package/dist/node/core/uploadVoice.js +6 -1
- package/dist/node/core/verify.js +6 -2
- package/package.json +2 -2
- package/src/Bot.d.ts +16 -4
- package/src/Bot.js +48 -7
- package/src/FileManager.js +10 -6
- package/src/core/auth.js +4 -1
- package/src/core/fs/deleteGroupFile.js +49 -0
- package/src/core/fs/getGroupFileInfo.js +50 -0
- package/src/core/fs/getGroupFileList.js +51 -0
- package/src/core/fs/makeGroupDir.js +49 -0
- package/src/core/fs/moveGroupFile.js +51 -0
- package/src/core/{groupFileRename.js → fs/renameGroupFile.js} +10 -7
- package/src/core/{uploadFileAndSend.js → fs/uploadGroupFIle.js} +8 -5
- package/src/core/getFriendList.js +4 -1
- package/src/core/getGroupConfig.js +4 -1
- package/src/core/getGroupList.js +4 -1
- package/src/core/getMemberInfo.js +4 -1
- package/src/core/getMemberList.js +4 -1
- package/src/core/getSessionConfig.js +4 -1
- package/src/core/mute.js +4 -1
- package/src/core/muteAll.js +4 -1
- package/src/core/quitGroup.js +4 -1
- package/src/core/recall.js +4 -1
- package/src/core/releaseSession.js +5 -1
- package/src/core/{groupFileDelete.js → removeFriend.js} +10 -11
- package/src/core/removeMember.js +4 -1
- package/src/core/responseBotInvitedJoinGroupRequest.js +4 -1
- package/src/core/responseFirendRequest.js +4 -1
- package/src/core/responseMemberJoinRequest.js +4 -1
- package/src/core/sendCommand.js +4 -1
- package/src/core/sendFirendMessage.js +4 -1
- package/src/core/sendGroupMessage.js +4 -1
- package/src/core/sendNudge.js +4 -1
- package/src/core/sendTempMessage.js +4 -1
- package/src/core/setEssence.js +4 -1
- package/src/core/setGroupConfig.js +4 -1
- package/src/core/setMemberAdmin.js +48 -0
- package/src/core/setMemberInfo.js +4 -1
- package/src/core/setSessionConfig.js +4 -1
- package/src/core/startListeningBrowser.js +3 -0
- package/src/core/startListeningNode.js +3 -0
- package/src/core/stopListeningBrowser.js +3 -0
- package/src/core/stopListeningNode.js +3 -0
- package/src/core/unmute.js +4 -1
- package/src/core/unmuteAll.js +4 -1
- package/src/core/uploadImage.js +4 -1
- package/src/core/uploadVoice.js +4 -1
- package/src/core/verify.js +4 -1
- 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
@@ -0,0 +1,79 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
const {
|
4
|
+
errCodeMap
|
5
|
+
} = require('../../util/errCode');
|
6
|
+
|
7
|
+
const axios = require('axios');
|
8
|
+
|
9
|
+
let URL;
|
10
|
+
|
11
|
+
if (!process.browser) {
|
12
|
+
({
|
13
|
+
URL
|
14
|
+
} = require('url'));
|
15
|
+
} else {
|
16
|
+
URL = window.URL;
|
17
|
+
}
|
18
|
+
|
19
|
+
const errorHandler = require('../../util/errorHandler');
|
20
|
+
|
21
|
+
const path = require('path');
|
22
|
+
|
23
|
+
const locationStr = `core.${path.basename(__filename, path.extname(__filename))}`;
|
24
|
+
/**
|
25
|
+
* @description 重命名群文件
|
26
|
+
* @param {string} baseUrl mirai-api-http server 的地址
|
27
|
+
* @param {string} sessionKey 会话标识
|
28
|
+
* @param {number} id 文件 id
|
29
|
+
* @param {number} group 群号
|
30
|
+
* @param {string} rename 重命名
|
31
|
+
* @returns {Object} 结构 { message, code }
|
32
|
+
*/
|
33
|
+
|
34
|
+
module.exports = async ({
|
35
|
+
baseUrl,
|
36
|
+
sessionKey,
|
37
|
+
id,
|
38
|
+
path,
|
39
|
+
group,
|
40
|
+
renameTo
|
41
|
+
}) => {
|
42
|
+
try {
|
43
|
+
// 拼接 url
|
44
|
+
const url = new URL('/file/rename', baseUrl).toString(); // 请求
|
45
|
+
|
46
|
+
const responseData = await axios.post(url, {
|
47
|
+
sessionKey,
|
48
|
+
id,
|
49
|
+
path,
|
50
|
+
target: group,
|
51
|
+
group,
|
52
|
+
renameTo
|
53
|
+
});
|
54
|
+
|
55
|
+
try {
|
56
|
+
var {
|
57
|
+
data: {
|
58
|
+
msg: message,
|
59
|
+
code
|
60
|
+
}
|
61
|
+
} = responseData;
|
62
|
+
} catch (error) {
|
63
|
+
throw new Error('请求返回格式出错,请检查 mirai-console');
|
64
|
+
} // 抛出 mirai 的异常,到 catch 中处理后再抛出
|
65
|
+
|
66
|
+
|
67
|
+
if (code in errCodeMap) {
|
68
|
+
throw new Error(message);
|
69
|
+
}
|
70
|
+
|
71
|
+
return {
|
72
|
+
message,
|
73
|
+
code
|
74
|
+
};
|
75
|
+
} catch (error) {
|
76
|
+
console.error(`mirai-js: error ${locationStr}`);
|
77
|
+
errorHandler(error);
|
78
|
+
}
|
79
|
+
};
|
@@ -0,0 +1,87 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
const {
|
4
|
+
errCodeMap
|
5
|
+
} = require('../../util/errCode');
|
6
|
+
|
7
|
+
const axios = require('axios').default;
|
8
|
+
|
9
|
+
let URL;
|
10
|
+
|
11
|
+
if (!process.browser) {
|
12
|
+
({
|
13
|
+
URL
|
14
|
+
} = require('url'));
|
15
|
+
} else {
|
16
|
+
URL = window.URL;
|
17
|
+
}
|
18
|
+
|
19
|
+
const errorHandler = require('../../util/errorHandler');
|
20
|
+
|
21
|
+
const path = require('path');
|
22
|
+
|
23
|
+
const locationStr = `core.${path.basename(__filename, path.extname(__filename))}`;
|
24
|
+
|
25
|
+
const FormData = require('form-data');
|
26
|
+
/**
|
27
|
+
* @description 上传文件至服务器并发送,返回文件 id
|
28
|
+
* @param {string} baseUrl mirai-api-http server 的地址
|
29
|
+
* @param {string} sessionKey 会话标识
|
30
|
+
* @param {string} type "friend" 或 "group",目前仅支持 group
|
31
|
+
* @param {string} target 群/好友号
|
32
|
+
* @param {string} path 上传目录id
|
33
|
+
* @param {Buffer} file 文件二进制数据
|
34
|
+
* @returns {string} 文件 id
|
35
|
+
*/
|
36
|
+
|
37
|
+
|
38
|
+
module.exports = async ({
|
39
|
+
baseUrl,
|
40
|
+
sessionKey,
|
41
|
+
type,
|
42
|
+
target,
|
43
|
+
path,
|
44
|
+
file
|
45
|
+
}) => {
|
46
|
+
try {
|
47
|
+
// 拼接 url
|
48
|
+
const targetUrl = new URL('/file/upload', baseUrl).toString(); // 构造 fromdata
|
49
|
+
|
50
|
+
const form = new FormData();
|
51
|
+
form.append('sessionKey', sessionKey);
|
52
|
+
form.append('type', type);
|
53
|
+
form.append('target', target);
|
54
|
+
form.append('path', path);
|
55
|
+
form.append('file', file, {
|
56
|
+
filename: 'payload'
|
57
|
+
}); // 请求
|
58
|
+
|
59
|
+
const responseData = await axios.post(targetUrl, form, {
|
60
|
+
// formdata.getHeaders 将会指定 content-type,同时给定随
|
61
|
+
// 机生成的 boundary,即分隔符,用以分隔多个表单项而不会造成混乱
|
62
|
+
headers: form.getHeaders()
|
63
|
+
});
|
64
|
+
|
65
|
+
try {
|
66
|
+
var {
|
67
|
+
data: {
|
68
|
+
msg: message,
|
69
|
+
code,
|
70
|
+
id
|
71
|
+
}
|
72
|
+
} = responseData;
|
73
|
+
} catch (error) {
|
74
|
+
throw new Error('请求返回格式出错,请检查 mirai-console');
|
75
|
+
} // 抛出 mirai 的异常,到 catch 中处理后再抛出
|
76
|
+
|
77
|
+
|
78
|
+
if (code in errCodeMap) {
|
79
|
+
throw new Error(message);
|
80
|
+
}
|
81
|
+
|
82
|
+
return id;
|
83
|
+
} catch (error) {
|
84
|
+
console.error(`mirai-js: error ${locationStr}`);
|
85
|
+
errorHandler(error);
|
86
|
+
}
|
87
|
+
};
|
@@ -17,6 +17,10 @@ if (!process.browser) {
|
|
17
17
|
}
|
18
18
|
|
19
19
|
const errorHandler = require('../util/errorHandler');
|
20
|
+
|
21
|
+
const path = require('path');
|
22
|
+
|
23
|
+
const locationStr = `core.${path.basename(__filename, path.extname(__filename))}`;
|
20
24
|
/**
|
21
25
|
* @description 获取好友列表
|
22
26
|
* @param {string} baseUrl mirai-api-http server 的地址
|
@@ -24,7 +28,6 @@ const errorHandler = require('../util/errorHandler');
|
|
24
28
|
* @returns {Object[]} 结构 array[...{ id, nickname, remark }]
|
25
29
|
*/
|
26
30
|
|
27
|
-
|
28
31
|
module.exports = async ({
|
29
32
|
baseUrl,
|
30
33
|
sessionKey
|
@@ -48,7 +51,7 @@ module.exports = async ({
|
|
48
51
|
}
|
49
52
|
} = responseData;
|
50
53
|
} catch (error) {
|
51
|
-
throw new Error('
|
54
|
+
throw new Error('请求返回格式出错,请检查 mirai-console');
|
52
55
|
} // 抛出 mirai 的异常,到 catch 中处理后再抛出
|
53
56
|
|
54
57
|
|
@@ -58,6 +61,7 @@ module.exports = async ({
|
|
58
61
|
|
59
62
|
return data;
|
60
63
|
} catch (error) {
|
64
|
+
console.error(`mirai-js: error ${locationStr}`);
|
61
65
|
errorHandler(error);
|
62
66
|
}
|
63
67
|
};
|
@@ -17,6 +17,10 @@ if (!process.browser) {
|
|
17
17
|
}
|
18
18
|
|
19
19
|
const errorHandler = require('../util/errorHandler');
|
20
|
+
|
21
|
+
const path = require('path');
|
22
|
+
|
23
|
+
const locationStr = `core.${path.basename(__filename, path.extname(__filename))}`;
|
20
24
|
/**
|
21
25
|
* @description 获取群配置
|
22
26
|
* @param {string} baseUrl mirai-api-http server 的地址
|
@@ -25,7 +29,6 @@ const errorHandler = require('../util/errorHandler');
|
|
25
29
|
* @returns {Object}
|
26
30
|
*/
|
27
31
|
|
28
|
-
|
29
32
|
module.exports = async ({
|
30
33
|
baseUrl,
|
31
34
|
sessionKey,
|
@@ -51,7 +54,7 @@ module.exports = async ({
|
|
51
54
|
}
|
52
55
|
} = responseData;
|
53
56
|
} catch (error) {
|
54
|
-
throw new Error('
|
57
|
+
throw new Error('请求返回格式出错,请检查 mirai-console');
|
55
58
|
} // 抛出 mirai 的异常,到 catch 中处理后再抛出
|
56
59
|
|
57
60
|
|
@@ -61,6 +64,7 @@ module.exports = async ({
|
|
61
64
|
|
62
65
|
return data;
|
63
66
|
} catch (error) {
|
67
|
+
console.error(`mirai-js: error ${locationStr}`);
|
64
68
|
errorHandler(error);
|
65
69
|
}
|
66
70
|
};
|
@@ -17,6 +17,10 @@ if (!process.browser) {
|
|
17
17
|
}
|
18
18
|
|
19
19
|
const errorHandler = require('../util/errorHandler');
|
20
|
+
|
21
|
+
const path = require('path');
|
22
|
+
|
23
|
+
const locationStr = `core.${path.basename(__filename, path.extname(__filename))}`;
|
20
24
|
/**
|
21
25
|
* @description 获取群文件详细信息
|
22
26
|
* @param {string} baseUrl mirai-api-http server 的地址
|
@@ -30,7 +34,6 @@ const errorHandler = require('../util/errorHandler');
|
|
30
34
|
* }
|
31
35
|
*/
|
32
36
|
|
33
|
-
|
34
37
|
module.exports = async ({
|
35
38
|
baseUrl,
|
36
39
|
sessionKey,
|
@@ -58,7 +61,7 @@ module.exports = async ({
|
|
58
61
|
}
|
59
62
|
} = responseData;
|
60
63
|
} catch (error) {
|
61
|
-
throw new Error('
|
64
|
+
throw new Error('请求返回格式出错,请检查 mirai-console');
|
62
65
|
} // 抛出 mirai 的异常,到 catch 中处理后再抛出
|
63
66
|
|
64
67
|
|
@@ -68,6 +71,7 @@ module.exports = async ({
|
|
68
71
|
|
69
72
|
return data;
|
70
73
|
} catch (error) {
|
74
|
+
console.error(`mirai-js: error ${locationStr}`);
|
71
75
|
errorHandler(error);
|
72
76
|
}
|
73
77
|
};
|
@@ -17,6 +17,10 @@ if (!process.browser) {
|
|
17
17
|
}
|
18
18
|
|
19
19
|
const errorHandler = require('../util/errorHandler');
|
20
|
+
|
21
|
+
const path = require('path');
|
22
|
+
|
23
|
+
const locationStr = `core.${path.basename(__filename, path.extname(__filename))}`;
|
20
24
|
/**
|
21
25
|
* @description 获取群文件列表
|
22
26
|
* @param {string} baseUrl mirai-api-http server 的地址
|
@@ -26,7 +30,6 @@ const errorHandler = require('../util/errorHandler');
|
|
26
30
|
* @returns {Object[]} 结构 array[...{ id, name, path, isFile }]
|
27
31
|
*/
|
28
32
|
|
29
|
-
|
30
33
|
module.exports = async ({
|
31
34
|
baseUrl,
|
32
35
|
sessionKey,
|
@@ -54,7 +57,7 @@ module.exports = async ({
|
|
54
57
|
}
|
55
58
|
} = responseData;
|
56
59
|
} catch (error) {
|
57
|
-
throw new Error('
|
60
|
+
throw new Error('请求返回格式出错,请检查 mirai-console');
|
58
61
|
} // 抛出 mirai 的异常,到 catch 中处理后再抛出
|
59
62
|
|
60
63
|
|
@@ -64,6 +67,7 @@ module.exports = async ({
|
|
64
67
|
|
65
68
|
return data;
|
66
69
|
} catch (error) {
|
70
|
+
console.error(`mirai-js: error ${locationStr}`);
|
67
71
|
errorHandler(error);
|
68
72
|
}
|
69
73
|
};
|
@@ -17,6 +17,10 @@ if (!process.browser) {
|
|
17
17
|
}
|
18
18
|
|
19
19
|
const errorHandler = require('../util/errorHandler');
|
20
|
+
|
21
|
+
const path = require('path');
|
22
|
+
|
23
|
+
const locationStr = `core.${path.basename(__filename, path.extname(__filename))}`;
|
20
24
|
/**
|
21
25
|
* @description 获取群列表
|
22
26
|
* @param {string} baseUrl mirai-api-http server 的地址
|
@@ -24,7 +28,6 @@ const errorHandler = require('../util/errorHandler');
|
|
24
28
|
* @returns {Object[]} 结构 array[...{ id, name, permission }]
|
25
29
|
*/
|
26
30
|
|
27
|
-
|
28
31
|
module.exports = async ({
|
29
32
|
baseUrl,
|
30
33
|
sessionKey
|
@@ -48,7 +51,7 @@ module.exports = async ({
|
|
48
51
|
}
|
49
52
|
} = responseData;
|
50
53
|
} catch (error) {
|
51
|
-
throw new Error('
|
54
|
+
throw new Error('请求返回格式出错,请检查 mirai-console');
|
52
55
|
} // 抛出 mirai 的异常,到 catch 中处理后再抛出
|
53
56
|
|
54
57
|
|
@@ -58,6 +61,7 @@ module.exports = async ({
|
|
58
61
|
|
59
62
|
return data;
|
60
63
|
} catch (error) {
|
64
|
+
console.error(`mirai-js: error ${locationStr}`);
|
61
65
|
errorHandler(error);
|
62
66
|
}
|
63
67
|
};
|
@@ -17,6 +17,10 @@ if (!process.browser) {
|
|
17
17
|
}
|
18
18
|
|
19
19
|
const errorHandler = require('../util/errorHandler');
|
20
|
+
|
21
|
+
const path = require('path');
|
22
|
+
|
23
|
+
const locationStr = `core.${path.basename(__filename, path.extname(__filename))}`;
|
20
24
|
/**
|
21
25
|
* @description 获取群成员信息
|
22
26
|
* @param {string} baseUrl mirai-api-http server 的地址
|
@@ -26,7 +30,6 @@ const errorHandler = require('../util/errorHandler');
|
|
26
30
|
* @returns {Object} 结构 { name, specialTitle } 群名片和群头衔
|
27
31
|
*/
|
28
32
|
|
29
|
-
|
30
33
|
module.exports = async ({
|
31
34
|
baseUrl,
|
32
35
|
sessionKey,
|
@@ -55,7 +58,7 @@ module.exports = async ({
|
|
55
58
|
}
|
56
59
|
} = responseData;
|
57
60
|
} catch (error) {
|
58
|
-
throw new Error('
|
61
|
+
throw new Error('请求返回格式出错,请检查 mirai-console');
|
59
62
|
} // 抛出 mirai 的异常,到 catch 中处理后再抛出
|
60
63
|
|
61
64
|
|
@@ -68,6 +71,7 @@ module.exports = async ({
|
|
68
71
|
specialTitle
|
69
72
|
};
|
70
73
|
} catch (error) {
|
74
|
+
console.error(`mirai-js: error ${locationStr}`);
|
71
75
|
errorHandler(error);
|
72
76
|
}
|
73
77
|
};
|
@@ -17,6 +17,10 @@ if (!process.browser) {
|
|
17
17
|
}
|
18
18
|
|
19
19
|
const errorHandler = require('../util/errorHandler');
|
20
|
+
|
21
|
+
const path = require('path');
|
22
|
+
|
23
|
+
const locationStr = `core.${path.basename(__filename, path.extname(__filename))}`;
|
20
24
|
/**
|
21
25
|
* @description 获取指定群的成员列表
|
22
26
|
* @param {string} baseUrl mirai-api-http server 的地址
|
@@ -31,7 +35,6 @@ const errorHandler = require('../util/errorHandler');
|
|
31
35
|
* }]
|
32
36
|
*/
|
33
37
|
|
34
|
-
|
35
38
|
module.exports = async ({
|
36
39
|
baseUrl,
|
37
40
|
sessionKey,
|
@@ -57,7 +60,7 @@ module.exports = async ({
|
|
57
60
|
}
|
58
61
|
} = responseData;
|
59
62
|
} catch (error) {
|
60
|
-
throw new Error('
|
63
|
+
throw new Error('请求返回格式出错,请检查 mirai-console');
|
61
64
|
} // 抛出 mirai 的异常,到 catch 中处理后再抛出
|
62
65
|
|
63
66
|
|
@@ -67,6 +70,7 @@ module.exports = async ({
|
|
67
70
|
|
68
71
|
return data;
|
69
72
|
} catch (error) {
|
73
|
+
console.error(`mirai-js: error ${locationStr}`);
|
70
74
|
errorHandler(error);
|
71
75
|
}
|
72
76
|
};
|
@@ -17,6 +17,10 @@ if (!process.browser) {
|
|
17
17
|
}
|
18
18
|
|
19
19
|
const errorHandler = require('../util/errorHandler');
|
20
|
+
|
21
|
+
const path = require('path');
|
22
|
+
|
23
|
+
const locationStr = `core.${path.basename(__filename, path.extname(__filename))}`;
|
20
24
|
/**
|
21
25
|
* @description 获取指定 session 的 config
|
22
26
|
* @param {string} baseUrl mirai-api-http server 的地址
|
@@ -24,7 +28,6 @@ const errorHandler = require('../util/errorHandler');
|
|
24
28
|
* @returns {Object} 结构 { cacheSize, enableWebsocket }
|
25
29
|
*/
|
26
30
|
|
27
|
-
|
28
31
|
module.exports = async ({
|
29
32
|
baseUrl,
|
30
33
|
sessionKey
|
@@ -51,7 +54,7 @@ module.exports = async ({
|
|
51
54
|
}
|
52
55
|
} = responseData;
|
53
56
|
} catch (error) {
|
54
|
-
throw new Error('
|
57
|
+
throw new Error('请求返回格式出错,请检查 mirai-console');
|
55
58
|
} // 抛出 mirai 的异常,到 catch 中处理后再抛出
|
56
59
|
|
57
60
|
|
@@ -64,6 +67,7 @@ module.exports = async ({
|
|
64
67
|
enableWebsocket
|
65
68
|
};
|
66
69
|
} catch (error) {
|
70
|
+
console.error(`mirai-js: error ${locationStr}`);
|
67
71
|
errorHandler(error);
|
68
72
|
}
|
69
73
|
};
|
@@ -17,6 +17,10 @@ if (!process.browser) {
|
|
17
17
|
}
|
18
18
|
|
19
19
|
const errorHandler = require('../util/errorHandler');
|
20
|
+
|
21
|
+
const path = require('path');
|
22
|
+
|
23
|
+
const locationStr = `core.${path.basename(__filename, path.extname(__filename))}`;
|
20
24
|
/**
|
21
25
|
* @description 删除群文件
|
22
26
|
* @param {string} baseUrl mirai-api-http server 的地址
|
@@ -26,7 +30,6 @@ const errorHandler = require('../util/errorHandler');
|
|
26
30
|
* @returns {Object} 结构 { message, code }
|
27
31
|
*/
|
28
32
|
|
29
|
-
|
30
33
|
module.exports = async ({
|
31
34
|
baseUrl,
|
32
35
|
sessionKey,
|
@@ -51,7 +54,7 @@ module.exports = async ({
|
|
51
54
|
}
|
52
55
|
} = responseData;
|
53
56
|
} catch (error) {
|
54
|
-
throw new Error('
|
57
|
+
throw new Error('请求返回格式出错,请检查 mirai-console');
|
55
58
|
} // 抛出 mirai 的异常,到 catch 中处理后再抛出
|
56
59
|
|
57
60
|
|
@@ -64,6 +67,7 @@ module.exports = async ({
|
|
64
67
|
code
|
65
68
|
};
|
66
69
|
} catch (error) {
|
70
|
+
console.error(`mirai-js: error ${locationStr}`);
|
67
71
|
errorHandler(error);
|
68
72
|
}
|
69
73
|
};
|
@@ -17,6 +17,10 @@ if (!process.browser) {
|
|
17
17
|
}
|
18
18
|
|
19
19
|
const errorHandler = require('../util/errorHandler');
|
20
|
+
|
21
|
+
const path = require('path');
|
22
|
+
|
23
|
+
const locationStr = `core.${path.basename(__filename, path.extname(__filename))}`;
|
20
24
|
/**
|
21
25
|
* @description 移动群文件
|
22
26
|
* @param {string} baseUrl mirai-api-http server 的地址
|
@@ -27,7 +31,6 @@ const errorHandler = require('../util/errorHandler');
|
|
27
31
|
* @returns {Object} 结构 { message, code }
|
28
32
|
*/
|
29
33
|
|
30
|
-
|
31
34
|
module.exports = async ({
|
32
35
|
baseUrl,
|
33
36
|
sessionKey,
|
@@ -54,7 +57,7 @@ module.exports = async ({
|
|
54
57
|
}
|
55
58
|
} = responseData;
|
56
59
|
} catch (error) {
|
57
|
-
throw new Error('
|
60
|
+
throw new Error('请求返回格式出错,请检查 mirai-console');
|
58
61
|
} // 抛出 mirai 的异常,到 catch 中处理后再抛出
|
59
62
|
|
60
63
|
|
@@ -67,6 +70,7 @@ module.exports = async ({
|
|
67
70
|
code
|
68
71
|
};
|
69
72
|
} catch (error) {
|
73
|
+
console.error(`mirai-js: error ${locationStr}`);
|
70
74
|
errorHandler(error);
|
71
75
|
}
|
72
76
|
};
|
@@ -17,6 +17,10 @@ if (!process.browser) {
|
|
17
17
|
}
|
18
18
|
|
19
19
|
const errorHandler = require('../util/errorHandler');
|
20
|
+
|
21
|
+
const path = require('path');
|
22
|
+
|
23
|
+
const locationStr = `core.${path.basename(__filename, path.extname(__filename))}`;
|
20
24
|
/**
|
21
25
|
* @description 重命名群文件
|
22
26
|
* @param {string} baseUrl mirai-api-http server 的地址
|
@@ -27,7 +31,6 @@ const errorHandler = require('../util/errorHandler');
|
|
27
31
|
* @returns {Object} 结构 { message, code }
|
28
32
|
*/
|
29
33
|
|
30
|
-
|
31
34
|
module.exports = async ({
|
32
35
|
baseUrl,
|
33
36
|
sessionKey,
|
@@ -54,7 +57,7 @@ module.exports = async ({
|
|
54
57
|
}
|
55
58
|
} = responseData;
|
56
59
|
} catch (error) {
|
57
|
-
throw new Error('
|
60
|
+
throw new Error('请求返回格式出错,请检查 mirai-console');
|
58
61
|
} // 抛出 mirai 的异常,到 catch 中处理后再抛出
|
59
62
|
|
60
63
|
|
@@ -67,6 +70,7 @@ module.exports = async ({
|
|
67
70
|
code
|
68
71
|
};
|
69
72
|
} catch (error) {
|
73
|
+
console.error(`mirai-js: error ${locationStr}`);
|
70
74
|
errorHandler(error);
|
71
75
|
}
|
72
76
|
};
|
package/dist/node/core/mute.js
CHANGED
@@ -17,6 +17,10 @@ if (!process.browser) {
|
|
17
17
|
}
|
18
18
|
|
19
19
|
const errorHandler = require('../util/errorHandler');
|
20
|
+
|
21
|
+
const path = require('path');
|
22
|
+
|
23
|
+
const locationStr = `core.${path.basename(__filename, path.extname(__filename))}`;
|
20
24
|
/**
|
21
25
|
* @description 禁言群成员
|
22
26
|
* @param {string} baseUrl mirai-api-http server 的主机地址
|
@@ -27,7 +31,6 @@ const errorHandler = require('../util/errorHandler');
|
|
27
31
|
* @returns {Object} 结构 { message, code }
|
28
32
|
*/
|
29
33
|
|
30
|
-
|
31
34
|
module.exports = async ({
|
32
35
|
baseUrl,
|
33
36
|
sessionKey,
|
@@ -54,7 +57,7 @@ module.exports = async ({
|
|
54
57
|
}
|
55
58
|
} = responseData;
|
56
59
|
} catch (error) {
|
57
|
-
throw new Error('
|
60
|
+
throw new Error('请求返回格式出错,请检查 mirai-console');
|
58
61
|
} // 抛出 mirai 的异常,到 catch 中处理后再抛出
|
59
62
|
|
60
63
|
|
@@ -67,6 +70,7 @@ module.exports = async ({
|
|
67
70
|
code
|
68
71
|
};
|
69
72
|
} catch (error) {
|
73
|
+
console.error(`mirai-js: error ${locationStr}`);
|
70
74
|
errorHandler(error);
|
71
75
|
}
|
72
76
|
};
|
@@ -17,6 +17,10 @@ if (!process.browser) {
|
|
17
17
|
}
|
18
18
|
|
19
19
|
const errorHandler = require('../util/errorHandler');
|
20
|
+
|
21
|
+
const path = require('path');
|
22
|
+
|
23
|
+
const locationStr = `core.${path.basename(__filename, path.extname(__filename))}`;
|
20
24
|
/**
|
21
25
|
* @description 全员禁言
|
22
26
|
* @param {string} baseUrl mirai-api-http server 的主机地址
|
@@ -25,7 +29,6 @@ const errorHandler = require('../util/errorHandler');
|
|
25
29
|
* @returns {Object} 结构 { message, code }
|
26
30
|
*/
|
27
31
|
|
28
|
-
|
29
32
|
module.exports = async ({
|
30
33
|
baseUrl,
|
31
34
|
sessionKey,
|
@@ -48,7 +51,7 @@ module.exports = async ({
|
|
48
51
|
}
|
49
52
|
} = responseData;
|
50
53
|
} catch (error) {
|
51
|
-
throw new Error('
|
54
|
+
throw new Error('请求返回格式出错,请检查 mirai-console');
|
52
55
|
} // 抛出 mirai 的异常,到 catch 中处理后再抛出
|
53
56
|
|
54
57
|
|
@@ -61,6 +64,7 @@ module.exports = async ({
|
|
61
64
|
code
|
62
65
|
};
|
63
66
|
} catch (error) {
|
67
|
+
console.error(`mirai-js: error ${locationStr}`);
|
64
68
|
errorHandler(error);
|
65
69
|
}
|
66
70
|
};
|
@@ -17,6 +17,10 @@ if (!process.browser) {
|
|
17
17
|
}
|
18
18
|
|
19
19
|
const errorHandler = require('../util/errorHandler');
|
20
|
+
|
21
|
+
const path = require('path');
|
22
|
+
|
23
|
+
const locationStr = `core.${path.basename(__filename, path.extname(__filename))}`;
|
20
24
|
/**
|
21
25
|
* @description 退出群聊
|
22
26
|
* @param {string} baseUrl mirai-api-http server 的地址
|
@@ -25,7 +29,6 @@ const errorHandler = require('../util/errorHandler');
|
|
25
29
|
* @returns {Object} 结构 { message, code }
|
26
30
|
*/
|
27
31
|
|
28
|
-
|
29
32
|
module.exports = async ({
|
30
33
|
baseUrl,
|
31
34
|
sessionKey,
|
@@ -48,7 +51,7 @@ module.exports = async ({
|
|
48
51
|
}
|
49
52
|
} = responseData;
|
50
53
|
} catch (error) {
|
51
|
-
throw new Error('
|
54
|
+
throw new Error('请求返回格式出错,请检查 mirai-console');
|
52
55
|
} // 抛出 mirai 的异常,到 catch 中处理后再抛出
|
53
56
|
|
54
57
|
|
@@ -61,6 +64,7 @@ module.exports = async ({
|
|
61
64
|
code
|
62
65
|
};
|
63
66
|
} catch (error) {
|
67
|
+
console.error(`mirai-js: error ${locationStr}`);
|
64
68
|
errorHandler(error);
|
65
69
|
}
|
66
70
|
};
|
package/dist/node/core/recall.js
CHANGED
@@ -17,6 +17,10 @@ if (!process.browser) {
|
|
17
17
|
}
|
18
18
|
|
19
19
|
const errorHandler = require('../util/errorHandler');
|
20
|
+
|
21
|
+
const path = require('path');
|
22
|
+
|
23
|
+
const locationStr = `core.${path.basename(__filename, path.extname(__filename))}`;
|
20
24
|
/**
|
21
25
|
* @description 撤回由 messageId 确定的消息
|
22
26
|
* @param {string} baseUrl mirai-api-http server 的主机地址
|
@@ -25,7 +29,6 @@ const errorHandler = require('../util/errorHandler');
|
|
25
29
|
* @returns {Object} 结构 { message, code }
|
26
30
|
*/
|
27
31
|
|
28
|
-
|
29
32
|
module.exports = async ({
|
30
33
|
baseUrl,
|
31
34
|
sessionKey,
|
@@ -48,7 +51,7 @@ module.exports = async ({
|
|
48
51
|
}
|
49
52
|
} = responseData;
|
50
53
|
} catch (error) {
|
51
|
-
throw new Error('
|
54
|
+
throw new Error('请求返回格式出错,请检查 mirai-console');
|
52
55
|
} // 抛出 mirai 的异常,到 catch 中处理后再抛出
|
53
56
|
|
54
57
|
|
@@ -61,6 +64,7 @@ module.exports = async ({
|
|
61
64
|
code
|
62
65
|
};
|
63
66
|
} catch (error) {
|
67
|
+
console.error(`mirai-js: error ${locationStr}`);
|
64
68
|
errorHandler(error);
|
65
69
|
}
|
66
70
|
};
|