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.
Files changed (122) hide show
  1. package/.github/FUNDING.yml +1 -1
  2. package/README.md +17 -283
  3. package/demo.html +1 -1
  4. package/demo.js +13 -71
  5. package/dist/browser/mirai-js.js +1 -1
  6. package/dist/node/BaseType.d.ts +5 -2
  7. package/dist/node/Bot.d.ts +95 -8
  8. package/dist/node/Bot.js +233 -10
  9. package/dist/node/FileManager.js +15 -6
  10. package/dist/node/core/anno/deleteAnno.js +67 -0
  11. package/dist/node/core/anno/getAnno.js +70 -0
  12. package/dist/node/core/anno/publishAnno.js +70 -0
  13. package/dist/node/core/auth.js +9 -11
  14. package/dist/node/core/fs/deleteGroupFile.js +71 -0
  15. package/dist/node/core/fs/getGroupFileInfo.js +77 -0
  16. package/dist/node/core/fs/getGroupFileList.js +82 -0
  17. package/dist/node/core/fs/makeGroupDir.js +73 -0
  18. package/dist/node/core/fs/moveGroupFile.js +77 -0
  19. package/dist/node/core/fs/renameGroupFile.js +73 -0
  20. package/dist/node/core/fs/uploadGroupFIle.js +81 -0
  21. package/dist/node/core/getFriendList.js +9 -11
  22. package/dist/node/core/getGroupConfig.js +9 -11
  23. package/dist/node/core/getGroupFileInfo.js +6 -2
  24. package/dist/node/core/getGroupFileList.js +6 -2
  25. package/dist/node/core/getGroupList.js +9 -11
  26. package/dist/node/core/getMemberInfo.js +13 -19
  27. package/dist/node/core/getMemberList.js +9 -11
  28. package/dist/node/core/getSessionConfig.js +9 -11
  29. package/dist/node/core/getUserProfile.js +78 -0
  30. package/dist/node/core/groupFileDelete.js +6 -2
  31. package/dist/node/core/groupFileMove.js +6 -2
  32. package/dist/node/core/groupFileRename.js +6 -2
  33. package/dist/node/core/mute.js +9 -11
  34. package/dist/node/core/muteAll.js +9 -11
  35. package/dist/node/core/quitGroup.js +9 -11
  36. package/dist/node/core/recall.js +9 -11
  37. package/dist/node/core/releaseSession.js +10 -11
  38. package/dist/node/core/removeFriend.js +64 -0
  39. package/dist/node/core/removeMember.js +9 -11
  40. package/dist/node/core/responseBotInvitedJoinGroupRequest.js +9 -11
  41. package/dist/node/core/responseFirendRequest.js +9 -11
  42. package/dist/node/core/responseMemberJoinRequest.js +9 -11
  43. package/dist/node/core/sendCommand.js +9 -11
  44. package/dist/node/core/sendFirendMessage.js +9 -11
  45. package/dist/node/core/sendGroupMessage.js +9 -11
  46. package/dist/node/core/sendNudge.js +9 -11
  47. package/dist/node/core/sendTempMessage.js +9 -11
  48. package/dist/node/core/setEssence.js +9 -11
  49. package/dist/node/core/setGroupConfig.js +9 -11
  50. package/dist/node/core/setMemberAdmin.js +70 -0
  51. package/dist/node/core/setMemberInfo.js +9 -11
  52. package/dist/node/core/setSessionConfig.js +9 -11
  53. package/dist/node/core/startListeningBrowser.js +8 -9
  54. package/dist/node/core/startListeningNode.js +8 -10
  55. package/dist/node/core/stopListeningBrowser.js +5 -1
  56. package/dist/node/core/stopListeningNode.js +5 -1
  57. package/dist/node/core/unmute.js +9 -11
  58. package/dist/node/core/unmuteAll.js +9 -11
  59. package/dist/node/core/uploadFileAndSend.js +6 -1
  60. package/dist/node/core/uploadImage.js +9 -10
  61. package/dist/node/core/uploadVoice.js +9 -10
  62. package/dist/node/core/verify.js +9 -11
  63. package/dist/node/polyfill/URL.js +5 -0
  64. package/dist/node/polyfill/wsListener.js +6 -0
  65. package/package.json +2 -2
  66. package/src/BaseType.d.ts +5 -2
  67. package/src/Bot.d.ts +95 -8
  68. package/src/Bot.js +154 -9
  69. package/src/FileManager.js +10 -6
  70. package/src/core/anno/deleteAnno.js +42 -0
  71. package/src/core/anno/getAnno.js +43 -0
  72. package/src/core/anno/publishAnno.js +43 -0
  73. package/src/core/auth.js +5 -7
  74. package/src/core/fs/deleteGroupFile.js +44 -0
  75. package/src/core/fs/getGroupFileInfo.js +45 -0
  76. package/src/core/fs/getGroupFileList.js +46 -0
  77. package/src/core/fs/makeGroupDir.js +44 -0
  78. package/src/core/fs/moveGroupFile.js +46 -0
  79. package/src/core/{groupFileRename.js → fs/renameGroupFile.js} +11 -13
  80. package/src/core/{uploadFileAndSend.js → fs/uploadGroupFIle.js} +9 -11
  81. package/src/core/getFriendList.js +5 -7
  82. package/src/core/getGroupConfig.js +5 -7
  83. package/src/core/getGroupList.js +5 -7
  84. package/src/core/getMemberInfo.js +8 -10
  85. package/src/core/getMemberList.js +5 -7
  86. package/src/core/getSessionConfig.js +5 -7
  87. package/src/core/getUserProfile.js +39 -0
  88. package/src/core/mute.js +5 -7
  89. package/src/core/muteAll.js +5 -7
  90. package/src/core/quitGroup.js +5 -7
  91. package/src/core/recall.js +5 -7
  92. package/src/core/releaseSession.js +6 -7
  93. package/src/core/{groupFileDelete.js → removeFriend.js} +11 -17
  94. package/src/core/removeMember.js +5 -7
  95. package/src/core/responseBotInvitedJoinGroupRequest.js +5 -7
  96. package/src/core/responseFirendRequest.js +5 -7
  97. package/src/core/responseMemberJoinRequest.js +5 -7
  98. package/src/core/sendCommand.js +5 -7
  99. package/src/core/sendFirendMessage.js +5 -7
  100. package/src/core/sendGroupMessage.js +5 -7
  101. package/src/core/sendNudge.js +5 -7
  102. package/src/core/sendTempMessage.js +5 -7
  103. package/src/core/setEssence.js +5 -7
  104. package/src/core/setGroupConfig.js +5 -7
  105. package/src/core/setMemberAdmin.js +43 -0
  106. package/src/core/setMemberInfo.js +5 -7
  107. package/src/core/setSessionConfig.js +5 -7
  108. package/src/core/startListeningBrowser.js +4 -6
  109. package/src/core/startListeningNode.js +4 -6
  110. package/src/core/stopListeningBrowser.js +3 -0
  111. package/src/core/stopListeningNode.js +3 -0
  112. package/src/core/unmute.js +5 -7
  113. package/src/core/unmuteAll.js +5 -7
  114. package/src/core/uploadImage.js +5 -7
  115. package/src/core/uploadVoice.js +5 -7
  116. package/src/core/verify.js +5 -7
  117. package/src/polyfill/URL.js +3 -0
  118. package/src/polyfill/wsListener.js +4 -0
  119. package/webpack.config.js +4 -0
  120. package/src/core/getGroupFileInfo.js +0 -44
  121. package/src/core/getGroupFileList.js +0 -40
  122. package/src/core/groupFileMove.js +0 -46
@@ -6,17 +6,15 @@ const {
6
6
 
7
7
  const axios = require('axios').default;
8
8
 
9
- let URL;
10
-
11
- if (!process.browser) {
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('core.setSessionConfig 请求返回格式出错,请检查 mirai-console');
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
- if (!process.browser) {
7
- ({
8
- URL
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
- let URL;
6
-
7
- if (!process.browser) {
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
  };
@@ -6,17 +6,15 @@ const {
6
6
 
7
7
  const axios = require('axios').default;
8
8
 
9
- let URL;
10
-
11
- if (!process.browser) {
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('core.unmute 请求返回格式出错,请检查 mirai-console');
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
- let URL;
10
-
11
- if (!process.browser) {
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('core.unmuteAll 请求返回格式出错,请检查 mirai-console');
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('core.uploadFileAndSend 请求返回格式出错,请检查 mirai-console');
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
- let URL;
10
-
11
- if (!process.browser) {
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('core.uploadImage 请求返回格式出错,请检查 mirai-console');
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
- let URL;
10
-
11
- if (!process.browser) {
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('core.uploadVoice 请求返回格式出错,请检查 mirai-console');
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
  };
@@ -6,17 +6,15 @@ const {
6
6
 
7
7
  const axios = require('axios');
8
8
 
9
- let URL;
10
-
11
- if (!process.browser) {
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('core.verify 请求返回格式出错,请检查 mirai-console');
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,5 @@
1
+ "use strict";
2
+
3
+ module.exports = {
4
+ URL: process.browser ? window.URL : require('url').URL
5
+ };
@@ -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
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mirai-js",
3
- "version": "2.2.0",
3
+ "version": "2.4.1",
4
4
  "description": "QQ robot development framework based on Mirai-api-http.",
5
5
  "main": "dist/node/index.js",
6
6
  "scripts": {
@@ -32,7 +32,7 @@
32
32
  "dependencies": {
33
33
  "axios": "^0.24.0",
34
34
  "form-data": "^3.0.0",
35
- "ws": "^7.4.2"
35
+ "ws": "^8.4.0"
36
36
  },
37
37
  "devDependencies": {
38
38
  "@babel/cli": "^7.13.14",
package/src/BaseType.d.ts CHANGED
@@ -98,6 +98,9 @@ type GroupPermission =
98
98
  | 'ADMINISTRATOR'
99
99
  | 'MEMBER';
100
100
 
101
+ // 性别
102
+ type SEX = 'UNKNOWN' | 'MALE' | 'FEMALE'
103
+
101
104
  // 消息处理器
102
105
  type Processor = (data: any) => Promise<any> | any;
103
106
 
@@ -112,8 +115,8 @@ export {
112
115
  // 图片 id 语音 id 消息 id
113
116
  ImageId, VoiceId, MessageId,
114
117
 
115
- // 事件类型 群成员权限
116
- EventType, GroupPermission,
118
+ // 事件类型 群成员权限 性别
119
+ EventType, GroupPermission, SEX,
117
120
 
118
121
  // 消息处理器
119
122
  Processor,
package/src/Bot.d.ts CHANGED
@@ -2,8 +2,8 @@ import {
2
2
  // 图片 id 语音 id 消息 id
3
3
  ImageId, VoiceId, MessageId,
4
4
 
5
- // 事件类型 群成员权限
6
- EventType, GroupPermission,
5
+ // 事件类型 群成员权限 性别
6
+ EventType, GroupPermission, SEX,
7
7
 
8
8
  // 接口 原始消息类型 事件处理器类型
9
9
  MessageChainGetable, BotConfigGetable, MessageType, Processor
@@ -146,9 +146,9 @@ export class Bot implements BotConfigGetable {
146
146
 
147
147
  /**
148
148
  * @description 上传语音至服务器,返回 voiceId, url 及 path
149
- * @param {string} type 目前仅支持 "group",请忽略该参数
150
- * @param {Buffer} voice 二选一,语音二进制数据
151
- * @param {string} filename 二选一,语音文件路径
149
+ * @param type 目前仅支持 "group",请忽略该参数
150
+ * @param voice 二选一,语音二进制数据
151
+ * @param filename 二选一,语音文件路径
152
152
  */
153
153
  uploadVoice({ type, voice, filename }: Bot.UploadVoiceOptions): Promise<Bot.VoiceInfo>;
154
154
 
@@ -173,7 +173,13 @@ export class Bot implements BotConfigGetable {
173
173
  * @param group 必选,群成员所在群号
174
174
  * @param qq 必选,群成员的 qq 号
175
175
  */
176
- getMemberInfo(): Promise<Bot.MemberDetails>;
176
+ getMemberInfo({ group, qq }: Bot.GetMemberInfoOptions): Promise<Bot.MemberDetails>;
177
+
178
+ /**
179
+ * @description 获取群成员信息
180
+ * @param qq 必选,用户的 qq 号
181
+ */
182
+ getUserProfile({ qq }: Bot.GetUserProfileOptions): Promise<Bot.UserProfile>;
177
183
 
178
184
  /**
179
185
  * @description 设置群成员信息
@@ -181,8 +187,31 @@ export class Bot implements BotConfigGetable {
181
187
  * @param qq 必选,群成员的 qq 号
182
188
  * @param name 可选,要设置的群名片
183
189
  * @param title 可选,要设置的群头衔
190
+ * @param permission 可选,要设置的群头衔
191
+ */
192
+ setMemberInfo({ group, qq, name, title, permission }: Bot.SetMemberInfoOptions): Promise<void>;
193
+
194
+ /**
195
+ * @description 获取群公告列表迭代器
196
+ * @param group 必选,群号
197
+ * @returns 迭代器
198
+ */
199
+ getAnnoIter({ group }: Bot.GetAnnoIterOptions): AsyncGenerator<Bot.AnnoInfo>;
200
+
201
+ /**
202
+ * @description 发布群公告
203
+ * @param group 必选,群号
204
+ * @param content 必选,公告内容
205
+ */
206
+ publishAnno({ group, content, pinned }: Bot.PublishAnnoOptions): Promise<void>;
207
+
208
+ /**
209
+ * @description 删除群公告
210
+ * @param {number} group 必选,群号
211
+ * @param {string} fid 必选,公告 id
212
+ * @reaturns {void}
184
213
  */
185
- setMemberInfo({ group, qq, name, title }: Bot.SetMemberInfoOptions): Promise<void>;
214
+ deleteAnno({ group, fid }: Bot.DeleteAnnoOptions): Promise<void>;
186
215
 
187
216
  /**
188
217
  * @description 禁言群成员
@@ -219,6 +248,12 @@ export class Bot implements BotConfigGetable {
219
248
  */
220
249
  removeMember({ group, qq, message }: Bot.RemoveMemberOptions): Promise<void>;
221
250
 
251
+ /**
252
+ * @description 删除好友
253
+ * @param qq 欲删除的好友 qq 号
254
+ */
255
+ removeFriend({ qq }: Bot.RemoveFriendOptions): Promise<void>;
256
+
222
257
  /**
223
258
  * @description 移除群成员
224
259
  * @param group 必选,欲移除的成员所在群号
@@ -363,8 +398,18 @@ declare namespace Bot {
363
398
  permission: GroupPermission;
364
399
  }
365
400
 
401
+ interface GetMemberInfoOptions {
402
+ group: number;
403
+ qq: number;
404
+ }
405
+
366
406
  interface MemberDetails {
367
- name: string;
407
+ id: number;
408
+ joinTimestamp: number;
409
+ lastSpeakTimestamp: number;
410
+ memberName: string;
411
+ nuteTimeRemaining: number;
412
+ permission: GroupPermission;
368
413
  title: string;
369
414
  }
370
415
 
@@ -372,11 +417,49 @@ declare namespace Bot {
372
417
  group: number;
373
418
  }
374
419
 
420
+ interface GetUserProfileOptions {
421
+ qq: number;
422
+ }
423
+
424
+ interface UserProfile {
425
+ nickname: string;
426
+ email: string;
427
+ age: number;
428
+ level: number;
429
+ sign: string;
430
+ sex: SEX;
431
+ }
432
+
375
433
  interface SetMemberInfoOptions {
376
434
  group: number;
377
435
  qq: number;
378
436
  name?: string;
379
437
  title?: string;
438
+ permission?: GroupPermission
439
+ }
440
+
441
+ interface GetAnnoIterOptions {
442
+ group: number;
443
+ }
444
+
445
+ interface PublishAnnoOptions {
446
+ group: number;
447
+ content: string;
448
+ pinned: boolean;
449
+ }
450
+
451
+ interface DeleteAnnoOptions {
452
+ group: number;
453
+ fid: string;
454
+ }
455
+ interface AnnoInfo {
456
+ group: { id: number; name: string; permission: GroupPermission; };
457
+ content: string;
458
+ senderId: number;
459
+ fid: string;
460
+ allConfirmed: boolean;
461
+ confirmedMembersCount: number;
462
+ publicationTime: number;
380
463
  }
381
464
 
382
465
  interface MuteOptions {
@@ -404,6 +487,10 @@ declare namespace Bot {
404
487
  message?: string;
405
488
  }
406
489
 
490
+ interface RemoveFriendOptions {
491
+ qq: number;
492
+ }
493
+
407
494
  interface QuitGroupOptions {
408
495
  group: number;
409
496
  }