@alemonjs/qq-bot 2.1.0-alpha.0 → 2.1.0-alpha.2
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/lib/register.js +5 -22
- package/lib/sends.js +2 -2
- package/package.json +1 -1
package/lib/register.js
CHANGED
|
@@ -26,27 +26,11 @@ const register = (client) => {
|
|
|
26
26
|
const createUserAvatarURL = (author_id) => {
|
|
27
27
|
return `https://q.qlogo.cn/qqapp/${config.app_id}/${author_id}/640`;
|
|
28
28
|
};
|
|
29
|
-
const createUserAvatar = (url) => {
|
|
30
|
-
return {
|
|
31
|
-
toBuffer: async () => {
|
|
32
|
-
const arrayBuffer = await fetch(url).then(res => res.arrayBuffer());
|
|
33
|
-
return Buffer.from(arrayBuffer);
|
|
34
|
-
},
|
|
35
|
-
toBase64: async () => {
|
|
36
|
-
const arrayBuffer = await fetch(url).then(res => res.arrayBuffer());
|
|
37
|
-
return Buffer.from(arrayBuffer).toString('base64');
|
|
38
|
-
},
|
|
39
|
-
toURL: async () => {
|
|
40
|
-
return url;
|
|
41
|
-
}
|
|
42
|
-
};
|
|
43
|
-
};
|
|
44
29
|
// 监听消息
|
|
45
30
|
client.on('GROUP_AT_MESSAGE_CREATE', async (event) => {
|
|
46
31
|
const master_key = config?.master_key ?? [];
|
|
47
32
|
const isMaster = master_key.includes(event.author.id);
|
|
48
|
-
const
|
|
49
|
-
const UserAvatar = createUserAvatar(url);
|
|
33
|
+
const UserAvatar = createUserAvatarURL(event.author.id);
|
|
50
34
|
const UserId = event.author.id;
|
|
51
35
|
const UserKey = useUserHashKey({
|
|
52
36
|
Platform: platform,
|
|
@@ -79,8 +63,7 @@ const register = (client) => {
|
|
|
79
63
|
client.on('C2C_MESSAGE_CREATE', async (event) => {
|
|
80
64
|
const master_key = config?.master_key ?? [];
|
|
81
65
|
const isMaster = master_key.includes(event.author.id);
|
|
82
|
-
const
|
|
83
|
-
const UserAvatar = createUserAvatar(url);
|
|
66
|
+
const UserAvatar = createUserAvatarURL(event.author.id);
|
|
84
67
|
const UserId = event.author.id;
|
|
85
68
|
const UserKey = useUserHashKey({
|
|
86
69
|
Platform: platform,
|
|
@@ -118,7 +101,7 @@ const register = (client) => {
|
|
|
118
101
|
const master_key = config?.master_key ?? [];
|
|
119
102
|
const isMaster = master_key.includes(event.author.id);
|
|
120
103
|
let msg = event?.content ?? '';
|
|
121
|
-
const UserAvatar =
|
|
104
|
+
const UserAvatar = event?.author?.avatar;
|
|
122
105
|
const UserId = event.author.id;
|
|
123
106
|
const UserKey = useUserHashKey({
|
|
124
107
|
Platform: platform,
|
|
@@ -158,7 +141,7 @@ const register = (client) => {
|
|
|
158
141
|
const master_key = config?.master_key ?? [];
|
|
159
142
|
const isMaster = master_key.includes(event.author.id);
|
|
160
143
|
let msg = getMessageContent(event);
|
|
161
|
-
const UserAvatar =
|
|
144
|
+
const UserAvatar = event?.author?.avatar;
|
|
162
145
|
const UserId = event.author.id;
|
|
163
146
|
const UserKey = useUserHashKey({
|
|
164
147
|
Platform: platform,
|
|
@@ -224,7 +207,7 @@ const register = (client) => {
|
|
|
224
207
|
const UserId = event.author.id;
|
|
225
208
|
const isMaster = master_key.includes(UserId);
|
|
226
209
|
const msg = getMessageContent(event);
|
|
227
|
-
const UserAvatar =
|
|
210
|
+
const UserAvatar = event?.author?.avatar;
|
|
228
211
|
const UserKey = useUserHashKey({
|
|
229
212
|
Platform: platform,
|
|
230
213
|
UserId: UserId
|
package/lib/sends.js
CHANGED
|
@@ -214,7 +214,7 @@ const GROUP_AT_MESSAGE_CREATE = async (client, event, val) => {
|
|
|
214
214
|
try {
|
|
215
215
|
const file_data = item.type == 'ImageFile'
|
|
216
216
|
? readFileSync(item.value, 'base64')
|
|
217
|
-
: item.value
|
|
217
|
+
: item.value;
|
|
218
218
|
const file_info = await client
|
|
219
219
|
.postRichMediaByGroup(event.GuildId, {
|
|
220
220
|
file_type: 1,
|
|
@@ -376,7 +376,7 @@ const C2C_MESSAGE_CREATE = (client, event, val) => {
|
|
|
376
376
|
}
|
|
377
377
|
const file_data = item.type == 'ImageFile'
|
|
378
378
|
? readFileSync(item.value, 'base64')
|
|
379
|
-
: item.value
|
|
379
|
+
: item.value;
|
|
380
380
|
const file_info = await client
|
|
381
381
|
.postRichMediaByUsers(event.OpenId, {
|
|
382
382
|
file_type: 1,
|