mirai-js 2.7.0-beta.1.0.0 → 2.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (106) hide show
  1. package/dist/browser/mirai-js.js +1 -1
  2. package/dist/node/Bot.js +17 -5
  3. package/dist/node/FileManager.js +6 -2
  4. package/dist/node/core/anno/deleteAnno.js +5 -1
  5. package/dist/node/core/anno/getAnno.js +5 -1
  6. package/dist/node/core/anno/publishAnno.js +5 -1
  7. package/dist/node/core/auth.js +5 -1
  8. package/dist/node/core/fs/deleteGroupFile.js +5 -1
  9. package/dist/node/core/fs/getGroupFileInfo.js +5 -1
  10. package/dist/node/core/fs/getGroupFileList.js +5 -1
  11. package/dist/node/core/fs/makeGroupDir.js +5 -1
  12. package/dist/node/core/fs/moveGroupFile.js +5 -1
  13. package/dist/node/core/fs/renameGroupFile.js +5 -1
  14. package/dist/node/core/fs/uploadGroupFIle.js +5 -1
  15. package/dist/node/core/getFriendList.js +5 -1
  16. package/dist/node/core/getGroupConfig.js +5 -1
  17. package/dist/node/core/getGroupList.js +5 -1
  18. package/dist/node/core/getMemberInfo.js +5 -1
  19. package/dist/node/core/getMemberList.js +10 -2
  20. package/dist/node/core/getSessionConfig.js +5 -1
  21. package/dist/node/core/getUserProfile.js +5 -1
  22. package/dist/node/core/mute.js +5 -1
  23. package/dist/node/core/muteAll.js +5 -1
  24. package/dist/node/core/quitGroup.js +5 -1
  25. package/dist/node/core/recall.js +5 -1
  26. package/dist/node/core/releaseSession.js +5 -1
  27. package/dist/node/core/removeFriend.js +5 -1
  28. package/dist/node/core/removeMember.js +5 -1
  29. package/dist/node/core/responseBotInvitedJoinGroupRequest.js +5 -1
  30. package/dist/node/core/responseFirendRequest.js +5 -1
  31. package/dist/node/core/responseMemberJoinRequest.js +5 -1
  32. package/dist/node/core/sendCommand.js +5 -1
  33. package/dist/node/core/sendFriendMessage.js +5 -1
  34. package/dist/node/core/sendGroupMessage.js +5 -1
  35. package/dist/node/core/sendNudge.js +5 -1
  36. package/dist/node/core/sendTempMessage.js +5 -1
  37. package/dist/node/core/setEssence.js +5 -1
  38. package/dist/node/core/setGroupConfig.js +5 -1
  39. package/dist/node/core/setMemberAdmin.js +5 -1
  40. package/dist/node/core/setMemberInfo.js +5 -1
  41. package/dist/node/core/setSessionConfig.js +5 -1
  42. package/dist/node/core/startListeningBrowser.js +5 -1
  43. package/dist/node/core/startListeningNode.js +5 -1
  44. package/dist/node/core/stopListeningBrowser.js +5 -1
  45. package/dist/node/core/stopListeningNode.js +5 -1
  46. package/dist/node/core/unmute.js +5 -1
  47. package/dist/node/core/unmuteAll.js +5 -1
  48. package/dist/node/core/uploadImage.js +5 -1
  49. package/dist/node/core/uploadVoice.js +5 -1
  50. package/dist/node/core/verify.js +5 -1
  51. package/dist/node/polyfill/URL.js +5 -1
  52. package/dist/node/polyfill/wsListener.js +6 -2
  53. package/dist/node/util/isBrowserEnv.js +5 -0
  54. package/package.json +1 -1
  55. package/src/Bot.js +5 -2
  56. package/src/FileManager.js +3 -2
  57. package/src/core/anno/deleteAnno.js +2 -1
  58. package/src/core/anno/getAnno.js +2 -1
  59. package/src/core/anno/publishAnno.js +2 -1
  60. package/src/core/auth.js +2 -1
  61. package/src/core/fs/deleteGroupFile.js +2 -1
  62. package/src/core/fs/getGroupFileInfo.js +2 -1
  63. package/src/core/fs/getGroupFileList.js +2 -1
  64. package/src/core/fs/makeGroupDir.js +2 -1
  65. package/src/core/fs/moveGroupFile.js +2 -1
  66. package/src/core/fs/renameGroupFile.js +2 -1
  67. package/src/core/fs/uploadGroupFIle.js +2 -1
  68. package/src/core/getFriendList.js +2 -1
  69. package/src/core/getGroupConfig.js +2 -1
  70. package/src/core/getGroupList.js +2 -1
  71. package/src/core/getMemberInfo.js +2 -1
  72. package/src/core/getMemberList.js +8 -2
  73. package/src/core/getSessionConfig.js +2 -1
  74. package/src/core/getUserProfile.js +2 -1
  75. package/src/core/mute.js +2 -1
  76. package/src/core/muteAll.js +2 -1
  77. package/src/core/quitGroup.js +2 -1
  78. package/src/core/recall.js +2 -1
  79. package/src/core/releaseSession.js +2 -1
  80. package/src/core/removeFriend.js +2 -1
  81. package/src/core/removeMember.js +2 -1
  82. package/src/core/responseBotInvitedJoinGroupRequest.js +2 -1
  83. package/src/core/responseFirendRequest.js +2 -1
  84. package/src/core/responseMemberJoinRequest.js +2 -1
  85. package/src/core/sendCommand.js +2 -1
  86. package/src/core/sendFriendMessage.js +2 -1
  87. package/src/core/sendGroupMessage.js +2 -1
  88. package/src/core/sendNudge.js +2 -1
  89. package/src/core/sendTempMessage.js +2 -1
  90. package/src/core/setEssence.js +2 -1
  91. package/src/core/setGroupConfig.js +2 -1
  92. package/src/core/setMemberAdmin.js +2 -1
  93. package/src/core/setMemberInfo.js +2 -1
  94. package/src/core/setSessionConfig.js +2 -1
  95. package/src/core/startListeningBrowser.js +2 -1
  96. package/src/core/startListeningNode.js +2 -1
  97. package/src/core/stopListeningBrowser.js +2 -1
  98. package/src/core/stopListeningNode.js +2 -1
  99. package/src/core/unmute.js +2 -1
  100. package/src/core/unmuteAll.js +2 -1
  101. package/src/core/uploadImage.js +2 -1
  102. package/src/core/uploadVoice.js +2 -1
  103. package/src/core/verify.js +2 -1
  104. package/src/polyfill/URL.js +3 -1
  105. package/src/polyfill/wsListener.js +4 -2
  106. package/src/util/isBrowserEnv.js +3 -0
@@ -14,7 +14,11 @@ const errorHandler = require('../../util/errorHandler');
14
14
 
15
15
  const path = require('path');
16
16
 
17
- const locationStr = window === undefined ? `core.${path.basename(__filename, path.extname(__filename))}` : 'borwser';
17
+ const {
18
+ isBrowserEnv
19
+ } = require('../../util/isBrowserEnv');
20
+
21
+ const locationStr = !isBrowserEnv() ? `core.${path.basename(__filename, path.extname(__filename))}` : 'borwser';
18
22
  /**
19
23
  * @description 获取群文件列表
20
24
  * @param {string} baseUrl mirai-api-http server 的地址
@@ -14,7 +14,11 @@ const errorHandler = require('../../util/errorHandler');
14
14
 
15
15
  const path = require('path');
16
16
 
17
- const locationStr = window === undefined ? `core.${path.basename(__filename, path.extname(__filename))}` : 'borwser';
17
+ const {
18
+ isBrowserEnv
19
+ } = require('../../util/isBrowserEnv');
20
+
21
+ const locationStr = !isBrowserEnv() ? `core.${path.basename(__filename, path.extname(__filename))}` : 'borwser';
18
22
  /**
19
23
  * @description 新建群文件夹
20
24
  * @param {string} baseUrl mirai-api-http server 的地址
@@ -14,7 +14,11 @@ const errorHandler = require('../../util/errorHandler');
14
14
 
15
15
  const path = require('path');
16
16
 
17
- const locationStr = window === undefined ? `core.${path.basename(__filename, path.extname(__filename))}` : 'borwser';
17
+ const {
18
+ isBrowserEnv
19
+ } = require('../../util/isBrowserEnv');
20
+
21
+ const locationStr = !isBrowserEnv() ? `core.${path.basename(__filename, path.extname(__filename))}` : 'borwser';
18
22
  /**
19
23
  * @description 移动群文件
20
24
  * @param {string} baseUrl mirai-api-http server 的地址
@@ -14,7 +14,11 @@ const errorHandler = require('../../util/errorHandler');
14
14
 
15
15
  const path = require('path');
16
16
 
17
- const locationStr = window === undefined ? `core.${path.basename(__filename, path.extname(__filename))}` : 'borwser';
17
+ const {
18
+ isBrowserEnv
19
+ } = require('../../util/isBrowserEnv');
20
+
21
+ const locationStr = !isBrowserEnv() ? `core.${path.basename(__filename, path.extname(__filename))}` : 'borwser';
18
22
  /**
19
23
  * @description 重命名群文件
20
24
  * @param {string} baseUrl mirai-api-http server 的地址
@@ -14,7 +14,11 @@ const errorHandler = require('../../util/errorHandler');
14
14
 
15
15
  const path = require('path');
16
16
 
17
- const locationStr = window === undefined ? `core.${path.basename(__filename, path.extname(__filename))}` : 'borwser';
17
+ const {
18
+ isBrowserEnv
19
+ } = require('../../util/isBrowserEnv');
20
+
21
+ const locationStr = !isBrowserEnv() ? `core.${path.basename(__filename, path.extname(__filename))}` : 'borwser';
18
22
 
19
23
  const FormData = require('form-data');
20
24
  /**
@@ -14,7 +14,11 @@ const errorHandler = require('../util/errorHandler');
14
14
 
15
15
  const path = require('path');
16
16
 
17
- const locationStr = window === undefined ? `core.${path.basename(__filename, path.extname(__filename))}` : 'borwser';
17
+ const {
18
+ isBrowserEnv
19
+ } = require('../util/isBrowserEnv');
20
+
21
+ const locationStr = !isBrowserEnv() ? `core.${path.basename(__filename, path.extname(__filename))}` : 'borwser';
18
22
  /**
19
23
  * @description 获取好友列表
20
24
  * @param {string} baseUrl mirai-api-http server 的地址
@@ -14,7 +14,11 @@ const errorHandler = require('../util/errorHandler');
14
14
 
15
15
  const path = require('path');
16
16
 
17
- const locationStr = window === undefined ? `core.${path.basename(__filename, path.extname(__filename))}` : 'borwser';
17
+ const {
18
+ isBrowserEnv
19
+ } = require('../util/isBrowserEnv');
20
+
21
+ const locationStr = !isBrowserEnv() ? `core.${path.basename(__filename, path.extname(__filename))}` : 'borwser';
18
22
  /**
19
23
  * @description 获取群配置
20
24
  * @param {string} baseUrl mirai-api-http server 的地址
@@ -14,7 +14,11 @@ const errorHandler = require('../util/errorHandler');
14
14
 
15
15
  const path = require('path');
16
16
 
17
- const locationStr = window === undefined ? `core.${path.basename(__filename, path.extname(__filename))}` : 'borwser';
17
+ const {
18
+ isBrowserEnv
19
+ } = require('../util/isBrowserEnv');
20
+
21
+ const locationStr = !isBrowserEnv() ? `core.${path.basename(__filename, path.extname(__filename))}` : 'borwser';
18
22
  /**
19
23
  * @description 获取群列表
20
24
  * @param {string} baseUrl mirai-api-http server 的地址
@@ -14,7 +14,11 @@ const errorHandler = require('../util/errorHandler');
14
14
 
15
15
  const path = require('path');
16
16
 
17
- const locationStr = window === undefined ? `core.${path.basename(__filename, path.extname(__filename))}` : 'borwser';
17
+ const {
18
+ isBrowserEnv
19
+ } = require('../util/isBrowserEnv');
20
+
21
+ const locationStr = !isBrowserEnv() ? `core.${path.basename(__filename, path.extname(__filename))}` : 'borwser';
18
22
  /**
19
23
  * @description 获取群成员信息
20
24
  * @param {string} baseUrl mirai-api-http server 的地址
@@ -14,7 +14,11 @@ const errorHandler = require('../util/errorHandler');
14
14
 
15
15
  const path = require('path');
16
16
 
17
- const locationStr = window === undefined ? `core.${path.basename(__filename, path.extname(__filename))}` : 'borwser';
17
+ const {
18
+ isBrowserEnv
19
+ } = require('../util/isBrowserEnv');
20
+
21
+ const locationStr = !isBrowserEnv() ? `core.${path.basename(__filename, path.extname(__filename))}` : 'borwser';
18
22
  /**
19
23
  * @description 获取指定群的成员列表
20
24
  * @param {string} baseUrl mirai-api-http server 的地址
@@ -62,7 +66,11 @@ module.exports = async ({
62
66
  throw new Error(message);
63
67
  }
64
68
 
65
- return data;
69
+ if (Array.isArray(data)) {
70
+ return data;
71
+ } else {
72
+ return data.data;
73
+ }
66
74
  } catch (error) {
67
75
  console.error(`mirai-js: error ${locationStr}`);
68
76
  errorHandler(error);
@@ -14,7 +14,11 @@ const errorHandler = require('../util/errorHandler');
14
14
 
15
15
  const path = require('path');
16
16
 
17
- const locationStr = window === undefined ? `core.${path.basename(__filename, path.extname(__filename))}` : 'borwser';
17
+ const {
18
+ isBrowserEnv
19
+ } = require('../util/isBrowserEnv');
20
+
21
+ const locationStr = !isBrowserEnv() ? `core.${path.basename(__filename, path.extname(__filename))}` : 'borwser';
18
22
  /**
19
23
  * @description 获取指定 session 的 config
20
24
  * @param {string} baseUrl mirai-api-http server 的地址
@@ -14,7 +14,11 @@ const errorHandler = require('../util/errorHandler');
14
14
 
15
15
  const path = require('path');
16
16
 
17
- const locationStr = window === undefined ? `core.${path.basename(__filename, path.extname(__filename))}` : 'borwser';
17
+ const {
18
+ isBrowserEnv
19
+ } = require('../util/isBrowserEnv');
20
+
21
+ const locationStr = !isBrowserEnv() ? `core.${path.basename(__filename, path.extname(__filename))}` : 'borwser';
18
22
  /**
19
23
  * @description 获取用户信息
20
24
  * @param {string} baseUrl mirai-api-http server 的地址
@@ -14,7 +14,11 @@ const errorHandler = require('../util/errorHandler');
14
14
 
15
15
  const path = require('path');
16
16
 
17
- const locationStr = window === undefined ? `core.${path.basename(__filename, path.extname(__filename))}` : 'borwser';
17
+ const {
18
+ isBrowserEnv
19
+ } = require('../util/isBrowserEnv');
20
+
21
+ const locationStr = !isBrowserEnv() ? `core.${path.basename(__filename, path.extname(__filename))}` : 'borwser';
18
22
  /**
19
23
  * @description 禁言群成员
20
24
  * @param {string} baseUrl mirai-api-http server 的主机地址
@@ -14,7 +14,11 @@ const errorHandler = require('../util/errorHandler');
14
14
 
15
15
  const path = require('path');
16
16
 
17
- const locationStr = window === undefined ? `core.${path.basename(__filename, path.extname(__filename))}` : 'borwser';
17
+ const {
18
+ isBrowserEnv
19
+ } = require('../util/isBrowserEnv');
20
+
21
+ const locationStr = !isBrowserEnv() ? `core.${path.basename(__filename, path.extname(__filename))}` : 'borwser';
18
22
  /**
19
23
  * @description 全员禁言
20
24
  * @param {string} baseUrl mirai-api-http server 的主机地址
@@ -14,7 +14,11 @@ const errorHandler = require('../util/errorHandler');
14
14
 
15
15
  const path = require('path');
16
16
 
17
- const locationStr = window === undefined ? `core.${path.basename(__filename, path.extname(__filename))}` : 'borwser';
17
+ const {
18
+ isBrowserEnv
19
+ } = require('../util/isBrowserEnv');
20
+
21
+ const locationStr = !isBrowserEnv() ? `core.${path.basename(__filename, path.extname(__filename))}` : 'borwser';
18
22
  /**
19
23
  * @description 退出群聊
20
24
  * @param {string} baseUrl mirai-api-http server 的地址
@@ -14,7 +14,11 @@ const errorHandler = require('../util/errorHandler');
14
14
 
15
15
  const path = require('path');
16
16
 
17
- const locationStr = window === undefined ? `core.${path.basename(__filename, path.extname(__filename))}` : 'borwser';
17
+ const {
18
+ isBrowserEnv
19
+ } = require('../util/isBrowserEnv');
20
+
21
+ const locationStr = !isBrowserEnv() ? `core.${path.basename(__filename, path.extname(__filename))}` : 'borwser';
18
22
  /**
19
23
  * @description 撤回由 messageId 确定的消息
20
24
  * @param {string} baseUrl mirai-api-http server 的主机地址
@@ -14,7 +14,11 @@ const errorHandler = require('../util/errorHandler');
14
14
 
15
15
  const path = require('path');
16
16
 
17
- const locationStr = window === undefined ? `core.${path.basename(__filename, path.extname(__filename))}` : 'borwser';
17
+ const {
18
+ isBrowserEnv
19
+ } = require('../util/isBrowserEnv');
20
+
21
+ const locationStr = !isBrowserEnv() ? `core.${path.basename(__filename, path.extname(__filename))}` : 'borwser';
18
22
  /**
19
23
  * @description 关闭一个会话
20
24
  * @param {string} baseUrl mirai-api-http server 的主机地址
@@ -14,7 +14,11 @@ const errorHandler = require('../util/errorHandler');
14
14
 
15
15
  const path = require('path');
16
16
 
17
- const locationStr = window === undefined ? `core.${path.basename(__filename, path.extname(__filename))}` : 'borwser';
17
+ const {
18
+ isBrowserEnv
19
+ } = require('../util/isBrowserEnv');
20
+
21
+ const locationStr = !isBrowserEnv() ? `core.${path.basename(__filename, path.extname(__filename))}` : 'borwser';
18
22
  /**
19
23
  * @description 删除好友
20
24
  * @param {string} baseUrl mirai-api-http server 的地址
@@ -14,7 +14,11 @@ const errorHandler = require('../util/errorHandler');
14
14
 
15
15
  const path = require('path');
16
16
 
17
- const locationStr = window === undefined ? `core.${path.basename(__filename, path.extname(__filename))}` : 'borwser';
17
+ const {
18
+ isBrowserEnv
19
+ } = require('../util/isBrowserEnv');
20
+
21
+ const locationStr = !isBrowserEnv() ? `core.${path.basename(__filename, path.extname(__filename))}` : 'borwser';
18
22
  /**
19
23
  * @description 移除群成员
20
24
  * @param {string} baseUrl mirai-api-http server 的地址
@@ -14,7 +14,11 @@ const errorHandler = require('../util/errorHandler');
14
14
 
15
15
  const path = require('path');
16
16
 
17
- const locationStr = window === undefined ? `core.${path.basename(__filename, path.extname(__filename))}` : 'borwser';
17
+ const {
18
+ isBrowserEnv
19
+ } = require('../util/isBrowserEnv');
20
+
21
+ const locationStr = !isBrowserEnv() ? `core.${path.basename(__filename, path.extname(__filename))}` : 'borwser';
18
22
  /**
19
23
  * ! 自动同意时,不会触发该事件
20
24
  * @description 响应机器人被邀请入群请求
@@ -14,7 +14,11 @@ const errorHandler = require('../util/errorHandler');
14
14
 
15
15
  const path = require('path');
16
16
 
17
- const locationStr = window === undefined ? `core.${path.basename(__filename, path.extname(__filename))}` : 'borwser';
17
+ const {
18
+ isBrowserEnv
19
+ } = require('../util/isBrowserEnv');
20
+
21
+ const locationStr = !isBrowserEnv() ? `core.${path.basename(__filename, path.extname(__filename))}` : 'borwser';
18
22
  /**
19
23
  * @description 响应好友请求
20
24
  * @param {string} baseUrl mirai-api-http server 的地址
@@ -14,7 +14,11 @@ const errorHandler = require('../util/errorHandler');
14
14
 
15
15
  const path = require('path');
16
16
 
17
- const locationStr = window === undefined ? `core.${path.basename(__filename, path.extname(__filename))}` : 'borwser';
17
+ const {
18
+ isBrowserEnv
19
+ } = require('../util/isBrowserEnv');
20
+
21
+ const locationStr = !isBrowserEnv() ? `core.${path.basename(__filename, path.extname(__filename))}` : 'borwser';
18
22
  /**
19
23
  * FIXME: mirai-core 的问题,有时候收不到 MemberJoinRequestEvent 事件
20
24
  * 该功能未经测试
@@ -14,7 +14,11 @@ const errorHandler = require('../util/errorHandler');
14
14
 
15
15
  const path = require('path');
16
16
 
17
- const locationStr = window === undefined ? `core.${path.basename(__filename, path.extname(__filename))}` : 'borwser';
17
+ const {
18
+ isBrowserEnv
19
+ } = require('../util/isBrowserEnv');
20
+
21
+ const locationStr = !isBrowserEnv() ? `core.${path.basename(__filename, path.extname(__filename))}` : 'borwser';
18
22
  /**
19
23
  * @description 向 mirai-console 发送指令
20
24
  * @param {string} baseUrl mirai-api-http server 的地址
@@ -14,7 +14,11 @@ const errorHandler = require('../util/errorHandler');
14
14
 
15
15
  const path = require('path');
16
16
 
17
- const locationStr = window === undefined ? `core.${path.basename(__filename, path.extname(__filename))}` : 'borwser';
17
+ const {
18
+ isBrowserEnv
19
+ } = require('../util/isBrowserEnv');
20
+
21
+ const locationStr = !isBrowserEnv() ? `core.${path.basename(__filename, path.extname(__filename))}` : 'borwser';
18
22
  /**
19
23
  * @description 向 qq 好友发送消息
20
24
  * @param {string} baseUrl mirai-api-http server 的地址
@@ -14,7 +14,11 @@ const errorHandler = require('../util/errorHandler');
14
14
 
15
15
  const path = require('path');
16
16
 
17
- const locationStr = window === undefined ? `core.${path.basename(__filename, path.extname(__filename))}` : 'borwser';
17
+ const {
18
+ isBrowserEnv
19
+ } = require('../util/isBrowserEnv');
20
+
21
+ const locationStr = !isBrowserEnv() ? `core.${path.basename(__filename, path.extname(__filename))}` : 'borwser';
18
22
  /**
19
23
  * @description 向 qq 群发送消息
20
24
  * @param {string} baseUrl mirai-api-http server 的地址
@@ -14,7 +14,11 @@ const errorHandler = require('../util/errorHandler');
14
14
 
15
15
  const path = require('path');
16
16
 
17
- const locationStr = window === undefined ? `core.${path.basename(__filename, path.extname(__filename))}` : 'borwser';
17
+ const {
18
+ isBrowserEnv
19
+ } = require('../util/isBrowserEnv');
20
+
21
+ const locationStr = !isBrowserEnv() ? `core.${path.basename(__filename, path.extname(__filename))}` : 'borwser';
18
22
  /**
19
23
  * @description 发送戳一戳消息
20
24
  * @param {string} baseUrl mirai-api-http server 的地址
@@ -14,7 +14,11 @@ const errorHandler = require('../util/errorHandler');
14
14
 
15
15
  const path = require('path');
16
16
 
17
- const locationStr = window === undefined ? `core.${path.basename(__filename, path.extname(__filename))}` : 'borwser';
17
+ const {
18
+ isBrowserEnv
19
+ } = require('../util/isBrowserEnv');
20
+
21
+ const locationStr = !isBrowserEnv() ? `core.${path.basename(__filename, path.extname(__filename))}` : 'borwser';
18
22
  /**
19
23
  * @description 向临时对象发送消息
20
24
  * @param {string} baseUrl mirai-api-http server 的地址
@@ -14,7 +14,11 @@ const errorHandler = require('../util/errorHandler');
14
14
 
15
15
  const path = require('path');
16
16
 
17
- const locationStr = window === undefined ? `core.${path.basename(__filename, path.extname(__filename))}` : 'borwser';
17
+ const {
18
+ isBrowserEnv
19
+ } = require('../util/isBrowserEnv');
20
+
21
+ const locationStr = !isBrowserEnv() ? `core.${path.basename(__filename, path.extname(__filename))}` : 'borwser';
18
22
  /**
19
23
  * @description 设置群精华消息
20
24
  * @param {string} baseUrl mirai-api-http server 的地址
@@ -14,7 +14,11 @@ const errorHandler = require('../util/errorHandler');
14
14
 
15
15
  const path = require('path');
16
16
 
17
- const locationStr = window === undefined ? `core.${path.basename(__filename, path.extname(__filename))}` : 'borwser';
17
+ const {
18
+ isBrowserEnv
19
+ } = require('../util/isBrowserEnv');
20
+
21
+ const locationStr = !isBrowserEnv() ? `core.${path.basename(__filename, path.extname(__filename))}` : 'borwser';
18
22
  /**
19
23
  * @description 设置群配置
20
24
  * @param {string} baseUrl mirai-api-http server 的地址
@@ -14,7 +14,11 @@ const errorHandler = require('../util/errorHandler');
14
14
 
15
15
  const path = require('path');
16
16
 
17
- const locationStr = window === undefined ? `core.${path.basename(__filename, path.extname(__filename))}` : 'borwser';
17
+ const {
18
+ isBrowserEnv
19
+ } = require('../util/isBrowserEnv');
20
+
21
+ const locationStr = !isBrowserEnv() ? `core.${path.basename(__filename, path.extname(__filename))}` : 'borwser';
18
22
  /**
19
23
  * @description 设置群成员权限
20
24
  * @param {string} baseUrl mirai-api-http server 的地址
@@ -14,7 +14,11 @@ const errorHandler = require('../util/errorHandler');
14
14
 
15
15
  const path = require('path');
16
16
 
17
- const locationStr = window === undefined ? `core.${path.basename(__filename, path.extname(__filename))}` : 'borwser';
17
+ const {
18
+ isBrowserEnv
19
+ } = require('../util/isBrowserEnv');
20
+
21
+ const locationStr = !isBrowserEnv() ? `core.${path.basename(__filename, path.extname(__filename))}` : 'borwser';
18
22
  /**
19
23
  * @description 设置群成员信息
20
24
  * @param {string} baseUrl mirai-api-http server 的地址
@@ -14,7 +14,11 @@ const errorHandler = require('../util/errorHandler');
14
14
 
15
15
  const path = require('path');
16
16
 
17
- const locationStr = window === undefined ? `core.${path.basename(__filename, path.extname(__filename))}` : 'borwser';
17
+ const {
18
+ isBrowserEnv
19
+ } = require('../util/isBrowserEnv');
20
+
21
+ const locationStr = !isBrowserEnv() ? `core.${path.basename(__filename, path.extname(__filename))}` : 'borwser';
18
22
  /**
19
23
  * @description 设置指定 session 的 config
20
24
  * @param {string} baseUrl mirai-api-http server 的地址
@@ -10,7 +10,11 @@ const errorHandler = require('../util/errorHandler');
10
10
 
11
11
  const path = require('path');
12
12
 
13
- const locationStr = window === undefined ? `core.${path.basename(__filename, path.extname(__filename))}` : 'borwser';
13
+ const {
14
+ isBrowserEnv
15
+ } = require('../util/isBrowserEnv');
16
+
17
+ const locationStr = !isBrowserEnv() ? `core.${path.basename(__filename, path.extname(__filename))}` : 'borwser';
14
18
  /**
15
19
  * @description 开始侦听事件
16
20
  * @param {string} baseUrl mirai-api-http server 的地址
@@ -10,7 +10,11 @@ const errorHandler = require('../util/errorHandler');
10
10
 
11
11
  const path = require('path');
12
12
 
13
- const locationStr = window === undefined ? `core.${path.basename(__filename, path.extname(__filename))}` : 'borwser';
13
+ const {
14
+ isBrowserEnv
15
+ } = require('../util/isBrowserEnv');
16
+
17
+ const locationStr = !isBrowserEnv() ? `core.${path.basename(__filename, path.extname(__filename))}` : 'borwser';
14
18
  /**
15
19
  * @description 开始侦听事件
16
20
  * @param {string} baseUrl mirai-api-http server 的地址
@@ -4,7 +4,11 @@ const errorHandler = require('../util/errorHandler');
4
4
 
5
5
  const path = require('path');
6
6
 
7
- const locationStr = window === undefined ? `core.${path.basename(__filename, path.extname(__filename))}` : 'borwser';
7
+ const {
8
+ isBrowserEnv
9
+ } = require('../util/isBrowserEnv');
10
+
11
+ const locationStr = !isBrowserEnv() ? `core.${path.basename(__filename, path.extname(__filename))}` : 'borwser';
8
12
  /**
9
13
  * @description 停止侦听事件
10
14
  * @param {WebSocket} 建立连接的 WebSocket 实例
@@ -4,7 +4,11 @@ const errorHandler = require('../util/errorHandler');
4
4
 
5
5
  const path = require('path');
6
6
 
7
- const locationStr = window === undefined ? `core.${path.basename(__filename, path.extname(__filename))}` : 'borwser';
7
+ const {
8
+ isBrowserEnv
9
+ } = require('../util/isBrowserEnv');
10
+
11
+ const locationStr = !isBrowserEnv() ? `core.${path.basename(__filename, path.extname(__filename))}` : 'borwser';
8
12
  /**
9
13
  * @description 停止侦听事件
10
14
  * @param {WebSocket} 建立连接的 WebSocket 实例
@@ -14,7 +14,11 @@ const errorHandler = require('../util/errorHandler');
14
14
 
15
15
  const path = require('path');
16
16
 
17
- const locationStr = window === undefined ? `core.${path.basename(__filename, path.extname(__filename))}` : 'borwser';
17
+ const {
18
+ isBrowserEnv
19
+ } = require('../util/isBrowserEnv');
20
+
21
+ const locationStr = !isBrowserEnv() ? `core.${path.basename(__filename, path.extname(__filename))}` : 'borwser';
18
22
  /**
19
23
  * @description 解除禁言
20
24
  * @param {string} baseUrl mirai-api-http server 的主机地址
@@ -14,7 +14,11 @@ const errorHandler = require('../util/errorHandler');
14
14
 
15
15
  const path = require('path');
16
16
 
17
- const locationStr = window === undefined ? `core.${path.basename(__filename, path.extname(__filename))}` : 'borwser';
17
+ const {
18
+ isBrowserEnv
19
+ } = require('../util/isBrowserEnv');
20
+
21
+ const locationStr = !isBrowserEnv() ? `core.${path.basename(__filename, path.extname(__filename))}` : 'borwser';
18
22
  /**
19
23
  * @description 解除全员禁言
20
24
  * @param {string} baseUrl mirai-api-http server 的主机地址
@@ -14,7 +14,11 @@ const errorHandler = require('../util/errorHandler');
14
14
 
15
15
  const path = require('path');
16
16
 
17
- const locationStr = window === undefined ? `core.${path.basename(__filename, path.extname(__filename))}` : 'borwser';
17
+ const {
18
+ isBrowserEnv
19
+ } = require('../util/isBrowserEnv');
20
+
21
+ const locationStr = !isBrowserEnv() ? `core.${path.basename(__filename, path.extname(__filename))}` : 'borwser';
18
22
 
19
23
  const FormData = require('form-data');
20
24
  /**
@@ -14,7 +14,11 @@ const errorHandler = require('../util/errorHandler');
14
14
 
15
15
  const path = require('path');
16
16
 
17
- const locationStr = window === undefined ? `core.${path.basename(__filename, path.extname(__filename))}` : 'borwser';
17
+ const {
18
+ isBrowserEnv
19
+ } = require('../util/isBrowserEnv');
20
+
21
+ const locationStr = !isBrowserEnv() ? `core.${path.basename(__filename, path.extname(__filename))}` : 'borwser';
18
22
 
19
23
  const FormData = require('form-data');
20
24
  /**
@@ -14,7 +14,11 @@ const errorHandler = require('../util/errorHandler');
14
14
 
15
15
  const path = require('path');
16
16
 
17
- const locationStr = window === undefined ? `core.${path.basename(__filename, path.extname(__filename))}` : 'borwser';
17
+ const {
18
+ isBrowserEnv
19
+ } = require('../util/isBrowserEnv');
20
+
21
+ const locationStr = !isBrowserEnv() ? `core.${path.basename(__filename, path.extname(__filename))}` : 'borwser';
18
22
  /**
19
23
  * @description 校验 sessionKey,将一个 session 绑定到指定的 qq 上
20
24
  * @param {string} baseUrl mirai-api-http server 的地址
@@ -1,5 +1,9 @@
1
1
  "use strict";
2
2
 
3
+ const {
4
+ isBrowserEnv
5
+ } = require('../util/isBrowserEnv');
6
+
3
7
  module.exports = {
4
- URL: window !== undefined ? window.URL : require('url').URL
8
+ URL: isBrowserEnv() ? window.URL : require('url').URL
5
9
  };
@@ -1,6 +1,10 @@
1
1
  "use strict";
2
2
 
3
+ const {
4
+ isBrowserEnv
5
+ } = require('../util/isBrowserEnv');
6
+
3
7
  module.exports = {
4
- wsStartListening: window !== undefined ? require('../core/startListeningBrowser') : require('../core/startListeningNode'),
5
- wsStopListening: window !== undefined ? require('../core/stopListeningBrowser') : require('../core/stopListeningNode')
8
+ wsStartListening: isBrowserEnv() ? require('../core/startListeningBrowser') : require('../core/startListeningNode'),
9
+ wsStopListening: isBrowserEnv() ? require('../core/stopListeningBrowser') : require('../core/stopListeningNode')
6
10
  };
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+
3
+ exports.isBrowserEnv = () => {
4
+ return typeof window !== 'undefined';
5
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mirai-js",
3
- "version": "2.7.0-beta.1.0.0",
3
+ "version": "2.7.0",
4
4
  "description": "QQ robot development framework based on Mirai-api-http.",
5
5
  "main": "dist/node/index.js",
6
6
  "scripts": {