mirai-js 2.6.2 → 2.7.1-0

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 (114) hide show
  1. package/dist/browser/mirai-js.js +1 -1
  2. package/dist/node/Bot.d.ts +1 -1
  3. package/dist/node/Bot.js +17 -5
  4. package/dist/node/FileManager.js +6 -2
  5. package/dist/node/Middleware.d.ts +4 -4
  6. package/dist/node/core/anno/deleteAnno.js +5 -1
  7. package/dist/node/core/anno/getAnno.js +5 -1
  8. package/dist/node/core/anno/publishAnno.js +5 -1
  9. package/dist/node/core/auth.js +5 -1
  10. package/dist/node/core/fs/deleteGroupFile.js +5 -1
  11. package/dist/node/core/fs/getGroupFileInfo.js +5 -1
  12. package/dist/node/core/fs/getGroupFileList.js +5 -1
  13. package/dist/node/core/fs/makeGroupDir.js +5 -1
  14. package/dist/node/core/fs/moveGroupFile.js +5 -1
  15. package/dist/node/core/fs/renameGroupFile.js +5 -1
  16. package/dist/node/core/fs/uploadGroupFIle.js +5 -1
  17. package/dist/node/core/getFriendList.js +5 -1
  18. package/dist/node/core/getGroupConfig.js +5 -1
  19. package/dist/node/core/getGroupList.js +5 -1
  20. package/dist/node/core/getMemberInfo.js +5 -1
  21. package/dist/node/core/getMemberList.js +5 -1
  22. package/dist/node/core/getSessionConfig.js +5 -1
  23. package/dist/node/core/getUserProfile.js +5 -1
  24. package/dist/node/core/mute.js +5 -1
  25. package/dist/node/core/muteAll.js +5 -1
  26. package/dist/node/core/quitGroup.js +5 -1
  27. package/dist/node/core/recall.js +5 -1
  28. package/dist/node/core/releaseSession.js +5 -1
  29. package/dist/node/core/removeFriend.js +5 -1
  30. package/dist/node/core/removeMember.js +5 -1
  31. package/dist/node/core/responseBotInvitedJoinGroupRequest.js +5 -1
  32. package/dist/node/core/responseFirendRequest.js +5 -1
  33. package/dist/node/core/responseMemberJoinRequest.js +5 -1
  34. package/dist/node/core/sendCommand.js +5 -1
  35. package/dist/node/core/sendFriendMessage.js +5 -1
  36. package/dist/node/core/sendGroupMessage.js +5 -1
  37. package/dist/node/core/sendNudge.js +5 -1
  38. package/dist/node/core/sendTempMessage.js +5 -1
  39. package/dist/node/core/setEssence.js +5 -1
  40. package/dist/node/core/setGroupConfig.js +5 -1
  41. package/dist/node/core/setMemberAdmin.js +5 -1
  42. package/dist/node/core/setMemberInfo.js +5 -1
  43. package/dist/node/core/setSessionConfig.js +5 -1
  44. package/dist/node/core/startListeningBrowser.js +5 -1
  45. package/dist/node/core/startListeningNode.js +5 -1
  46. package/dist/node/core/stopListeningBrowser.js +5 -1
  47. package/dist/node/core/stopListeningNode.js +5 -1
  48. package/dist/node/core/unmute.js +5 -1
  49. package/dist/node/core/unmuteAll.js +5 -1
  50. package/dist/node/core/uploadImage.js +5 -1
  51. package/dist/node/core/uploadVoice.js +5 -1
  52. package/dist/node/core/verify.js +5 -1
  53. package/dist/node/index.d.ts +8 -3
  54. package/dist/node/index.js +12 -9
  55. package/dist/node/polyfill/URL.js +5 -1
  56. package/dist/node/polyfill/wsListener.js +6 -2
  57. package/dist/node/util/isBrowserEnv.js +5 -0
  58. package/package.json +2 -2
  59. package/src/Bot.d.ts +1 -1
  60. package/src/Bot.js +5 -2
  61. package/src/FileManager.js +3 -2
  62. package/src/Middleware.d.ts +4 -4
  63. package/src/core/anno/deleteAnno.js +2 -1
  64. package/src/core/anno/getAnno.js +2 -1
  65. package/src/core/anno/publishAnno.js +2 -1
  66. package/src/core/auth.js +2 -1
  67. package/src/core/fs/deleteGroupFile.js +2 -1
  68. package/src/core/fs/getGroupFileInfo.js +2 -1
  69. package/src/core/fs/getGroupFileList.js +2 -1
  70. package/src/core/fs/makeGroupDir.js +2 -1
  71. package/src/core/fs/moveGroupFile.js +2 -1
  72. package/src/core/fs/renameGroupFile.js +2 -1
  73. package/src/core/fs/uploadGroupFIle.js +2 -1
  74. package/src/core/getFriendList.js +2 -1
  75. package/src/core/getGroupConfig.js +2 -1
  76. package/src/core/getGroupList.js +2 -1
  77. package/src/core/getMemberInfo.js +2 -1
  78. package/src/core/getMemberList.js +2 -1
  79. package/src/core/getSessionConfig.js +2 -1
  80. package/src/core/getUserProfile.js +2 -1
  81. package/src/core/mute.js +2 -1
  82. package/src/core/muteAll.js +2 -1
  83. package/src/core/quitGroup.js +2 -1
  84. package/src/core/recall.js +2 -1
  85. package/src/core/releaseSession.js +2 -1
  86. package/src/core/removeFriend.js +2 -1
  87. package/src/core/removeMember.js +2 -1
  88. package/src/core/responseBotInvitedJoinGroupRequest.js +2 -1
  89. package/src/core/responseFirendRequest.js +2 -1
  90. package/src/core/responseMemberJoinRequest.js +2 -1
  91. package/src/core/sendCommand.js +2 -1
  92. package/src/core/sendFriendMessage.js +2 -1
  93. package/src/core/sendGroupMessage.js +2 -1
  94. package/src/core/sendNudge.js +2 -1
  95. package/src/core/sendTempMessage.js +2 -1
  96. package/src/core/setEssence.js +2 -1
  97. package/src/core/setGroupConfig.js +2 -1
  98. package/src/core/setMemberAdmin.js +2 -1
  99. package/src/core/setMemberInfo.js +2 -1
  100. package/src/core/setSessionConfig.js +2 -1
  101. package/src/core/startListeningBrowser.js +2 -1
  102. package/src/core/startListeningNode.js +2 -1
  103. package/src/core/stopListeningBrowser.js +2 -1
  104. package/src/core/stopListeningNode.js +2 -1
  105. package/src/core/unmute.js +2 -1
  106. package/src/core/unmuteAll.js +2 -1
  107. package/src/core/uploadImage.js +2 -1
  108. package/src/core/uploadVoice.js +2 -1
  109. package/src/core/verify.js +2 -1
  110. package/src/index.d.ts +8 -3
  111. package/src/index.js +13 -9
  112. package/src/polyfill/URL.js +3 -1
  113. package/src/polyfill/wsListener.js +4 -2
  114. package/src/util/isBrowserEnv.js +3 -0
@@ -12,16 +12,19 @@ const {
12
12
  Middleware
13
13
  } = require('./Middleware');
14
14
 
15
- if (process.browser) {
16
- window.miraiJs = {
15
+ (function (window, factory) {
16
+ if (typeof exports === 'object') {
17
+ module.exports = factory(); // eslint-disable-next-line no-undef
18
+ } else if (typeof define === 'function' && define.amd) {
19
+ // eslint-disable-next-line no-undef
20
+ define(factory);
21
+ } else {
22
+ window.miraiJs = factory();
23
+ }
24
+ })(void 0, function () {
25
+ return {
17
26
  Bot,
18
27
  Message,
19
28
  Middleware
20
29
  };
21
- } else {
22
- module.exports = {
23
- Bot,
24
- Message,
25
- Middleware
26
- };
27
- }
30
+ });
@@ -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: process.browser ? 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: process.browser ? require('../core/startListeningBrowser') : require('../core/startListeningNode'),
5
- wsStopListening: process.browser ? 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.6.2",
3
+ "version": "2.7.1-0",
4
4
  "description": "QQ robot development framework based on Mirai-api-http.",
5
5
  "main": "dist/node/index.js",
6
6
  "scripts": {
@@ -49,4 +49,4 @@
49
49
  "webpack": "^5.30.0",
50
50
  "webpack-cli": "^4.6.0"
51
51
  }
52
- }
52
+ }
package/src/Bot.d.ts CHANGED
@@ -115,7 +115,7 @@ export class Bot implements BotConfigGetable {
115
115
  * @description 移除所有事件处理器
116
116
  * @param eventType 可选,事件类型(或数组)
117
117
  */
118
- ofAll(eventType?: EventType | EventType[]): void;
118
+ offAll(eventType?: EventType | EventType[]): void;
119
119
 
120
120
  /**
121
121
  * @description 获取 config
package/src/Bot.js CHANGED
@@ -42,6 +42,7 @@ const { promisify } = require('util');
42
42
  const { Waiter } = require('./Waiter');
43
43
  const { FileManager } = require('./FileManager');
44
44
  const { errCodeEnum } = require('./util/errCode');
45
+ const { isBrowserEnv } = require('./util/isBrowserEnv');
45
46
 
46
47
 
47
48
  // 扩展接口
@@ -571,13 +572,14 @@ class Bot extends BotConfigGetable {
571
572
  * @returns {Object} 结构 { imageId, url, path }
572
573
  */
573
574
  async uploadImage({ type = 'group', img, filename }) {
575
+ if (isBrowserEnv()) { throw new Error('uploadImage 在浏览器环境下不可用'); }
574
576
  // 检查对象状态
575
577
  if (!this.config) {
576
578
  throw new Error('uploadImage 请先调用 open,建立一个会话');
577
579
  }
578
580
 
579
581
  // 检查参数
580
- if (process.browser && filename) {
582
+ if (isBrowserEnv() && filename) {
581
583
  throw new Error('uploadImage 浏览器端不支持 filename 参数');
582
584
  }
583
585
  if (!img && !filename) {
@@ -604,13 +606,14 @@ class Bot extends BotConfigGetable {
604
606
  * @returns {Object} 结构 { voiceId, url, path }
605
607
  */
606
608
  async uploadVoice({ type = 'group', voice, filename }) {
609
+ if (isBrowserEnv()) { throw new Error('uploadVoice 在浏览器环境下不可用'); }
607
610
  // 检查对象状态
608
611
  if (!this.config) {
609
612
  throw new Error('uploadVoice 请先调用 open,建立一个会话');
610
613
  }
611
614
 
612
615
  // 检查参数
613
- if (process.browser && filename) {
616
+ if (isBrowserEnv() && filename) {
614
617
  throw new Error('uploadVoice 浏览器端不支持 filename 参数');
615
618
  }
616
619
  if (!voice && !filename) {
@@ -1,6 +1,7 @@
1
1
  const fs = require('fs');
2
2
  const path = require('path');
3
3
  const { promisify } = require('util');
4
+ const { isBrowserEnv } = require('./util/isBrowserEnv');
4
5
 
5
6
  class FileManager {
6
7
  constructor({ bot, group }) {
@@ -194,7 +195,7 @@ class FileManager {
194
195
  */
195
196
  async upload({ file, filePath, filename }) {
196
197
  // 检查参数
197
- if (process.browser && filePath) {
198
+ if (isBrowserEnv && filePath) {
198
199
  throw new Error('Bot.FileManager.Directory.upload 浏览器端不支持 filePath 参数');
199
200
  }
200
201
  if (!file && !filePath) {
@@ -250,7 +251,7 @@ class FileManager {
250
251
  */
251
252
  async uploadTo({ uploadPath, file, filePath }) {
252
253
  // 检查参数
253
- if (process.browser && filePath) {
254
+ if (isBrowserEnv() && filePath) {
254
255
  throw new Error('Bot.FileManager.uploadTo 浏览器端不支持 filePath 参数');
255
256
  }
256
257
  if (!file && !filePath) {
@@ -42,14 +42,14 @@ export class Middleware {
42
42
  * @param groupArr 允许通过的群号数组
43
43
  * @param allow 允许通过还是禁止通过
44
44
  */
45
- groupFilter(groupArr: number[], allow: boolean): Middleware;
45
+ groupFilter(groupArr: number[], allow?: boolean): Middleware;
46
46
 
47
47
  /**
48
48
  * @description 过滤指定的好友消息
49
49
  * @param friendArr 好友 qq 号数组
50
50
  * @param allow 允许通过还是禁止通过
51
51
  */
52
- friendFilter(friendArr: number[], allow: boolean): Middleware;
52
+ friendFilter(friendArr: number[], allow?: boolean): Middleware;
53
53
 
54
54
  /**
55
55
  * @description 过滤指定群的群成员的消息
@@ -57,7 +57,7 @@ export class Middleware {
57
57
  * @param allow 允许通过还是禁止通过
58
58
  * 结构 { number => number[], } key 为允许通过的群号,value 为该群允许通过的成员 qq
59
59
  */
60
- groupMemberFilter(groupMemberMap: Middleware.GroupMemberMap, allow: boolean): Middleware;
60
+ groupMemberFilter(groupMemberMap: Middleware.GroupMemberMap, allow?: boolean): Middleware;
61
61
 
62
62
  /**
63
63
  * @description 这是一个对话锁,保证群中同一成员不能在中途触发处理器
@@ -76,7 +76,7 @@ export class Middleware {
76
76
  * @param atArr 必选,qq 号数组
77
77
  * @param allow 可选,允许通过还是禁止通过
78
78
  */
79
- atFilter(friendArr: number[], allow: boolean): Middleware;
79
+ atFilter(friendArr: number[], allow?: boolean): Middleware;
80
80
 
81
81
  /**
82
82
  * @description 用于 NewFriendRequestEvent 的中间件,经过该中间件后,将在 data 下放置三个方法
@@ -3,7 +3,8 @@ const axios = require('axios');
3
3
  const { URL } = require('../../polyfill/URL');
4
4
  const errorHandler = require('../../util/errorHandler');
5
5
  const path = require('path');
6
- const locationStr = `core.${path.basename(__filename, path.extname(__filename))}`;
6
+ const { isBrowserEnv } = require('../../util/isBrowserEnv');
7
+ const locationStr = !isBrowserEnv() ? `core.${path.basename(__filename, path.extname(__filename))}` : 'borwser';
7
8
 
8
9
  /**
9
10
  * @description 删除群公告
@@ -3,7 +3,8 @@ const axios = require('axios').default;
3
3
  const { URL } = require('../../polyfill/URL');
4
4
  const errorHandler = require('../../util/errorHandler');
5
5
  const path = require('path');
6
- const locationStr = `core.${path.basename(__filename, path.extname(__filename))}`;
6
+ const { isBrowserEnv } = require('../../util/isBrowserEnv');
7
+ const locationStr = !isBrowserEnv() ? `core.${path.basename(__filename, path.extname(__filename))}` : 'borwser';
7
8
 
8
9
  /**
9
10
  * @description 获取群公告
@@ -3,7 +3,8 @@ const axios = require('axios');
3
3
  const { URL } = require('../../polyfill/URL');
4
4
  const errorHandler = require('../../util/errorHandler');
5
5
  const path = require('path');
6
- const locationStr = `core.${path.basename(__filename, path.extname(__filename))}`;
6
+ const { isBrowserEnv } = require('../../util/isBrowserEnv');
7
+ const locationStr = !isBrowserEnv() ? `core.${path.basename(__filename, path.extname(__filename))}` : 'borwser';
7
8
 
8
9
  /**
9
10
  * @description 发布群公告
package/src/core/auth.js CHANGED
@@ -3,7 +3,8 @@ const axios = require('axios');
3
3
  const { URL } = require('../polyfill/URL');
4
4
  const errorHandler = require('../util/errorHandler');
5
5
  const path = require('path');
6
- const locationStr = `core.${path.basename(__filename, path.extname(__filename))}`;
6
+ const { isBrowserEnv } = require('../util/isBrowserEnv');
7
+ const locationStr = !isBrowserEnv() ? `core.${path.basename(__filename, path.extname(__filename))}` : 'borwser';
7
8
 
8
9
  /**
9
10
  *
@@ -3,7 +3,8 @@ const axios = require('axios');
3
3
  const { URL } = require('../../polyfill/URL');
4
4
  const errorHandler = require('../../util/errorHandler');
5
5
  const path = require('path');
6
- const locationStr = `core.${path.basename(__filename, path.extname(__filename))}`;
6
+ const { isBrowserEnv } = require('../../util/isBrowserEnv');
7
+ const locationStr = !isBrowserEnv() ? `core.${path.basename(__filename, path.extname(__filename))}` : 'borwser';
7
8
 
8
9
  /**
9
10
  * @description 删除群文件
@@ -3,7 +3,8 @@ const axios = require('axios').default;
3
3
  const { URL } = require('../../polyfill/URL');
4
4
  const errorHandler = require('../../util/errorHandler');
5
5
  const path = require('path');
6
- const locationStr = `core.${path.basename(__filename, path.extname(__filename))}`;
6
+ const { isBrowserEnv } = require('../../util/isBrowserEnv');
7
+ const locationStr = !isBrowserEnv() ? `core.${path.basename(__filename, path.extname(__filename))}` : 'borwser';
7
8
 
8
9
  /**
9
10
  * @description 获取群文件详细信息
@@ -3,7 +3,8 @@ const axios = require('axios').default;
3
3
  const { URL } = require('../../polyfill/URL');
4
4
  const errorHandler = require('../../util/errorHandler');
5
5
  const path = require('path');
6
- const locationStr = `core.${path.basename(__filename, path.extname(__filename))}`;
6
+ const { isBrowserEnv } = require('../../util/isBrowserEnv');
7
+ const locationStr = !isBrowserEnv() ? `core.${path.basename(__filename, path.extname(__filename))}` : 'borwser';
7
8
 
8
9
  /**
9
10
  * @description 获取群文件列表
@@ -3,7 +3,8 @@ const axios = require('axios');
3
3
  const { URL } = require('../../polyfill/URL');
4
4
  const errorHandler = require('../../util/errorHandler');
5
5
  const path = require('path');
6
- const locationStr = `core.${path.basename(__filename, path.extname(__filename))}`;
6
+ const { isBrowserEnv } = require('../../util/isBrowserEnv');
7
+ const locationStr = !isBrowserEnv() ? `core.${path.basename(__filename, path.extname(__filename))}` : 'borwser';
7
8
 
8
9
  /**
9
10
  * @description 新建群文件夹
@@ -3,7 +3,8 @@ const axios = require('axios');
3
3
  const { URL } = require('../../polyfill/URL');
4
4
  const errorHandler = require('../../util/errorHandler');
5
5
  const path = require('path');
6
- const locationStr = `core.${path.basename(__filename, path.extname(__filename))}`;
6
+ const { isBrowserEnv } = require('../../util/isBrowserEnv');
7
+ const locationStr = !isBrowserEnv() ? `core.${path.basename(__filename, path.extname(__filename))}` : 'borwser';
7
8
 
8
9
  /**
9
10
  * @description 移动群文件
@@ -3,7 +3,8 @@ const axios = require('axios');
3
3
  const { URL } = require('../../polyfill/URL');
4
4
  const errorHandler = require('../../util/errorHandler');
5
5
  const path = require('path');
6
- const locationStr = `core.${path.basename(__filename, path.extname(__filename))}`;
6
+ const { isBrowserEnv } = require('../../util/isBrowserEnv');
7
+ const locationStr = !isBrowserEnv() ? `core.${path.basename(__filename, path.extname(__filename))}` : 'borwser';
7
8
 
8
9
  /**
9
10
  * @description 重命名群文件
@@ -3,7 +3,8 @@ const axios = require('axios').default;
3
3
  const { URL } = require('../../polyfill/URL');
4
4
  const errorHandler = require('../../util/errorHandler');
5
5
  const path = require('path');
6
- const locationStr = `core.${path.basename(__filename, path.extname(__filename))}`;
6
+ const { isBrowserEnv } = require('../../util/isBrowserEnv');
7
+ const locationStr = !isBrowserEnv() ? `core.${path.basename(__filename, path.extname(__filename))}` : 'borwser';
7
8
  const FormData = require('form-data');
8
9
 
9
10
 
@@ -3,7 +3,8 @@ const axios = require('axios').default;
3
3
  const { URL } = require('../polyfill/URL');
4
4
  const errorHandler = require('../util/errorHandler');
5
5
  const path = require('path');
6
- const locationStr = `core.${path.basename(__filename, path.extname(__filename))}`;
6
+ const { isBrowserEnv } = require('../util/isBrowserEnv');
7
+ const locationStr = !isBrowserEnv() ? `core.${path.basename(__filename, path.extname(__filename))}` : 'borwser';
7
8
 
8
9
  /**
9
10
  * @description 获取好友列表
@@ -3,7 +3,8 @@ const axios = require('axios').default;
3
3
  const { URL } = require('../polyfill/URL');
4
4
  const errorHandler = require('../util/errorHandler');
5
5
  const path = require('path');
6
- const locationStr = `core.${path.basename(__filename, path.extname(__filename))}`;
6
+ const { isBrowserEnv } = require('../util/isBrowserEnv');
7
+ const locationStr = !isBrowserEnv() ? `core.${path.basename(__filename, path.extname(__filename))}` : 'borwser';
7
8
 
8
9
  /**
9
10
  * @description 获取群配置
@@ -3,7 +3,8 @@ const axios = require('axios').default;
3
3
  const { URL } = require('../polyfill/URL');
4
4
  const errorHandler = require('../util/errorHandler');
5
5
  const path = require('path');
6
- const locationStr = `core.${path.basename(__filename, path.extname(__filename))}`;
6
+ const { isBrowserEnv } = require('../util/isBrowserEnv');
7
+ const locationStr = !isBrowserEnv() ? `core.${path.basename(__filename, path.extname(__filename))}` : 'borwser';
7
8
 
8
9
  /**
9
10
  * @description 获取群列表
@@ -3,7 +3,8 @@ const axios = require('axios');
3
3
  const { URL } = require('../polyfill/URL');
4
4
  const errorHandler = require('../util/errorHandler');
5
5
  const path = require('path');
6
- const locationStr = `core.${path.basename(__filename, path.extname(__filename))}`;
6
+ const { isBrowserEnv } = require('../util/isBrowserEnv');
7
+ const locationStr = !isBrowserEnv() ? `core.${path.basename(__filename, path.extname(__filename))}` : 'borwser';
7
8
 
8
9
  /**
9
10
  * @description 获取群成员信息
@@ -3,7 +3,8 @@ const axios = require('axios').default;
3
3
  const { URL } = require('../polyfill/URL');
4
4
  const errorHandler = require('../util/errorHandler');
5
5
  const path = require('path');
6
- const locationStr = `core.${path.basename(__filename, path.extname(__filename))}`;
6
+ const { isBrowserEnv } = require('../util/isBrowserEnv');
7
+ const locationStr = !isBrowserEnv() ? `core.${path.basename(__filename, path.extname(__filename))}` : 'borwser';
7
8
 
8
9
  /**
9
10
  * @description 获取指定群的成员列表
@@ -3,7 +3,8 @@ const axios = require('axios');
3
3
  const { URL } = require('../polyfill/URL');
4
4
  const errorHandler = require('../util/errorHandler');
5
5
  const path = require('path');
6
- const locationStr = `core.${path.basename(__filename, path.extname(__filename))}`;
6
+ const { isBrowserEnv } = require('../util/isBrowserEnv');
7
+ const locationStr = !isBrowserEnv() ? `core.${path.basename(__filename, path.extname(__filename))}` : 'borwser';
7
8
 
8
9
  /**
9
10
  * @description 获取指定 session 的 config
@@ -3,7 +3,8 @@ const axios = require('axios');
3
3
  const { URL } = require('../polyfill/URL');
4
4
  const errorHandler = require('../util/errorHandler');
5
5
  const path = require('path');
6
- const locationStr = `core.${path.basename(__filename, path.extname(__filename))}`;
6
+ const { isBrowserEnv } = require('../util/isBrowserEnv');
7
+ const locationStr = !isBrowserEnv() ? `core.${path.basename(__filename, path.extname(__filename))}` : 'borwser';
7
8
 
8
9
  /**
9
10
  * @description 获取用户信息
package/src/core/mute.js CHANGED
@@ -3,7 +3,8 @@ const axios = require('axios').default;
3
3
  const { URL } = require('../polyfill/URL');
4
4
  const errorHandler = require('../util/errorHandler');
5
5
  const path = require('path');
6
- const locationStr = `core.${path.basename(__filename, path.extname(__filename))}`;
6
+ const { isBrowserEnv } = require('../util/isBrowserEnv');
7
+ const locationStr = !isBrowserEnv() ? `core.${path.basename(__filename, path.extname(__filename))}` : 'borwser';
7
8
 
8
9
  /**
9
10
  * @description 禁言群成员
@@ -3,7 +3,8 @@ const axios = require('axios').default;
3
3
  const { URL } = require('../polyfill/URL');
4
4
  const errorHandler = require('../util/errorHandler');
5
5
  const path = require('path');
6
- const locationStr = `core.${path.basename(__filename, path.extname(__filename))}`;
6
+ const { isBrowserEnv } = require('../util/isBrowserEnv');
7
+ const locationStr = !isBrowserEnv() ? `core.${path.basename(__filename, path.extname(__filename))}` : 'borwser';
7
8
 
8
9
  /**
9
10
  * @description 全员禁言
@@ -3,7 +3,8 @@ const axios = require('axios').default;
3
3
  const { URL } = require('../polyfill/URL');
4
4
  const errorHandler = require('../util/errorHandler');
5
5
  const path = require('path');
6
- const locationStr = `core.${path.basename(__filename, path.extname(__filename))}`;
6
+ const { isBrowserEnv } = require('../util/isBrowserEnv');
7
+ const locationStr = !isBrowserEnv() ? `core.${path.basename(__filename, path.extname(__filename))}` : 'borwser';
7
8
 
8
9
  /**
9
10
  * @description 退出群聊
@@ -3,7 +3,8 @@ const axios = require('axios').default;
3
3
  const { URL } = require('../polyfill/URL');
4
4
  const errorHandler = require('../util/errorHandler');
5
5
  const path = require('path');
6
- const locationStr = `core.${path.basename(__filename, path.extname(__filename))}`;
6
+ const { isBrowserEnv } = require('../util/isBrowserEnv');
7
+ const locationStr = !isBrowserEnv() ? `core.${path.basename(__filename, path.extname(__filename))}` : 'borwser';
7
8
 
8
9
  /**
9
10
  * @description 撤回由 messageId 确定的消息
@@ -3,7 +3,8 @@ const axios = require('axios').default;
3
3
  const { URL } = require('../polyfill/URL');
4
4
  const errorHandler = require('../util/errorHandler');
5
5
  const path = require('path');
6
- const locationStr = `core.${path.basename(__filename, path.extname(__filename))}`;
6
+ const { isBrowserEnv } = require('../util/isBrowserEnv');
7
+ const locationStr = !isBrowserEnv() ? `core.${path.basename(__filename, path.extname(__filename))}` : 'borwser';
7
8
 
8
9
  /**
9
10
  * @description 关闭一个会话
@@ -3,7 +3,8 @@ const axios = require('axios').default;
3
3
  const { URL } = require('../polyfill/URL');
4
4
  const errorHandler = require('../util/errorHandler');
5
5
  const path = require('path');
6
- const locationStr = `core.${path.basename(__filename, path.extname(__filename))}`;
6
+ const { isBrowserEnv } = require('../util/isBrowserEnv');
7
+ const locationStr = !isBrowserEnv() ? `core.${path.basename(__filename, path.extname(__filename))}` : 'borwser';
7
8
 
8
9
  /**
9
10
  * @description 删除好友
@@ -3,7 +3,8 @@ const axios = require('axios').default;
3
3
  const { URL } = require('../polyfill/URL');
4
4
  const errorHandler = require('../util/errorHandler');
5
5
  const path = require('path');
6
- const locationStr = `core.${path.basename(__filename, path.extname(__filename))}`;
6
+ const { isBrowserEnv } = require('../util/isBrowserEnv');
7
+ const locationStr = !isBrowserEnv() ? `core.${path.basename(__filename, path.extname(__filename))}` : 'borwser';
7
8
 
8
9
  /**
9
10
  * @description 移除群成员
@@ -3,7 +3,8 @@ const axios = require('axios');
3
3
  const { URL } = require('../polyfill/URL');
4
4
  const errorHandler = require('../util/errorHandler');
5
5
  const path = require('path');
6
- const locationStr = `core.${path.basename(__filename, path.extname(__filename))}`;
6
+ const { isBrowserEnv } = require('../util/isBrowserEnv');
7
+ const locationStr = !isBrowserEnv() ? `core.${path.basename(__filename, path.extname(__filename))}` : 'borwser';
7
8
 
8
9
  /**
9
10
  * ! 自动同意时,不会触发该事件
@@ -3,7 +3,8 @@ const axios = require('axios');
3
3
  const { URL } = require('../polyfill/URL');
4
4
  const errorHandler = require('../util/errorHandler');
5
5
  const path = require('path');
6
- const locationStr = `core.${path.basename(__filename, path.extname(__filename))}`;
6
+ const { isBrowserEnv } = require('../util/isBrowserEnv');
7
+ const locationStr = !isBrowserEnv() ? `core.${path.basename(__filename, path.extname(__filename))}` : 'borwser';
7
8
 
8
9
  /**
9
10
  * @description 响应好友请求
@@ -3,7 +3,8 @@ const axios = require('axios');
3
3
  const { URL } = require('../polyfill/URL');
4
4
  const errorHandler = require('../util/errorHandler');
5
5
  const path = require('path');
6
- const locationStr = `core.${path.basename(__filename, path.extname(__filename))}`;
6
+ const { isBrowserEnv } = require('../util/isBrowserEnv');
7
+ const locationStr = !isBrowserEnv() ? `core.${path.basename(__filename, path.extname(__filename))}` : 'borwser';
7
8
 
8
9
  /**
9
10
  * FIXME: mirai-core 的问题,有时候收不到 MemberJoinRequestEvent 事件
@@ -3,7 +3,8 @@ const { errCodeMap } = require('../util/errCode');
3
3
  const { URL } = require('../polyfill/URL');
4
4
  const errorHandler = require('../util/errorHandler');
5
5
  const path = require('path');
6
- const locationStr = `core.${path.basename(__filename, path.extname(__filename))}`;
6
+ const { isBrowserEnv } = require('../util/isBrowserEnv');
7
+ const locationStr = !isBrowserEnv() ? `core.${path.basename(__filename, path.extname(__filename))}` : 'borwser';
7
8
 
8
9
  /**
9
10
  * @description 向 mirai-console 发送指令
@@ -3,7 +3,8 @@ const axios = require('axios').default;
3
3
  const { URL } = require('../polyfill/URL');
4
4
  const errorHandler = require('../util/errorHandler');
5
5
  const path = require('path');
6
- const locationStr = `core.${path.basename(__filename, path.extname(__filename))}`;
6
+ const { isBrowserEnv } = require('../util/isBrowserEnv');
7
+ const locationStr = !isBrowserEnv() ? `core.${path.basename(__filename, path.extname(__filename))}` : 'borwser';
7
8
 
8
9
  /**
9
10
  * @description 向 qq 好友发送消息
@@ -3,7 +3,8 @@ const axios = require('axios').default;
3
3
  const { URL } = require('../polyfill/URL');
4
4
  const errorHandler = require('../util/errorHandler');
5
5
  const path = require('path');
6
- const locationStr = `core.${path.basename(__filename, path.extname(__filename))}`;
6
+ const { isBrowserEnv } = require('../util/isBrowserEnv');
7
+ const locationStr = !isBrowserEnv() ? `core.${path.basename(__filename, path.extname(__filename))}` : 'borwser';
7
8
 
8
9
  /**
9
10
  * @description 向 qq 群发送消息
@@ -3,7 +3,8 @@ const axios = require('axios').default;
3
3
  const { URL } = require('../polyfill/URL');
4
4
  const errorHandler = require('../util/errorHandler');
5
5
  const path = require('path');
6
- const locationStr = `core.${path.basename(__filename, path.extname(__filename))}`;
6
+ const { isBrowserEnv } = require('../util/isBrowserEnv');
7
+ const locationStr = !isBrowserEnv() ? `core.${path.basename(__filename, path.extname(__filename))}` : 'borwser';
7
8
 
8
9
  /**
9
10
  * @description 发送戳一戳消息
@@ -3,7 +3,8 @@ const axios = require('axios').default;
3
3
  const { URL } = require('../polyfill/URL');
4
4
  const errorHandler = require('../util/errorHandler');
5
5
  const path = require('path');
6
- const locationStr = `core.${path.basename(__filename, path.extname(__filename))}`;
6
+ const { isBrowserEnv } = require('../util/isBrowserEnv');
7
+ const locationStr = !isBrowserEnv() ? `core.${path.basename(__filename, path.extname(__filename))}` : 'borwser';
7
8
 
8
9
  /**
9
10
  * @description 向临时对象发送消息
@@ -3,7 +3,8 @@ const axios = require('axios').default;
3
3
  const { URL } = require('../polyfill/URL');
4
4
  const errorHandler = require('../util/errorHandler');
5
5
  const path = require('path');
6
- const locationStr = `core.${path.basename(__filename, path.extname(__filename))}`;
6
+ const { isBrowserEnv } = require('../util/isBrowserEnv');
7
+ const locationStr = !isBrowserEnv() ? `core.${path.basename(__filename, path.extname(__filename))}` : 'borwser';
7
8
 
8
9
 
9
10
  /**
@@ -3,7 +3,8 @@ const axios = require('axios').default;
3
3
  const { URL } = require('../polyfill/URL');
4
4
  const errorHandler = require('../util/errorHandler');
5
5
  const path = require('path');
6
- const locationStr = `core.${path.basename(__filename, path.extname(__filename))}`;
6
+ const { isBrowserEnv } = require('../util/isBrowserEnv');
7
+ const locationStr = !isBrowserEnv() ? `core.${path.basename(__filename, path.extname(__filename))}` : 'borwser';
7
8
 
8
9
 
9
10
  /**
@@ -3,7 +3,8 @@ const axios = require('axios');
3
3
  const { URL } = require('../polyfill/URL');
4
4
  const errorHandler = require('../util/errorHandler');
5
5
  const path = require('path');
6
- const locationStr = `core.${path.basename(__filename, path.extname(__filename))}`;
6
+ const { isBrowserEnv } = require('../util/isBrowserEnv');
7
+ const locationStr = !isBrowserEnv() ? `core.${path.basename(__filename, path.extname(__filename))}` : 'borwser';
7
8
 
8
9
  /**
9
10
  * @description 设置群成员权限
@@ -3,7 +3,8 @@ const axios = require('axios');
3
3
  const { URL } = require('../polyfill/URL');
4
4
  const errorHandler = require('../util/errorHandler');
5
5
  const path = require('path');
6
- const locationStr = `core.${path.basename(__filename, path.extname(__filename))}`;
6
+ const { isBrowserEnv } = require('../util/isBrowserEnv');
7
+ const locationStr = !isBrowserEnv() ? `core.${path.basename(__filename, path.extname(__filename))}` : 'borwser';
7
8
 
8
9
  /**
9
10
  * @description 设置群成员信息
@@ -3,7 +3,8 @@ const axios = require('axios').default;
3
3
  const { URL } = require('../polyfill/URL');
4
4
  const errorHandler = require('../util/errorHandler');
5
5
  const path = require('path');
6
- const locationStr = `core.${path.basename(__filename, path.extname(__filename))}`;
6
+ const { isBrowserEnv } = require('../util/isBrowserEnv');
7
+ const locationStr = !isBrowserEnv() ? `core.${path.basename(__filename, path.extname(__filename))}` : 'borwser';
7
8
 
8
9
 
9
10
  /**