@alemonjs/qq-bot 0.0.9 → 0.0.10

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 (40) hide show
  1. package/dist/assets/index.css +476 -0
  2. package/dist/assets/index.js +11032 -0
  3. package/dist/index.html +15 -0
  4. package/lib/api.d.ts +971 -843
  5. package/lib/api.js +1172 -1156
  6. package/lib/client.d.ts +22 -22
  7. package/lib/client.js +201 -217
  8. package/lib/config.js +2 -2
  9. package/lib/desktop.d.ts +2 -2
  10. package/lib/desktop.js +60 -59
  11. package/lib/from.js +27 -34
  12. package/lib/index.d.ts +7 -7
  13. package/lib/index.js +406 -405
  14. package/lib/message/AT_MESSAGE_CREATE.d.ts +35 -35
  15. package/lib/message/C2C_MESSAGE_CREATE.d.ts +9 -9
  16. package/lib/message/CHANNEL_CREATE.d.ts +15 -15
  17. package/lib/message/CHANNEL_DELETE.d.ts +15 -15
  18. package/lib/message/CHANNEL_UPDATE.d.ts +15 -15
  19. package/lib/message/DIRECT_MESSAGE_CREATE.d.ts +29 -29
  20. package/lib/message/DIRECT_MESSAGE_DELETE.d.ts +17 -17
  21. package/lib/message/ERROR.d.ts +2 -2
  22. package/lib/message/GROUP_AT_MESSAGE_CREATE.d.ts +10 -10
  23. package/lib/message/GUILD_CREATE.d.ts +15 -15
  24. package/lib/message/GUILD_DELETE.d.ts +15 -15
  25. package/lib/message/GUILD_MEMBER_ADD.d.ts +14 -14
  26. package/lib/message/GUILD_MEMBER_REMOVE.d.ts +14 -14
  27. package/lib/message/GUILD_MEMBER_UPDATE.d.ts +14 -14
  28. package/lib/message/GUILD_UPDATE.d.ts +15 -15
  29. package/lib/message/INTERACTION_CREATE.d.ts +2 -2
  30. package/lib/message/MESSAGE_CREATE.d.ts +2 -2
  31. package/lib/message/MESSAGE_DELETE.d.ts +2 -2
  32. package/lib/message/MESSAGE_REACTION_ADD.d.ts +13 -13
  33. package/lib/message/MESSAGE_REACTION_REMOVE.d.ts +13 -13
  34. package/lib/message/PUBLIC_MESSAGE_DELETE.d.ts +15 -15
  35. package/lib/message/READY.d.ts +6 -6
  36. package/lib/message.d.ts +46 -46
  37. package/lib/send/index.js +230 -192
  38. package/lib/typing.d.ts +62 -54
  39. package/lib/webhook.js +46 -48
  40. package/package.json +1 -1
@@ -3,19 +3,19 @@
3
3
  * @param event
4
4
  */
5
5
  type PUBLIC_MESSAGE_DELETE_TYPE = {
6
- message: {
7
- author: {
8
- bot: false;
9
- id: string;
10
- username: string;
11
- };
12
- channel_id: string;
13
- guild_id: string;
14
- id: string;
15
- };
16
- op_user: {
17
- id: string;
18
- };
19
- };
6
+ message: {
7
+ author: {
8
+ bot: false
9
+ id: string
10
+ username: string
11
+ }
12
+ channel_id: string
13
+ guild_id: string
14
+ id: string
15
+ }
16
+ op_user: {
17
+ id: string
18
+ }
19
+ }
20
20
 
21
- export type { PUBLIC_MESSAGE_DELETE_TYPE };
21
+ export type { PUBLIC_MESSAGE_DELETE_TYPE }
@@ -2,10 +2,10 @@
2
2
  * 登录
3
3
  */
4
4
  type READY_TYPE = {
5
- user: {
6
- id: string;
7
- name: string;
8
- };
9
- };
5
+ user: {
6
+ id: string
7
+ name: string
8
+ }
9
+ }
10
10
 
11
- export type { READY_TYPE };
11
+ export type { READY_TYPE }
package/lib/message.d.ts CHANGED
@@ -1,49 +1,49 @@
1
- import { C2C_MESSAGE_CREATE_TYPE } from './message/C2C_MESSAGE_CREATE.js';
2
- import { GROUP_AT_MESSAGE_CREATE_TYPE } from './message/GROUP_AT_MESSAGE_CREATE.js';
3
- import { AT_MESSAGE_CREATE_TYPE } from './message/AT_MESSAGE_CREATE.js';
4
- import { CHANNEL_CREATE_TYPE } from './message/CHANNEL_CREATE.js';
5
- import { CHANNEL_DELETE_TYPE } from './message/CHANNEL_DELETE.js';
6
- import { CHANNEL_UPDATE_TYPE } from './message/CHANNEL_UPDATE.js';
7
- import { DIRECT_MESSAGE_CREATE_TYPE } from './message/DIRECT_MESSAGE_CREATE.js';
8
- import { DIRECT_MESSAGE_DELETE_TYPE } from './message/DIRECT_MESSAGE_DELETE.js';
9
- import { GUILD_CREATE_TYPE } from './message/GUILD_CREATE.js';
10
- import { GUILD_DELETE_TYPE } from './message/GUILD_DELETE.js';
11
- import { GUILD_MEMBER_ADD_TYPE } from './message/GUILD_MEMBER_ADD.js';
12
- import { GUILD_MEMBER_REMOVE_TYPE } from './message/GUILD_MEMBER_REMOVE.js';
13
- import { GUILD_MEMBER_UPDATE_TYPE } from './message/GUILD_MEMBER_UPDATE.js';
14
- import { GUILD_UPDATE_TYPE } from './message/GUILD_UPDATE.js';
15
- import { INTERACTION_CREATE_TYPE } from './message/INTERACTION_CREATE.js';
16
- import { MESSAGE_CREATE_TYPE } from './message/MESSAGE_CREATE.js';
17
- import { MESSAGE_DELETE_TYPE } from './message/MESSAGE_DELETE.js';
18
- import { MESSAGE_REACTION_ADD_TYPE } from './message/MESSAGE_REACTION_ADD.js';
19
- import { MESSAGE_REACTION_REMOVE_TYPE } from './message/MESSAGE_REACTION_REMOVE.js';
20
- import { PUBLIC_MESSAGE_DELETE_TYPE } from './message/PUBLIC_MESSAGE_DELETE.js';
21
- import { READY_TYPE } from './message/READY.js';
22
- import { ERROR_TYPE } from './message/ERROR.js';
1
+ import { C2C_MESSAGE_CREATE_TYPE } from './message/C2C_MESSAGE_CREATE.js'
2
+ import { GROUP_AT_MESSAGE_CREATE_TYPE } from './message/GROUP_AT_MESSAGE_CREATE.js'
3
+ import { AT_MESSAGE_CREATE_TYPE } from './message/AT_MESSAGE_CREATE.js'
4
+ import { CHANNEL_CREATE_TYPE } from './message/CHANNEL_CREATE.js'
5
+ import { CHANNEL_DELETE_TYPE } from './message/CHANNEL_DELETE.js'
6
+ import { CHANNEL_UPDATE_TYPE } from './message/CHANNEL_UPDATE.js'
7
+ import { DIRECT_MESSAGE_CREATE_TYPE } from './message/DIRECT_MESSAGE_CREATE.js'
8
+ import { DIRECT_MESSAGE_DELETE_TYPE } from './message/DIRECT_MESSAGE_DELETE.js'
9
+ import { GUILD_CREATE_TYPE } from './message/GUILD_CREATE.js'
10
+ import { GUILD_DELETE_TYPE } from './message/GUILD_DELETE.js'
11
+ import { GUILD_MEMBER_ADD_TYPE } from './message/GUILD_MEMBER_ADD.js'
12
+ import { GUILD_MEMBER_REMOVE_TYPE } from './message/GUILD_MEMBER_REMOVE.js'
13
+ import { GUILD_MEMBER_UPDATE_TYPE } from './message/GUILD_MEMBER_UPDATE.js'
14
+ import { GUILD_UPDATE_TYPE } from './message/GUILD_UPDATE.js'
15
+ import { INTERACTION_CREATE_TYPE } from './message/INTERACTION_CREATE.js'
16
+ import { MESSAGE_CREATE_TYPE } from './message/MESSAGE_CREATE.js'
17
+ import { MESSAGE_DELETE_TYPE } from './message/MESSAGE_DELETE.js'
18
+ import { MESSAGE_REACTION_ADD_TYPE } from './message/MESSAGE_REACTION_ADD.js'
19
+ import { MESSAGE_REACTION_REMOVE_TYPE } from './message/MESSAGE_REACTION_REMOVE.js'
20
+ import { PUBLIC_MESSAGE_DELETE_TYPE } from './message/PUBLIC_MESSAGE_DELETE.js'
21
+ import { READY_TYPE } from './message/READY.js'
22
+ import { ERROR_TYPE } from './message/ERROR.js'
23
23
 
24
24
  type QQBotEventMap = {
25
- AT_MESSAGE_CREATE: AT_MESSAGE_CREATE_TYPE;
26
- CHANNEL_CREATE: CHANNEL_CREATE_TYPE;
27
- CHANNEL_DELETE: CHANNEL_DELETE_TYPE;
28
- CHANNEL_UPDATE: CHANNEL_UPDATE_TYPE;
29
- DIRECT_MESSAGE_CREATE: DIRECT_MESSAGE_CREATE_TYPE;
30
- DIRECT_MESSAGE_DELETE: DIRECT_MESSAGE_DELETE_TYPE;
31
- GUILD_CREATE: GUILD_CREATE_TYPE;
32
- GUILD_DELETE: GUILD_DELETE_TYPE;
33
- GUILD_MEMBER_ADD: GUILD_MEMBER_ADD_TYPE;
34
- GUILD_MEMBER_REMOVE: GUILD_MEMBER_REMOVE_TYPE;
35
- GUILD_MEMBER_UPDATE: GUILD_MEMBER_UPDATE_TYPE;
36
- GUILD_UPDATE: GUILD_UPDATE_TYPE;
37
- INTERACTION_CREATE: INTERACTION_CREATE_TYPE;
38
- MESSAGE_CREATE: MESSAGE_CREATE_TYPE;
39
- MESSAGE_DELETE: MESSAGE_DELETE_TYPE;
40
- MESSAGE_REACTION_ADD: MESSAGE_REACTION_ADD_TYPE;
41
- MESSAGE_REACTION_REMOVE: MESSAGE_REACTION_REMOVE_TYPE;
42
- PUBLIC_MESSAGE_DELETE: PUBLIC_MESSAGE_DELETE_TYPE;
43
- READY: READY_TYPE;
44
- C2C_MESSAGE_CREATE: C2C_MESSAGE_CREATE_TYPE;
45
- GROUP_AT_MESSAGE_CREATE: GROUP_AT_MESSAGE_CREATE_TYPE;
46
- ERROR: ERROR_TYPE;
47
- };
25
+ AT_MESSAGE_CREATE: AT_MESSAGE_CREATE_TYPE
26
+ CHANNEL_CREATE: CHANNEL_CREATE_TYPE
27
+ CHANNEL_DELETE: CHANNEL_DELETE_TYPE
28
+ CHANNEL_UPDATE: CHANNEL_UPDATE_TYPE
29
+ DIRECT_MESSAGE_CREATE: DIRECT_MESSAGE_CREATE_TYPE
30
+ DIRECT_MESSAGE_DELETE: DIRECT_MESSAGE_DELETE_TYPE
31
+ GUILD_CREATE: GUILD_CREATE_TYPE
32
+ GUILD_DELETE: GUILD_DELETE_TYPE
33
+ GUILD_MEMBER_ADD: GUILD_MEMBER_ADD_TYPE
34
+ GUILD_MEMBER_REMOVE: GUILD_MEMBER_REMOVE_TYPE
35
+ GUILD_MEMBER_UPDATE: GUILD_MEMBER_UPDATE_TYPE
36
+ GUILD_UPDATE: GUILD_UPDATE_TYPE
37
+ INTERACTION_CREATE: INTERACTION_CREATE_TYPE
38
+ MESSAGE_CREATE: MESSAGE_CREATE_TYPE
39
+ MESSAGE_DELETE: MESSAGE_DELETE_TYPE
40
+ MESSAGE_REACTION_ADD: MESSAGE_REACTION_ADD_TYPE
41
+ MESSAGE_REACTION_REMOVE: MESSAGE_REACTION_REMOVE_TYPE
42
+ PUBLIC_MESSAGE_DELETE: PUBLIC_MESSAGE_DELETE_TYPE
43
+ READY: READY_TYPE
44
+ C2C_MESSAGE_CREATE: C2C_MESSAGE_CREATE_TYPE
45
+ GROUP_AT_MESSAGE_CREATE: GROUP_AT_MESSAGE_CREATE_TYPE
46
+ ERROR: ERROR_TYPE
47
+ }
48
48
 
49
- export type { QQBotEventMap };
49
+ export type { QQBotEventMap }
package/lib/send/index.js CHANGED
@@ -1,101 +1,111 @@
1
1
  const GROUP_AT_MESSAGE_CREATE = (client, event, val) => {
2
- const content = val
3
- .filter(item => item.type == 'Link' || item.type == 'Mention' || item.type == 'Text')
4
- .map(item => {
5
- if (item.type == 'Link') {
6
- return `[${item.options?.title ?? item.value}](${item.value})`;
2
+ const content = val
3
+ .filter(item => item.type == 'Link' || item.type == 'Mention' || item.type == 'Text')
4
+ .map(item => {
5
+ if (item.type == 'Link') {
6
+ return `[${item.options?.title ?? item.value}](${item.value})`
7
+ } else if (item.type == 'Mention') {
8
+ if (
9
+ item.value == 'everyone' ||
10
+ item.value == 'all' ||
11
+ item.value == '' ||
12
+ typeof item.value != 'string'
13
+ ) {
14
+ return ``
7
15
  }
8
- else if (item.type == 'Mention') {
9
- if (item.value == 'everyone' ||
10
- item.value == 'all' ||
11
- item.value == '' ||
12
- typeof item.value != 'string') {
13
- return ``;
14
- }
15
- if (item.options?.belong == 'user') {
16
- return `<@${item.value}>`;
17
- }
18
- return '';
19
- }
20
- else if (item.type == 'Text') {
21
- return item.value;
16
+ if (item.options?.belong == 'user') {
17
+ return `<@${item.value}>`
22
18
  }
19
+ return ''
20
+ } else if (item.type == 'Text') {
21
+ return item.value
22
+ }
23
23
  })
24
- .join('');
25
- if (content) {
26
- return Promise.all([content].map(item => client.groupOpenMessages(event.GuildId, {
27
- content: item,
28
- msg_id: event.MessageId,
29
- msg_type: 0,
30
- msg_seq: client.getMessageSeq(event.MessageId)
31
- })));
32
- }
33
- const images = val.filter(item => item.type == 'Image').map(item => item.value);
34
- if (images) {
35
- return Promise.all(images.map(async (msg) => {
36
- const file_info = await client
37
- .postRichMediaByGroup(event.GuildId, {
38
- file_type: 1,
39
- file_data: msg.toString('base64')
40
- })
41
- .then(res => res?.file_info);
42
- if (!file_info)
43
- return Promise.resolve(null);
44
- return client.groupOpenMessages(event.GuildId, {
45
- content: '',
46
- media: {
47
- file_info
48
- },
49
- msg_id: event.MessageId,
50
- msg_type: 7,
51
- msg_seq: client.getMessageSeq(event.MessageId)
52
- });
53
- }));
54
- }
55
- return [];
56
- };
24
+ .join('')
25
+ if (content) {
26
+ return Promise.all(
27
+ [content].map(item =>
28
+ client.groupOpenMessages(event.GuildId, {
29
+ content: item,
30
+ msg_id: event.MessageId,
31
+ msg_type: 0,
32
+ msg_seq: client.getMessageSeq(event.MessageId)
33
+ })
34
+ )
35
+ )
36
+ }
37
+ const images = val.filter(item => item.type == 'Image').map(item => item.value)
38
+ if (images) {
39
+ return Promise.all(
40
+ images.map(async msg => {
41
+ const file_info = await client
42
+ .postRichMediaByGroup(event.GuildId, {
43
+ file_type: 1,
44
+ file_data: msg.toString('base64')
45
+ })
46
+ .then(res => res?.file_info)
47
+ if (!file_info) return Promise.resolve(null)
48
+ return client.groupOpenMessages(event.GuildId, {
49
+ content: '',
50
+ media: {
51
+ file_info
52
+ },
53
+ msg_id: event.MessageId,
54
+ msg_type: 7,
55
+ msg_seq: client.getMessageSeq(event.MessageId)
56
+ })
57
+ })
58
+ )
59
+ }
60
+ return []
61
+ }
57
62
  const C2C_MESSAGE_CREATE = (client, event, val) => {
58
- const content = val
59
- .filter(item => item.type == 'Link' || item.type == 'Mention' || item.type == 'Text')
60
- .map(item => {
61
- if (item.type == 'Text') {
62
- return item.value;
63
- }
64
- return '';
63
+ const content = val
64
+ .filter(item => item.type == 'Link' || item.type == 'Mention' || item.type == 'Text')
65
+ .map(item => {
66
+ if (item.type == 'Text') {
67
+ return item.value
68
+ }
69
+ return ''
65
70
  })
66
- .join('');
67
- if (content) {
68
- return Promise.all([content].map(item => client.usersOpenMessages(event.OpenId, {
69
- content: item,
70
- msg_id: event.MessageId,
71
- msg_type: 0,
72
- msg_seq: client.getMessageSeq(event.MessageId)
73
- })));
74
- }
75
- const images = val.filter(item => item.type == 'Image').map(item => item.value);
76
- if (images) {
77
- return Promise.all(images.map(async (msg) => {
78
- const file_info = await client
79
- .postRichMediaByUsers(event.OpenId, {
80
- file_type: 1,
81
- file_data: msg.toString('base64')
82
- })
83
- .then(res => res?.file_info);
84
- if (!file_info)
85
- return Promise.resolve(null);
86
- return client.usersOpenMessages(event.OpenId, {
87
- content: '',
88
- media: {
89
- file_info
90
- },
91
- msg_id: event.MessageId,
92
- msg_type: 7,
93
- msg_seq: client.getMessageSeq(event.MessageId)
94
- });
95
- }));
96
- }
97
- return [];
98
- };
71
+ .join('')
72
+ if (content) {
73
+ return Promise.all(
74
+ [content].map(item =>
75
+ client.usersOpenMessages(event.OpenId, {
76
+ content: item,
77
+ msg_id: event.MessageId,
78
+ msg_type: 0,
79
+ msg_seq: client.getMessageSeq(event.MessageId)
80
+ })
81
+ )
82
+ )
83
+ }
84
+ const images = val.filter(item => item.type == 'Image').map(item => item.value)
85
+ if (images) {
86
+ return Promise.all(
87
+ images.map(async msg => {
88
+ const file_info = await client
89
+ .postRichMediaByUsers(event.OpenId, {
90
+ file_type: 1,
91
+ file_data: msg.toString('base64')
92
+ })
93
+ .then(res => res?.file_info)
94
+ if (!file_info) return Promise.resolve(null)
95
+ return client.usersOpenMessages(event.OpenId, {
96
+ content: '',
97
+ media: {
98
+ file_info
99
+ },
100
+ msg_id: event.MessageId,
101
+ msg_type: 7,
102
+ msg_seq: client.getMessageSeq(event.MessageId)
103
+ })
104
+ })
105
+ )
106
+ }
107
+ return []
108
+ }
99
109
  /**
100
110
  * 频道私聊
101
111
  * @param client
@@ -104,72 +114,87 @@ const C2C_MESSAGE_CREATE = (client, event, val) => {
104
114
  * @returns
105
115
  */
106
116
  const DIRECT_MESSAGE_CREATE = (client, event, val) => {
107
- const content = val
108
- .filter(item => item.type == 'Link' || item.type == 'Mention' || item.type == 'Text')
109
- .map(item => {
110
- if (item.type == 'Text') {
111
- return item.value;
112
- }
113
- return '';
117
+ const content = val
118
+ .filter(item => item.type == 'Link' || item.type == 'Mention' || item.type == 'Text')
119
+ .map(item => {
120
+ if (item.type == 'Text') {
121
+ return item.value
122
+ }
123
+ return ''
114
124
  })
115
- .join('');
116
- if (content) {
117
- return Promise.all([content].map(item => client.dmsMessage(event.OpenId, {
118
- content: item,
119
- msg_id: event.MessageId
120
- })));
121
- }
122
- const images = val.filter(item => item.type == 'Image').map(item => item.value);
123
- if (images) {
124
- return Promise.all(images.map(item => client.postDirectImage(event.OpenId, {
125
- msg_id: event.MessageId,
126
- image: item
127
- })));
128
- }
129
- return [];
130
- };
125
+ .join('')
126
+ if (content) {
127
+ return Promise.all(
128
+ [content].map(item =>
129
+ client.dmsMessage(event.OpenId, {
130
+ content: item,
131
+ msg_id: event.MessageId
132
+ })
133
+ )
134
+ )
135
+ }
136
+ const images = val.filter(item => item.type == 'Image').map(item => item.value)
137
+ if (images) {
138
+ return Promise.all(
139
+ images.map(item =>
140
+ client.postDirectImage(event.OpenId, {
141
+ msg_id: event.MessageId,
142
+ image: item
143
+ })
144
+ )
145
+ )
146
+ }
147
+ return []
148
+ }
131
149
  const AT_MESSAGE_CREATE = (client, event, val) => {
132
- const content = val
133
- .filter(item => item.type == 'Link' || item.type == 'Mention' || item.type == 'Text')
134
- .map(item => {
135
- if (item.type == 'Link') {
136
- return `[${item.options?.title ?? item.value}](${item.value})`;
150
+ const content = val
151
+ .filter(item => item.type == 'Link' || item.type == 'Mention' || item.type == 'Text')
152
+ .map(item => {
153
+ if (item.type == 'Link') {
154
+ return `[${item.options?.title ?? item.value}](${item.value})`
155
+ } else if (item.type == 'Mention') {
156
+ if (
157
+ item.value == 'everyone' ||
158
+ item.value == 'all' ||
159
+ item.value == '' ||
160
+ typeof item.value != 'string'
161
+ ) {
162
+ return `@everyone`
137
163
  }
138
- else if (item.type == 'Mention') {
139
- if (item.value == 'everyone' ||
140
- item.value == 'all' ||
141
- item.value == '' ||
142
- typeof item.value != 'string') {
143
- return `@everyone`;
144
- }
145
- if (item.options?.belong == 'user') {
146
- return `<@!${item.value}>`;
147
- }
148
- else if (item.options?.belong == 'channel') {
149
- return `<#${item.value}>`;
150
- }
151
- return '';
152
- }
153
- else if (item.type == 'Text') {
154
- return item.value;
164
+ if (item.options?.belong == 'user') {
165
+ return `<@!${item.value}>`
166
+ } else if (item.options?.belong == 'channel') {
167
+ return `<#${item.value}>`
155
168
  }
169
+ return ''
170
+ } else if (item.type == 'Text') {
171
+ return item.value
172
+ }
156
173
  })
157
- .join('');
158
- if (content) {
159
- return Promise.all([content].map(item => client.channelsMessagesPost(event.ChannelId, {
160
- content: item,
161
- msg_id: event.MessageId
162
- })));
163
- }
164
- const images = val.filter(item => item.type == 'Image').map(item => item.value);
165
- if (images) {
166
- return Promise.all(images.map(item => client.postImage(event.ChannelId, {
167
- msg_id: event.MessageId,
168
- image: item
169
- })));
170
- }
171
- return [];
172
- };
174
+ .join('')
175
+ if (content) {
176
+ return Promise.all(
177
+ [content].map(item =>
178
+ client.channelsMessagesPost(event.ChannelId, {
179
+ content: item,
180
+ msg_id: event.MessageId
181
+ })
182
+ )
183
+ )
184
+ }
185
+ const images = val.filter(item => item.type == 'Image').map(item => item.value)
186
+ if (images) {
187
+ return Promise.all(
188
+ images.map(item =>
189
+ client.postImage(event.ChannelId, {
190
+ msg_id: event.MessageId,
191
+ image: item
192
+ })
193
+ )
194
+ )
195
+ }
196
+ return []
197
+ }
173
198
  /**
174
199
  *
175
200
  * @param event
@@ -177,46 +202,59 @@ const AT_MESSAGE_CREATE = (client, event, val) => {
177
202
  * @returns
178
203
  */
179
204
  const MESSAGE_CREATE = (client, event, val) => {
180
- const content = val
181
- .filter(item => item.type == 'Link' || item.type == 'Mention' || item.type == 'Text')
182
- .map(item => {
183
- if (item.type == 'Link') {
184
- return `[${item.options?.title ?? item.value}](${item.value})`;
185
- }
186
- else if (item.type == 'Mention') {
187
- if (item.value == 'everyone' ||
188
- item.value == 'all' ||
189
- item.value == '' ||
190
- typeof item.value != 'string') {
191
- return `@everyone`;
192
- }
193
- if (item.options?.belong == 'user') {
194
- return `<@!${item.value}>`;
195
- }
196
- else if (item.options?.belong == 'channel') {
197
- return `<#${item.value}>`;
198
- }
199
- return '';
205
+ const content = val
206
+ .filter(item => item.type == 'Link' || item.type == 'Mention' || item.type == 'Text')
207
+ .map(item => {
208
+ if (item.type == 'Link') {
209
+ return `[${item.options?.title ?? item.value}](${item.value})`
210
+ } else if (item.type == 'Mention') {
211
+ if (
212
+ item.value == 'everyone' ||
213
+ item.value == 'all' ||
214
+ item.value == '' ||
215
+ typeof item.value != 'string'
216
+ ) {
217
+ return `@everyone`
200
218
  }
201
- else if (item.type == 'Text') {
202
- return item.value;
219
+ if (item.options?.belong == 'user') {
220
+ return `<@!${item.value}>`
221
+ } else if (item.options?.belong == 'channel') {
222
+ return `<#${item.value}>`
203
223
  }
224
+ return ''
225
+ } else if (item.type == 'Text') {
226
+ return item.value
227
+ }
204
228
  })
205
- .join('');
206
- if (content) {
207
- return Promise.all([content].map(item => client.channelsMessagesPost(event.ChannelId, {
208
- content: item,
209
- msg_id: event.MessageId
210
- })));
211
- }
212
- const images = val.filter(item => item.type == 'Image').map(item => item.value);
213
- if (images) {
214
- return Promise.all(images.map(item => client.postImage(event.ChannelId, {
215
- msg_id: event.MessageId,
216
- image: item
217
- })));
218
- }
219
- return [];
220
- };
229
+ .join('')
230
+ if (content) {
231
+ return Promise.all(
232
+ [content].map(item =>
233
+ client.channelsMessagesPost(event.ChannelId, {
234
+ content: item,
235
+ msg_id: event.MessageId
236
+ })
237
+ )
238
+ )
239
+ }
240
+ const images = val.filter(item => item.type == 'Image').map(item => item.value)
241
+ if (images) {
242
+ return Promise.all(
243
+ images.map(item =>
244
+ client.postImage(event.ChannelId, {
245
+ msg_id: event.MessageId,
246
+ image: item
247
+ })
248
+ )
249
+ )
250
+ }
251
+ return []
252
+ }
221
253
 
222
- export { AT_MESSAGE_CREATE, C2C_MESSAGE_CREATE, DIRECT_MESSAGE_CREATE, GROUP_AT_MESSAGE_CREATE, MESSAGE_CREATE };
254
+ export {
255
+ AT_MESSAGE_CREATE,
256
+ C2C_MESSAGE_CREATE,
257
+ DIRECT_MESSAGE_CREATE,
258
+ GROUP_AT_MESSAGE_CREATE,
259
+ MESSAGE_CREATE
260
+ }