@alemonjs/qq-bot 0.0.10 → 0.0.11
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.
- package/README.md +0 -6
- package/dist/assets/index.css +1 -476
- package/dist/assets/index.js +14 -10997
- package/dist/index.html +1 -1
- package/lib/api.d.ts +843 -971
- package/lib/api.js +1156 -1172
- package/lib/client.d.ts +22 -22
- package/lib/client.js +217 -201
- package/lib/config.js +2 -2
- package/lib/desktop.d.ts +2 -2
- package/lib/desktop.js +59 -60
- package/lib/from.js +34 -27
- package/lib/index.d.ts +7 -7
- package/lib/index.js +405 -406
- package/lib/message/AT_MESSAGE_CREATE.d.ts +35 -35
- package/lib/message/C2C_MESSAGE_CREATE.d.ts +9 -9
- package/lib/message/CHANNEL_CREATE.d.ts +15 -15
- package/lib/message/CHANNEL_DELETE.d.ts +15 -15
- package/lib/message/CHANNEL_UPDATE.d.ts +15 -15
- package/lib/message/DIRECT_MESSAGE_CREATE.d.ts +29 -29
- package/lib/message/DIRECT_MESSAGE_DELETE.d.ts +17 -17
- package/lib/message/ERROR.d.ts +2 -2
- package/lib/message/GROUP_AT_MESSAGE_CREATE.d.ts +10 -10
- package/lib/message/GUILD_CREATE.d.ts +15 -15
- package/lib/message/GUILD_DELETE.d.ts +15 -15
- package/lib/message/GUILD_MEMBER_ADD.d.ts +14 -14
- package/lib/message/GUILD_MEMBER_REMOVE.d.ts +14 -14
- package/lib/message/GUILD_MEMBER_UPDATE.d.ts +14 -14
- package/lib/message/GUILD_UPDATE.d.ts +15 -15
- package/lib/message/INTERACTION_CREATE.d.ts +2 -2
- package/lib/message/MESSAGE_CREATE.d.ts +2 -2
- package/lib/message/MESSAGE_DELETE.d.ts +2 -2
- package/lib/message/MESSAGE_REACTION_ADD.d.ts +13 -13
- package/lib/message/MESSAGE_REACTION_REMOVE.d.ts +13 -13
- package/lib/message/PUBLIC_MESSAGE_DELETE.d.ts +15 -15
- package/lib/message/READY.d.ts +6 -6
- package/lib/message.d.ts +46 -46
- package/lib/send/index.js +192 -230
- package/lib/typing.d.ts +54 -62
- package/lib/webhook.js +48 -46
- package/package.json +2 -2
|
@@ -3,19 +3,19 @@
|
|
|
3
3
|
* @param event
|
|
4
4
|
*/
|
|
5
5
|
type PUBLIC_MESSAGE_DELETE_TYPE = {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
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 };
|
package/lib/message/READY.d.ts
CHANGED
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
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
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,111 +1,101 @@
|
|
|
1
1
|
const GROUP_AT_MESSAGE_CREATE = (client, event, val) => {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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 ``
|
|
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})`;
|
|
15
7
|
}
|
|
16
|
-
if (item.
|
|
17
|
-
|
|
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;
|
|
18
22
|
}
|
|
19
|
-
return ''
|
|
20
|
-
} else if (item.type == 'Text') {
|
|
21
|
-
return item.value
|
|
22
|
-
}
|
|
23
23
|
})
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
})
|
|
58
|
-
)
|
|
59
|
-
}
|
|
60
|
-
return []
|
|
61
|
-
}
|
|
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
|
+
};
|
|
62
57
|
const C2C_MESSAGE_CREATE = (client, event, val) => {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
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 '';
|
|
70
65
|
})
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
})
|
|
105
|
-
)
|
|
106
|
-
}
|
|
107
|
-
return []
|
|
108
|
-
}
|
|
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
|
+
};
|
|
109
99
|
/**
|
|
110
100
|
* 频道私聊
|
|
111
101
|
* @param client
|
|
@@ -114,87 +104,72 @@ const C2C_MESSAGE_CREATE = (client, event, val) => {
|
|
|
114
104
|
* @returns
|
|
115
105
|
*/
|
|
116
106
|
const DIRECT_MESSAGE_CREATE = (client, event, val) => {
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
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 '';
|
|
124
114
|
})
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
msg_id: event.MessageId,
|
|
142
|
-
image: item
|
|
143
|
-
})
|
|
144
|
-
)
|
|
145
|
-
)
|
|
146
|
-
}
|
|
147
|
-
return []
|
|
148
|
-
}
|
|
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
|
+
};
|
|
149
131
|
const AT_MESSAGE_CREATE = (client, event, val) => {
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
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`
|
|
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})`;
|
|
163
137
|
}
|
|
164
|
-
if (item.
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
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;
|
|
168
155
|
}
|
|
169
|
-
return ''
|
|
170
|
-
} else if (item.type == 'Text') {
|
|
171
|
-
return item.value
|
|
172
|
-
}
|
|
173
156
|
})
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
msg_id: event.MessageId,
|
|
191
|
-
image: item
|
|
192
|
-
})
|
|
193
|
-
)
|
|
194
|
-
)
|
|
195
|
-
}
|
|
196
|
-
return []
|
|
197
|
-
}
|
|
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
|
+
};
|
|
198
173
|
/**
|
|
199
174
|
*
|
|
200
175
|
* @param event
|
|
@@ -202,59 +177,46 @@ const AT_MESSAGE_CREATE = (client, event, val) => {
|
|
|
202
177
|
* @returns
|
|
203
178
|
*/
|
|
204
179
|
const MESSAGE_CREATE = (client, event, val) => {
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
if (
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
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 '';
|
|
218
200
|
}
|
|
219
|
-
if (item.
|
|
220
|
-
|
|
221
|
-
} else if (item.options?.belong == 'channel') {
|
|
222
|
-
return `<#${item.value}>`
|
|
201
|
+
else if (item.type == 'Text') {
|
|
202
|
+
return item.value;
|
|
223
203
|
}
|
|
224
|
-
return ''
|
|
225
|
-
} else if (item.type == 'Text') {
|
|
226
|
-
return item.value
|
|
227
|
-
}
|
|
228
204
|
})
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
msg_id: event.MessageId,
|
|
246
|
-
image: item
|
|
247
|
-
})
|
|
248
|
-
)
|
|
249
|
-
)
|
|
250
|
-
}
|
|
251
|
-
return []
|
|
252
|
-
}
|
|
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
|
+
};
|
|
253
221
|
|
|
254
|
-
export {
|
|
255
|
-
AT_MESSAGE_CREATE,
|
|
256
|
-
C2C_MESSAGE_CREATE,
|
|
257
|
-
DIRECT_MESSAGE_CREATE,
|
|
258
|
-
GROUP_AT_MESSAGE_CREATE,
|
|
259
|
-
MESSAGE_CREATE
|
|
260
|
-
}
|
|
222
|
+
export { AT_MESSAGE_CREATE, C2C_MESSAGE_CREATE, DIRECT_MESSAGE_CREATE, GROUP_AT_MESSAGE_CREATE, MESSAGE_CREATE };
|