alemonjs 1.0.47 → 1.0.48

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 (39) hide show
  1. package/lib/core/buffer.js +27 -26
  2. package/lib/core/ip.js +2 -4
  3. package/lib/koa/img.js +1 -2
  4. package/lib/kook/alemon/conversation.js +1 -5
  5. package/lib/kook/alemon/message/PUBLIC_GUILD_MESSAGES.js +27 -25
  6. package/lib/kook/index.js +6 -6
  7. package/lib/kook/sdk/api.js +8 -47
  8. package/lib/log/index.js +4 -0
  9. package/lib/logs.js +23 -0
  10. package/lib/ntqq/alemon/message/C2C_MESSAGE_CREATE.js +5 -14
  11. package/lib/ntqq/alemon/message/GROUP_AT_MESSAGE_CREATE.js +5 -14
  12. package/lib/qq/alemon/apidoc.js +0 -9
  13. package/lib/qq/alemon/message/DIRECT_MESSAGE.js +7 -17
  14. package/lib/qq/alemon/message/GUILD_MEMBERS.js +7 -16
  15. package/lib/qq/alemon/message/GUILD_MESSAGES.js +2 -11
  16. package/lib/qq/alemon/message/MESSAGE.js +9 -18
  17. package/lib/qq/alemon/message/PUBLIC_GUILD_MESSAGES.js +2 -11
  18. package/lib/qq/alemon/permissions.js +2 -5
  19. package/lib/qq/alemon/privatechat.js +6 -9
  20. package/lib/run.js +1 -1
  21. package/lib/villa/alemon/conversation.js +0 -4
  22. package/lib/villa/alemon/message/MESSAGES.js +15 -24
  23. package/lib/villa/alemon/segment.js +2 -2
  24. package/lib/villa/sdk/api.js +67 -117
  25. package/lib/villa/sdk/client.js +3 -8
  26. package/lib/villa/sdk/mechanism.js +10 -6
  27. package/logs.d.ts +9 -0
  28. package/logs.js +23 -0
  29. package/package.json +11 -5
  30. package/run.js +1 -1
  31. package/types/core/buffer.d.ts +4 -4
  32. package/types/kook/sdk/api.d.ts +23 -9
  33. package/types/log/index.d.ts +1 -0
  34. package/types/logs.d.ts +6 -0
  35. package/types/qq/alemon/apidoc.d.ts +5 -0
  36. package/types/qq/alemon/message/GUILD_MESSAGES.d.ts +3 -0
  37. package/types/qq/alemon/message/PUBLIC_GUILD_MESSAGES.d.ts +5 -0
  38. package/types/villa/sdk/api.d.ts +103 -32
  39. package/types/villa/sdk/reply.d.ts +18 -6
@@ -1,38 +1,39 @@
1
- import { readFileSync } from 'fs';
2
- import http from 'http';
3
- import https from 'https';
1
+ import { existsSync, readFileSync } from 'fs';
2
+ import axios from 'axios';
4
3
  import { join } from 'path';
5
4
  /**
6
5
  * 异步请求图片
7
6
  * @param url 网络地址
8
7
  * @returns buffer
9
8
  */
10
- export function getUrlbuffer(url) {
11
- return new Promise((resolve, reject) => {
12
- const protocol = url.startsWith('https') ? https : http;
13
- protocol
14
- .get(url, response => {
15
- if (response.statusCode !== 200) {
16
- reject(new Error(`Failed to fetch image: ${response.statusCode}`));
17
- }
18
- else {
19
- const chunks = [];
20
- response.on('data', chunk => chunks.push(chunk));
21
- response.on('end', () => resolve(Buffer.concat(chunks)));
22
- }
23
- })
24
- .on('error', reject);
9
+ export async function getUrlbuffer(url) {
10
+ return await axios
11
+ .get(url, {
12
+ responseType: 'arraybuffer'
13
+ })
14
+ .then(res => {
15
+ if (res.data)
16
+ return Buffer.from(res.data, 'binary');
17
+ return false;
25
18
  });
26
19
  }
27
20
  /**
28
21
  * 读取本地图片
29
- * @param path 本地地址 /public/img/xx.png
30
- * @returns buffer
22
+ * @param val
23
+ * @returns
31
24
  */
32
- export function getPathBuffer(path) {
33
- // 读取本地图片
34
- const image = readFileSync(join(process.cwd(), path));
35
- // 将图片转换为 Buffer 对象
36
- const BufferImage = Buffer.from(image);
37
- return BufferImage;
25
+ export function getPathBuffer(val) {
26
+ const add = join(process.cwd(), val);
27
+ try {
28
+ // 绝对路径
29
+ if (existsSync(add))
30
+ return Buffer.from(readFileSync(add));
31
+ // 相对路径
32
+ if (existsSync(val))
33
+ return Buffer.from(readFileSync(val));
34
+ }
35
+ catch (err) {
36
+ console.info(err);
37
+ }
38
+ return false;
38
39
  }
package/lib/core/ip.js CHANGED
@@ -10,10 +10,8 @@ export async function getIP() {
10
10
  return await publicIp({
11
11
  timeout: 10000
12
12
  }).then(ip => {
13
- if (/^(\d{1,3}\.){3}\d{1,3}$/.test(ip)) {
13
+ if (/^(\d{1,3}\.){3}\d{1,3}$/.test(ip))
14
14
  myIp = ip;
15
- return myIp;
16
- }
17
- return false;
15
+ return myIp ?? false;
18
16
  });
19
17
  }
package/lib/koa/img.js CHANGED
@@ -58,9 +58,8 @@ export async function setLocalImg(img) {
58
58
  const http = getServerConfig('http');
59
59
  let ip = await getIP();
60
60
  const ipp = getServerConfig('ip');
61
- if (ipp != 'localhost') {
61
+ if (ipp != 'localhost')
62
62
  ip = ipp;
63
- }
64
63
  // 生成文件名
65
64
  const filename = `${Math.floor(Math.random() * imgSize)}.${(await fileTypeFromBuffer(img))?.ext}`;
66
65
  // 文件路径
@@ -37,7 +37,6 @@ const ConversationMap = {
37
37
  */
38
38
  [255]: (event) => {
39
39
  console.info('system message', new Date(event.msg_timestamp));
40
- // console.info('event', event)
41
40
  }
42
41
  };
43
42
  /**
@@ -49,8 +48,5 @@ export async function callBackByKOOK(event) {
49
48
  if (Object.prototype.hasOwnProperty.call(ConversationMap, event.type)) {
50
49
  return await ConversationMap[event.type](event);
51
50
  }
52
- else {
53
- // console.info('kook new message', event.type)
54
- return false;
55
- }
51
+ return false;
56
52
  }
@@ -3,11 +3,7 @@ import { KOOKApiClient } from '../../sdk/index.js';
3
3
  import { segmentKOOK } from '../segment.js';
4
4
  import { getBotMsgByKOOK } from '../bot.js';
5
5
  import { getBotConfigByKey } from '../../../config/index.js';
6
- import { AlemonJSError, AlemonJSLog } from '../../../log/user.js';
7
- const error = err => {
8
- console.error(err);
9
- return err;
10
- };
6
+ import { AlemonJSError, AlemonJSLog, everyoneError } from '../../../log/index.js';
11
7
  /**
12
8
  *
13
9
  * @param event
@@ -93,21 +89,21 @@ export const PUBLIC_GUILD_MESSAGES_KOOK = async (event) => {
93
89
  */
94
90
  if (Buffer.isBuffer(msg)) {
95
91
  try {
96
- const url = await KOOKApiClient.postImage(msg);
97
- if (url) {
92
+ const ret = await KOOKApiClient.postImage(msg);
93
+ if (ret && ret.data) {
98
94
  if (event.channel_type == 'GROUP') {
99
95
  return await KOOKApiClient.createMessage({
100
96
  type: 2,
101
97
  target_id: event.target_id,
102
- content: url
103
- }).catch(error);
98
+ content: ret.data.url
99
+ }).catch(everyoneError);
104
100
  }
105
101
  return await KOOKApiClient.createDirectMessage({
106
102
  type: 2,
107
103
  target_id: event.target_id,
108
104
  chat_code: event.extra.code,
109
- content: url
110
- }).catch(error);
105
+ content: ret.data.url
106
+ }).catch(everyoneError);
111
107
  }
112
108
  return false;
113
109
  }
@@ -132,8 +128,10 @@ export const PUBLIC_GUILD_MESSAGES_KOOK = async (event) => {
132
128
  .filter(element => typeof element === 'string')
133
129
  .join('');
134
130
  // 转存
135
- const url = await KOOKApiClient.postImage(msg[isBuffer]);
136
- if (url) {
131
+ const ret = await KOOKApiClient.postImage(msg[isBuffer]);
132
+ if (!ret)
133
+ return false;
134
+ if (ret?.data) {
137
135
  // 群
138
136
  if (event.channel_type == 'GROUP') {
139
137
  await KOOKApiClient.createMessage({
@@ -144,8 +142,8 @@ export const PUBLIC_GUILD_MESSAGES_KOOK = async (event) => {
144
142
  return await KOOKApiClient.createMessage({
145
143
  type: 2,
146
144
  target_id: event.target_id,
147
- content: url
148
- }).catch(error);
145
+ content: ret.data.url
146
+ }).catch(everyoneError);
149
147
  }
150
148
  }
151
149
  // 私聊
@@ -159,8 +157,8 @@ export const PUBLIC_GUILD_MESSAGES_KOOK = async (event) => {
159
157
  type: 2,
160
158
  target_id: event.target_id,
161
159
  chat_code: event.extra.code,
162
- content: String(url)
163
- }).catch(error);
160
+ content: String(ret.data.url)
161
+ }).catch(everyoneError);
164
162
  }
165
163
  const content = Array.isArray(msg)
166
164
  ? msg.join('')
@@ -175,21 +173,25 @@ export const PUBLIC_GUILD_MESSAGES_KOOK = async (event) => {
175
173
  if (match) {
176
174
  const getUrl = match[1];
177
175
  const msg = await getUrlbuffer(getUrl);
178
- const url = await KOOKApiClient.postImage(msg);
179
- if (msg && url) {
176
+ if (!msg)
177
+ return false;
178
+ const ret = await KOOKApiClient.postImage(msg);
179
+ if (!ret)
180
+ return false;
181
+ if (msg && ret) {
180
182
  if (event.channel_type == 'GROUP') {
181
183
  return await KOOKApiClient.createMessage({
182
184
  type: 2,
183
185
  target_id: event.target_id,
184
- content: url
185
- }).catch(error);
186
+ content: ret.data.url
187
+ }).catch(everyoneError);
186
188
  }
187
189
  return await KOOKApiClient.createDirectMessage({
188
190
  type: 2,
189
191
  target_id: event.target_id,
190
192
  chat_code: event.extra.code,
191
- content: url
192
- }).catch(error);
193
+ content: ret.data.url
194
+ }).catch(everyoneError);
193
195
  }
194
196
  }
195
197
  if (event.channel_type == 'GROUP') {
@@ -198,7 +200,7 @@ export const PUBLIC_GUILD_MESSAGES_KOOK = async (event) => {
198
200
  type: 9,
199
201
  target_id: event.target_id,
200
202
  content
201
- }).catch(error);
203
+ }).catch(everyoneError);
202
204
  }
203
205
  catch (err) {
204
206
  console.error(err);
@@ -211,7 +213,7 @@ export const PUBLIC_GUILD_MESSAGES_KOOK = async (event) => {
211
213
  target_id: event.target_id,
212
214
  chat_code: event.extra.code,
213
215
  content
214
- }).catch(error);
216
+ }).catch(everyoneError);
215
217
  }
216
218
  catch (err) {
217
219
  console.error(err);
package/lib/kook/index.js CHANGED
@@ -23,14 +23,14 @@ export async function createAlemonByKOOK() {
23
23
  * 创建连接
24
24
  */
25
25
  await createClient(cfg.token, callBackByKOOK).then(async (res) => {
26
- const data = await KOOKApiClient.getBotInformation();
27
- if (data) {
26
+ const ret = await KOOKApiClient.getBotInformation();
27
+ if (ret?.data) {
28
28
  setBotMsgByKOOK({
29
- id: data.id,
30
- name: data.username,
31
- avatar: data.avatar
29
+ id: ret.data.id,
30
+ name: ret.data.username,
31
+ avatar: ret.data.avatar
32
32
  });
33
- console.info('KOOK Welcome back', data.username);
33
+ console.info('KOOK Welcome back', ret.data.username);
34
34
  }
35
35
  });
36
36
  return true;
@@ -74,24 +74,12 @@ export async function postImage(file, name = 'image.jpg') {
74
74
  * @returns
75
75
  */
76
76
  export async function createUrl(formdata) {
77
- const ret = await kookService({
77
+ return await kookService({
78
78
  method: 'post',
79
79
  url: ApiEnum.AssetCreate,
80
80
  data: formdata,
81
81
  headers: formdata.getHeaders()
82
- })
83
- .then(res => {
84
- const re = res.data;
85
- return re.data;
86
- })
87
- .catch(err => {
88
- console.error(err);
89
- return false;
90
- });
91
- if (!ret) {
92
- return false;
93
- }
94
- return ret.url;
82
+ }).then(res => res.data);
95
83
  }
96
84
  /**
97
85
  * *********
@@ -99,19 +87,10 @@ export async function createUrl(formdata) {
99
87
  * **********
100
88
  */
101
89
  export async function getBotInformation() {
102
- const ret = await kookService({
90
+ return await kookService({
103
91
  method: 'post',
104
92
  url: ApiEnum.UserMe
105
- })
106
- .then(res => {
107
- const re = res.data;
108
- return re.data;
109
- })
110
- .catch(err => {
111
- console.error(err);
112
- return false;
113
- });
114
- return ret;
93
+ }).then(res => res.data);
115
94
  }
116
95
  /**
117
96
  * *********
@@ -124,20 +103,11 @@ export async function getBotInformation() {
124
103
  * @returns
125
104
  */
126
105
  export async function createMessage(data) {
127
- const ret = await kookService({
106
+ return await kookService({
128
107
  method: 'post',
129
108
  url: ApiEnum.MessageCreate,
130
109
  data
131
- })
132
- .then(res => {
133
- const re = res.data;
134
- return re.data;
135
- })
136
- .catch(err => {
137
- console.error(err);
138
- return false;
139
- });
140
- return ret;
110
+ }).then(res => res.data);
141
111
  }
142
112
  /**
143
113
  * 创建私聊消息
@@ -148,18 +118,9 @@ export async function createMessage(data) {
148
118
  * @returns
149
119
  */
150
120
  export async function createDirectMessage(data) {
151
- const ret = await kookService({
121
+ return kookService({
152
122
  method: 'post',
153
123
  url: ApiEnum.DirectMessageCreate,
154
124
  data
155
- })
156
- .then(res => {
157
- const re = res.data;
158
- return re.data;
159
- })
160
- .catch(err => {
161
- console.error(err);
162
- return false;
163
- });
164
- return ret;
125
+ }).then(res => res.data);
165
126
  }
package/lib/log/index.js CHANGED
@@ -1,2 +1,6 @@
1
1
  export * from './user.js';
2
2
  export * from './event.js';
3
+ export const everyoneError = (err) => {
4
+ console.error(err);
5
+ return err;
6
+ };
package/lib/logs.js ADDED
@@ -0,0 +1,23 @@
1
+ /**
2
+ * 重定义log
3
+ * @param fun 中间值
4
+ * @param prefix 前缀
5
+ */
6
+ export function setLog(fun, prefix = '[AlemonJS]') {
7
+ const log = console.log;
8
+ global.console.log = (...argv) => {
9
+ log(prefix, `[${fun()}]`, ...argv);
10
+ };
11
+ const info = console.info;
12
+ global.console.info = (...argv) => {
13
+ info(prefix, `[${fun()}]`, ...argv);
14
+ };
15
+ const error = console.error;
16
+ global.console.error = (...argv) => {
17
+ error(prefix, `[${fun()}]`, ...argv);
18
+ };
19
+ const debug = console.debug;
20
+ global.console.debug = (...argv) => {
21
+ debug(prefix, `[${fun()}]`, ...argv);
22
+ };
23
+ }
@@ -4,17 +4,8 @@ import { segmentQQ } from '../segment.js';
4
4
  import { getBotMsgByNtqq } from '../bot.js';
5
5
  import IMGS from 'image-size';
6
6
  import { ClientKOA } from '../../../koa/index.js';
7
- import { AlemonJSError, AlemonJSLog } from '../../../log/user.js';
7
+ import { AlemonJSError, AlemonJSLog, everyoneError } from '../../../log/index.js';
8
8
  import { getBotConfigByKey } from '../../../config/index.js';
9
- /**
10
- * 错误打印
11
- * @param err
12
- * @returns
13
- */
14
- const error = err => {
15
- console.error(err);
16
- return err;
17
- };
18
9
  export const C2C_MESSAGE_CREATE = async (event) => {
19
10
  const cfg = getBotConfigByKey('ntqq');
20
11
  const masterID = cfg.masterID;
@@ -40,7 +31,7 @@ export const C2C_MESSAGE_CREATE = async (event) => {
40
31
  const url = await ClientKOA.setLocalImg(msg);
41
32
  if (!url)
42
33
  return false;
43
- return await Client.postFilesByUsers(event.author.user_openid, url).catch(error);
34
+ return await Client.postFilesByUsers(event.author.user_openid, url).catch(everyoneError);
44
35
  }
45
36
  catch (err) {
46
37
  console.error(err);
@@ -65,7 +56,7 @@ export const C2C_MESSAGE_CREATE = async (event) => {
65
56
  const url = await ClientKOA.setLocalImg(msg[isBuffer]);
66
57
  if (!url)
67
58
  return false;
68
- return await Client.postMessageByUser(event.author.user_openid, `${cont} ![text #${dimensions.width}px #${dimensions.height}px](${url})`, select?.quote).catch(error);
59
+ return await Client.postMessageByUser(event.author.user_openid, `${cont} ![text #${dimensions.width}px #${dimensions.height}px](${url})`, select?.quote).catch(everyoneError);
69
60
  }
70
61
  catch (err) {
71
62
  console.error(err);
@@ -92,10 +83,10 @@ export const C2C_MESSAGE_CREATE = async (event) => {
92
83
  const url = await ClientKOA.setLocalImg(msg);
93
84
  if (!url)
94
85
  return false;
95
- return await Client.postFilesByUsers(event.author.user_openid, url).catch(error);
86
+ return await Client.postFilesByUsers(event.author.user_openid, url).catch(everyoneError);
96
87
  }
97
88
  }
98
- return await Client.postMessageByUser(event.author.user_openid, content, select?.quote).catch(error);
89
+ return await Client.postMessageByUser(event.author.user_openid, content, select?.quote).catch(everyoneError);
99
90
  };
100
91
  e.replyCard = async (arr) => {
101
92
  for (const item of arr) {
@@ -5,16 +5,7 @@ import { getBotMsgByNtqq } from '../bot.js';
5
5
  import { getBotConfigByKey } from '../../../config/index.js';
6
6
  import { ClientKOA } from '../../../koa/index.js';
7
7
  import IMGS from 'image-size';
8
- import { AlemonJSError, AlemonJSLog } from '../../../log/user.js';
9
- /**
10
- * 错误打印
11
- * @param err
12
- * @returns
13
- */
14
- const error = err => {
15
- console.error(err);
16
- return err;
17
- };
8
+ import { AlemonJSError, AlemonJSLog, everyoneError } from '../../../log/index.js';
18
9
  /**
19
10
  * 公私域合并
20
11
  * @param e
@@ -49,7 +40,7 @@ export const GROUP_AT_MESSAGE_CREATE = async (event) => {
49
40
  const url = await ClientKOA.setLocalImg(msg);
50
41
  if (!url)
51
42
  return false;
52
- return await Client.postFilesByGroup(event.group_id, url).catch(error);
43
+ return await Client.postFilesByGroup(event.group_id, url).catch(everyoneError);
53
44
  }
54
45
  catch (err) {
55
46
  console.error(err);
@@ -71,7 +62,7 @@ export const GROUP_AT_MESSAGE_CREATE = async (event) => {
71
62
  const url = await ClientKOA.setLocalImg(msg[isBuffer]);
72
63
  if (!url)
73
64
  return false;
74
- return await Client.postMessageByGroup(event.group_id, `${cont} ![text #${dimensions.width}px #${dimensions.height}px](${url})`, select?.quote).catch(error);
65
+ return await Client.postMessageByGroup(event.group_id, `${cont} ![text #${dimensions.width}px #${dimensions.height}px](${url})`, select?.quote).catch(everyoneError);
75
66
  }
76
67
  catch (err) {
77
68
  console.error(err);
@@ -98,10 +89,10 @@ export const GROUP_AT_MESSAGE_CREATE = async (event) => {
98
89
  const url = await ClientKOA.setLocalImg(msg);
99
90
  if (!url)
100
91
  return false;
101
- return await Client.postFilesByGroup(event.group_id, url).catch(error);
92
+ return await Client.postFilesByGroup(event.group_id, url).catch(everyoneError);
102
93
  }
103
94
  }
104
- return await Client.postMessageByGroup(event.group_id, content, select?.quote).catch(error);
95
+ return await Client.postMessageByGroup(event.group_id, content, select?.quote).catch(everyoneError);
105
96
  };
106
97
  e.replyCard = async (arr) => {
107
98
  for (const item of arr) {
@@ -3,15 +3,6 @@
3
3
  * 频道api
4
4
  * ************
5
5
  */
6
- /**
7
- * 错误打印
8
- * @param err
9
- * @returns
10
- */
11
- const error = err => {
12
- console.error(err);
13
- return err;
14
- };
15
6
  /**
16
7
  * 获取当前用户下的所有频道列表
17
8
  * @returns
@@ -2,18 +2,8 @@ import { typeMessage, InstructionMatching, getUrlbuffer } from '../../../core/in
2
2
  import { ClientAPIByQQ as Client } from '../../sdk/index.js';
3
3
  import { segmentQQ } from '../segment.js';
4
4
  import { getBotMsgByQQ } from '../bot.js';
5
- import { AlemonJSError, AlemonJSLog } from '../../../log/user.js';
6
- import { AlemonJSEventError, AlemonJSEventLog } from '../../../log/event.js';
5
+ import { AlemonJSError, AlemonJSLog, AlemonJSEventError, AlemonJSEventLog, everyoneError } from '../../../log/index.js';
7
6
  import { getBotConfigByKey } from '../../../config/index.js';
8
- /**
9
- * 错误打印
10
- * @param err
11
- * @returns
12
- */
13
- const error = err => {
14
- console.error(err);
15
- return err;
16
- };
17
7
  /**
18
8
  * *
19
9
  * 私信
@@ -56,7 +46,7 @@ export const DIRECT_MESSAGE = async (event) => {
56
46
  /**
57
47
  * 优化接口
58
48
  */
59
- await directMessage(e, event).catch(error);
49
+ await directMessage(e, event).catch(everyoneError);
60
50
  console.info(`\n[${event.msg.author.username}][${event.msg.author.id}][${e.isGroup}] ${event.msg.content ? event.msg.content : ''}`);
61
51
  };
62
52
  async function directMessage(e, event) {
@@ -68,7 +58,7 @@ async function directMessage(e, event) {
68
58
  id: event.msg.guild_id,
69
59
  msg_id: event.msg.id,
70
60
  image: msg //buffer
71
- }).catch(error);
61
+ }).catch(everyoneError);
72
62
  }
73
63
  catch (err) {
74
64
  console.error(err);
@@ -92,7 +82,7 @@ async function directMessage(e, event) {
92
82
  msg_id: event.msg.id,
93
83
  image: msg[isBuffer],
94
84
  content: cont
95
- }).catch(error);
85
+ }).catch(everyoneError);
96
86
  }
97
87
  catch (err) {
98
88
  console.error(err);
@@ -120,7 +110,7 @@ async function directMessage(e, event) {
120
110
  id: event.msg.channel_id,
121
111
  msg_id: event.msg.id,
122
112
  image: msg //buffer
123
- }).catch(error);
113
+ }).catch(everyoneError);
124
114
  }
125
115
  }
126
116
  return await clientApiByQQ.directMessageApi
@@ -128,7 +118,7 @@ async function directMessage(e, event) {
128
118
  msg_id: event.msg.id,
129
119
  content
130
120
  })
131
- .catch(error);
121
+ .catch(everyoneError);
132
122
  };
133
123
  e.replyCard = async (arr) => {
134
124
  for (const item of arr) {
@@ -139,7 +129,7 @@ async function directMessage(e, event) {
139
129
  msg_id: event.msg.id,
140
130
  ...item.card
141
131
  })
142
- .catch(error);
132
+ .catch(everyoneError);
143
133
  }
144
134
  else {
145
135
  return false;
@@ -2,16 +2,7 @@ import { typeMessage, getUrlbuffer } from '../../../core/index.js';
2
2
  import { getBotMsgByQQ } from '../bot.js';
3
3
  // 非依赖引用
4
4
  import { ClientAPIByQQ as Client } from '../../sdk/index.js';
5
- import { AlemonJSEventError, AlemonJSEventLog } from '../../../log/event.js';
6
- /**
7
- * 错误打印
8
- * @param err
9
- * @returns
10
- */
11
- const error = err => {
12
- console.error(err);
13
- return err;
14
- };
5
+ import { AlemonJSEventError, AlemonJSEventLog, everyoneError } from '../../../log/index.js';
15
6
  /**
16
7
  GUILD_MEMBERS (1 << 1)
17
8
  - GUILD_MEMBER_ADD // 当成员加入时
@@ -39,7 +30,7 @@ export const GUILD_MEMBERS = async (event) => {
39
30
  const { data } = res;
40
31
  return data;
41
32
  })
42
- .catch(error);
33
+ .catch(everyoneError);
43
34
  if (typeof ChannelsData == 'boolean') {
44
35
  console.info(`[${Eevent}] [${eventType}] ${false}`);
45
36
  return false;
@@ -73,7 +64,7 @@ export const GUILD_MEMBERS = async (event) => {
73
64
  id: ChannelData.id,
74
65
  msg_id: event.msg.id,
75
66
  image: msg //buffer
76
- }).catch(error);
67
+ }).catch(everyoneError);
77
68
  }
78
69
  catch (err) {
79
70
  console.error(err);
@@ -97,7 +88,7 @@ export const GUILD_MEMBERS = async (event) => {
97
88
  msg_id: event.msg.id,
98
89
  image: msg[isBuffer],
99
90
  content: cont
100
- }).catch(error);
91
+ }).catch(everyoneError);
101
92
  }
102
93
  catch (err) {
103
94
  console.error(err);
@@ -125,7 +116,7 @@ export const GUILD_MEMBERS = async (event) => {
125
116
  id: event.msg.channel_id,
126
117
  msg_id: event.msg.id,
127
118
  image: msg //buffer
128
- }).catch(error);
119
+ }).catch(everyoneError);
129
120
  }
130
121
  }
131
122
  /**
@@ -135,7 +126,7 @@ export const GUILD_MEMBERS = async (event) => {
135
126
  .postMessage(ChannelData.id, {
136
127
  content
137
128
  })
138
- .catch(error);
129
+ .catch(everyoneError);
139
130
  },
140
131
  replyCard: async (arr) => {
141
132
  for (const item of arr) {
@@ -146,7 +137,7 @@ export const GUILD_MEMBERS = async (event) => {
146
137
  msg_id: event.msg.id,
147
138
  ...item.card
148
139
  })
149
- .catch(error);
140
+ .catch(everyoneError);
150
141
  }
151
142
  else {
152
143
  return false;
@@ -1,19 +1,10 @@
1
1
  import { typeMessage } from '../../../core/index.js';
2
2
  import { mergeMessages } from './MESSAGE.js';
3
3
  import { getBotMsgByQQ } from '../bot.js';
4
- import { AlemonJSEventError, AlemonJSEventLog } from '../../../log/event.js';
4
+ import { everyoneError, AlemonJSEventError, AlemonJSEventLog } from '../../../log/index.js';
5
5
  /**
6
6
  * *私域*
7
7
  */
8
- /**
9
- * 错误打印
10
- * @param err
11
- * @returns
12
- */
13
- const error = err => {
14
- console.error(err);
15
- return err;
16
- };
17
8
  /**
18
9
  GUILD_MESSAGES (1 << 9) // 消息事件,仅 *私域* 机器人能够设置此 intents。
19
10
  - MESSAGE_CREATE
@@ -52,5 +43,5 @@ export const GUILD_MESSAGES = async (event) => {
52
43
  /**
53
44
  * 消息方法
54
45
  */
55
- mergeMessages(e, event).catch(error);
46
+ mergeMessages(e, event).catch(everyoneError);
56
47
  };