@alemonjs/qq-bot 0.0.22 → 0.0.23
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/index.d.ts +2 -1
- package/lib/register.js +5 -27
- package/lib/sends.js +43 -15
- package/package.json +1 -1
- package/dist/assets/index.css +0 -1255
- package/dist/assets/index.js +0 -11257
- package/dist/index.html +0 -15
- package/lib/send/index.js +0 -453
package/dist/index.html
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html lang="en" id="__gui">
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="UTF-8" />
|
|
5
|
-
<link rel="icon" type="image/svg+xml" href="/favicon.ico" />
|
|
6
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
7
|
-
<title>AlemonJS</title>
|
|
8
|
-
<script type="module" crossorigin src="/assets/index.js"></script>
|
|
9
|
-
<link rel="stylesheet" crossorigin href="/assets/index.css" />
|
|
10
|
-
</head>
|
|
11
|
-
|
|
12
|
-
<body>
|
|
13
|
-
<div id="root"></div>
|
|
14
|
-
</body>
|
|
15
|
-
</html>
|
package/lib/send/index.js
DELETED
|
@@ -1,453 +0,0 @@
|
|
|
1
|
-
import { readFileSync } from 'fs'
|
|
2
|
-
import axios from 'axios'
|
|
3
|
-
|
|
4
|
-
const createButtonsData = rows => {
|
|
5
|
-
let id = 0
|
|
6
|
-
const data = {
|
|
7
|
-
rows: rows.map(row => {
|
|
8
|
-
const val = row.value
|
|
9
|
-
return {
|
|
10
|
-
buttons: val.map(button => {
|
|
11
|
-
const value = button.value
|
|
12
|
-
const options = button.options
|
|
13
|
-
id++
|
|
14
|
-
return {
|
|
15
|
-
id: String(id),
|
|
16
|
-
render_data: {
|
|
17
|
-
label: typeof value == 'object' ? value.title : value,
|
|
18
|
-
visited_label: typeof value == 'object' ? value.label : value,
|
|
19
|
-
// tudo
|
|
20
|
-
style: 0
|
|
21
|
-
},
|
|
22
|
-
action: {
|
|
23
|
-
// 0 link 1 callback , 2 command
|
|
24
|
-
type: typeof options.data === 'object' ? 1 : options?.isLink ? 0 : 2,
|
|
25
|
-
permission: {
|
|
26
|
-
// 所有人
|
|
27
|
-
type: 2
|
|
28
|
-
// "specify_role_ids": ["1", "2", "3"]
|
|
29
|
-
},
|
|
30
|
-
// "click_limit": 10,
|
|
31
|
-
unsupport_tips: options?.toolTip ?? '',
|
|
32
|
-
data: options?.data ?? '',
|
|
33
|
-
// reply: true,
|
|
34
|
-
at_bot_show_channel_list: options.showList ?? false,
|
|
35
|
-
enter: options?.autoEnter ?? false
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
})
|
|
39
|
-
}
|
|
40
|
-
})
|
|
41
|
-
}
|
|
42
|
-
return data
|
|
43
|
-
}
|
|
44
|
-
const GROUP_AT_MESSAGE_CREATE = (client, event, val) => {
|
|
45
|
-
const content = val
|
|
46
|
-
.filter(item => item.type == 'Mention' || item.type == 'Text')
|
|
47
|
-
.map(item => {
|
|
48
|
-
// if (item.type == 'Link') {
|
|
49
|
-
// return `[${item.options?.title ?? item.value}](${item.value})`
|
|
50
|
-
// } else
|
|
51
|
-
if (item.type == 'Mention') {
|
|
52
|
-
if (
|
|
53
|
-
item.value == 'everyone' ||
|
|
54
|
-
item.value == 'all' ||
|
|
55
|
-
item.value == '' ||
|
|
56
|
-
typeof item.value != 'string'
|
|
57
|
-
) {
|
|
58
|
-
return ``
|
|
59
|
-
}
|
|
60
|
-
if (item.options?.belong == 'user') {
|
|
61
|
-
return `<@${item.value}>`
|
|
62
|
-
}
|
|
63
|
-
return ''
|
|
64
|
-
} else if (item.type == 'Text') {
|
|
65
|
-
return item.value
|
|
66
|
-
}
|
|
67
|
-
})
|
|
68
|
-
.join('')
|
|
69
|
-
if (content) {
|
|
70
|
-
return Promise.all(
|
|
71
|
-
[content].map(item =>
|
|
72
|
-
client.groupOpenMessages(event.GuildId, {
|
|
73
|
-
content: item,
|
|
74
|
-
msg_id: event.MessageId,
|
|
75
|
-
msg_type: 0,
|
|
76
|
-
msg_seq: client.getMessageSeq(event.MessageId)
|
|
77
|
-
})
|
|
78
|
-
)
|
|
79
|
-
)
|
|
80
|
-
}
|
|
81
|
-
const images = val.filter(
|
|
82
|
-
item => item.type == 'Image' || item.type == 'ImageFile' || item.type == 'ImageURL'
|
|
83
|
-
)
|
|
84
|
-
if (images && images.length > 0) {
|
|
85
|
-
return Promise.all(
|
|
86
|
-
images.map(async item => {
|
|
87
|
-
if (item.type == 'ImageURL') {
|
|
88
|
-
return client.groupOpenMessages(event.GuildId, {
|
|
89
|
-
content: '',
|
|
90
|
-
media: {
|
|
91
|
-
file_info: item.value
|
|
92
|
-
},
|
|
93
|
-
msg_id: event.MessageId,
|
|
94
|
-
msg_type: 7,
|
|
95
|
-
msg_seq: client.getMessageSeq(event.MessageId)
|
|
96
|
-
})
|
|
97
|
-
}
|
|
98
|
-
const file_data =
|
|
99
|
-
item.type == 'ImageFile'
|
|
100
|
-
? readFileSync(item.value, 'base64')
|
|
101
|
-
: item.value.toString('base64')
|
|
102
|
-
const file_info = await client
|
|
103
|
-
.postRichMediaByGroup(event.GuildId, {
|
|
104
|
-
file_type: 1,
|
|
105
|
-
file_data: file_data
|
|
106
|
-
})
|
|
107
|
-
.then(res => res?.file_info)
|
|
108
|
-
if (!file_info) return Promise.resolve(null)
|
|
109
|
-
return client.groupOpenMessages(event.GuildId, {
|
|
110
|
-
content: '',
|
|
111
|
-
media: {
|
|
112
|
-
file_info
|
|
113
|
-
},
|
|
114
|
-
msg_id: event.MessageId,
|
|
115
|
-
msg_type: 7,
|
|
116
|
-
msg_seq: client.getMessageSeq(event.MessageId)
|
|
117
|
-
})
|
|
118
|
-
})
|
|
119
|
-
)
|
|
120
|
-
}
|
|
121
|
-
// buttons
|
|
122
|
-
const buttons = val.filter(item => item.type == 'BT.group')
|
|
123
|
-
if (buttons && buttons.length > 0) {
|
|
124
|
-
return Promise.all(
|
|
125
|
-
buttons.map(async item => {
|
|
126
|
-
const template_id = item?.options?.template_id
|
|
127
|
-
if (template_id) {
|
|
128
|
-
return client.groupOpenMessages(event.GuildId, {
|
|
129
|
-
content: '',
|
|
130
|
-
msg_id: event.MessageId,
|
|
131
|
-
keyboard: {
|
|
132
|
-
id: template_id
|
|
133
|
-
},
|
|
134
|
-
msg_type: 2,
|
|
135
|
-
msg_seq: client.getMessageSeq(event.MessageId)
|
|
136
|
-
})
|
|
137
|
-
}
|
|
138
|
-
const rows = item.value
|
|
139
|
-
// 构造成按钮
|
|
140
|
-
const data = createButtonsData(rows)
|
|
141
|
-
return client.groupOpenMessages(event.GuildId, {
|
|
142
|
-
content: '',
|
|
143
|
-
msg_id: event.MessageId,
|
|
144
|
-
keyboard: {
|
|
145
|
-
content: data
|
|
146
|
-
},
|
|
147
|
-
msg_type: 2,
|
|
148
|
-
msg_seq: client.getMessageSeq(event.MessageId)
|
|
149
|
-
})
|
|
150
|
-
})
|
|
151
|
-
)
|
|
152
|
-
}
|
|
153
|
-
return Promise.all([])
|
|
154
|
-
}
|
|
155
|
-
const C2C_MESSAGE_CREATE = (client, event, val) => {
|
|
156
|
-
const content = val
|
|
157
|
-
.filter(item => item.type == 'Mention' || item.type == 'Text')
|
|
158
|
-
.map(item => {
|
|
159
|
-
if (item.type == 'Text') {
|
|
160
|
-
return item.value
|
|
161
|
-
}
|
|
162
|
-
return ''
|
|
163
|
-
})
|
|
164
|
-
.join('')
|
|
165
|
-
if (content) {
|
|
166
|
-
return Promise.all(
|
|
167
|
-
[content].map(item =>
|
|
168
|
-
client.usersOpenMessages(event.OpenId, {
|
|
169
|
-
content: item,
|
|
170
|
-
msg_id: event.MessageId,
|
|
171
|
-
msg_type: 0,
|
|
172
|
-
msg_seq: client.getMessageSeq(event.MessageId)
|
|
173
|
-
})
|
|
174
|
-
)
|
|
175
|
-
)
|
|
176
|
-
}
|
|
177
|
-
const images = val.filter(
|
|
178
|
-
item => item.type == 'Image' || item.type == 'ImageFile' || item.type == 'ImageURL'
|
|
179
|
-
)
|
|
180
|
-
if (images && images.length > 0) {
|
|
181
|
-
return Promise.all(
|
|
182
|
-
images.map(async item => {
|
|
183
|
-
if (item.type == 'ImageURL') {
|
|
184
|
-
return client.usersOpenMessages(event.OpenId, {
|
|
185
|
-
content: '',
|
|
186
|
-
media: {
|
|
187
|
-
file_info: item.value
|
|
188
|
-
},
|
|
189
|
-
msg_id: event.MessageId,
|
|
190
|
-
msg_type: 7,
|
|
191
|
-
msg_seq: client.getMessageSeq(event.MessageId)
|
|
192
|
-
})
|
|
193
|
-
}
|
|
194
|
-
const file_data =
|
|
195
|
-
item.type == 'ImageFile'
|
|
196
|
-
? readFileSync(item.value, 'base64')
|
|
197
|
-
: item.value.toString('base64')
|
|
198
|
-
const file_info = await client
|
|
199
|
-
.postRichMediaByUsers(event.OpenId, {
|
|
200
|
-
file_type: 1,
|
|
201
|
-
file_data: file_data
|
|
202
|
-
})
|
|
203
|
-
.then(res => res?.file_info)
|
|
204
|
-
if (!file_info) return Promise.resolve(null)
|
|
205
|
-
return client.usersOpenMessages(event.OpenId, {
|
|
206
|
-
content: '',
|
|
207
|
-
media: {
|
|
208
|
-
file_info
|
|
209
|
-
},
|
|
210
|
-
msg_id: event.MessageId,
|
|
211
|
-
msg_type: 7,
|
|
212
|
-
msg_seq: client.getMessageSeq(event.MessageId)
|
|
213
|
-
})
|
|
214
|
-
})
|
|
215
|
-
)
|
|
216
|
-
}
|
|
217
|
-
// buttons
|
|
218
|
-
const buttons = val.filter(item => item.type == 'BT.group')
|
|
219
|
-
if (buttons && buttons.length > 0) {
|
|
220
|
-
return Promise.all(
|
|
221
|
-
buttons.map(async item => {
|
|
222
|
-
const template_id = item?.options?.template_id
|
|
223
|
-
if (template_id) {
|
|
224
|
-
return client.groupOpenMessages(event.GuildId, {
|
|
225
|
-
content: '',
|
|
226
|
-
msg_id: event.MessageId,
|
|
227
|
-
keyboard: {
|
|
228
|
-
id: template_id
|
|
229
|
-
},
|
|
230
|
-
msg_type: 2,
|
|
231
|
-
msg_seq: client.getMessageSeq(event.MessageId)
|
|
232
|
-
})
|
|
233
|
-
}
|
|
234
|
-
const rows = item.value
|
|
235
|
-
// 看看是否是模板id的
|
|
236
|
-
rows.map(row => {
|
|
237
|
-
return row
|
|
238
|
-
})
|
|
239
|
-
// 构造成按钮
|
|
240
|
-
const data = createButtonsData(rows)
|
|
241
|
-
return client.groupOpenMessages(event.GuildId, {
|
|
242
|
-
content: '',
|
|
243
|
-
msg_id: event.MessageId,
|
|
244
|
-
keyboard: {
|
|
245
|
-
content: data
|
|
246
|
-
},
|
|
247
|
-
msg_type: 2,
|
|
248
|
-
msg_seq: client.getMessageSeq(event.MessageId)
|
|
249
|
-
})
|
|
250
|
-
})
|
|
251
|
-
)
|
|
252
|
-
}
|
|
253
|
-
return Promise.all([])
|
|
254
|
-
}
|
|
255
|
-
/**
|
|
256
|
-
* 频道私聊
|
|
257
|
-
* @param client
|
|
258
|
-
* @param event
|
|
259
|
-
* @param val
|
|
260
|
-
* @returns
|
|
261
|
-
*/
|
|
262
|
-
const DIRECT_MESSAGE_CREATE = (client, event, val) => {
|
|
263
|
-
const content = val
|
|
264
|
-
.filter(item => item.type == 'Mention' || item.type == 'Text')
|
|
265
|
-
.map(item => {
|
|
266
|
-
if (item.type == 'Text') {
|
|
267
|
-
return item.value
|
|
268
|
-
}
|
|
269
|
-
return ''
|
|
270
|
-
})
|
|
271
|
-
.join('')
|
|
272
|
-
if (content) {
|
|
273
|
-
return Promise.all(
|
|
274
|
-
[content].map(item =>
|
|
275
|
-
client.dmsMessage(event.OpenId, {
|
|
276
|
-
content: item,
|
|
277
|
-
msg_id: event.MessageId
|
|
278
|
-
})
|
|
279
|
-
)
|
|
280
|
-
)
|
|
281
|
-
}
|
|
282
|
-
const images = val.filter(
|
|
283
|
-
item => item.type == 'Image' || item.type == 'ImageFile' || item.type == 'ImageURL'
|
|
284
|
-
)
|
|
285
|
-
if (images) {
|
|
286
|
-
return Promise.all(
|
|
287
|
-
images.map(async item => {
|
|
288
|
-
if (item.value == 'ImageURL') {
|
|
289
|
-
// 请求得到buffer
|
|
290
|
-
const data = await axios
|
|
291
|
-
.get(item.value, {
|
|
292
|
-
responseType: 'arraybuffer'
|
|
293
|
-
})
|
|
294
|
-
.then(res => res.data)
|
|
295
|
-
return client.postDirectImage(event.OpenId, {
|
|
296
|
-
msg_id: event.MessageId,
|
|
297
|
-
image: data
|
|
298
|
-
})
|
|
299
|
-
}
|
|
300
|
-
const file_data = item.type == 'ImageFile' ? readFileSync(item.value) : item.value
|
|
301
|
-
return client.postDirectImage(event.OpenId, {
|
|
302
|
-
msg_id: event.MessageId,
|
|
303
|
-
image: Buffer.isBuffer(file_data) ? file_data : Buffer.from(file_data)
|
|
304
|
-
})
|
|
305
|
-
})
|
|
306
|
-
)
|
|
307
|
-
}
|
|
308
|
-
return []
|
|
309
|
-
}
|
|
310
|
-
const AT_MESSAGE_CREATE = (client, event, val) => {
|
|
311
|
-
const content = val
|
|
312
|
-
.filter(item => item.type == 'Mention' || item.type == 'Text')
|
|
313
|
-
.map(item => {
|
|
314
|
-
// if (item.type == 'Link') {
|
|
315
|
-
// return `[${item.options?.title ?? item.value}](${item.value})`
|
|
316
|
-
// } else
|
|
317
|
-
if (item.type == 'Mention') {
|
|
318
|
-
if (
|
|
319
|
-
item.value == 'everyone' ||
|
|
320
|
-
item.value == 'all' ||
|
|
321
|
-
item.value == '' ||
|
|
322
|
-
typeof item.value != 'string'
|
|
323
|
-
) {
|
|
324
|
-
return `@everyone`
|
|
325
|
-
}
|
|
326
|
-
if (item.options?.belong == 'user') {
|
|
327
|
-
return `<@!${item.value}>`
|
|
328
|
-
} else if (item.options?.belong == 'channel') {
|
|
329
|
-
return `<#${item.value}>`
|
|
330
|
-
}
|
|
331
|
-
return ''
|
|
332
|
-
} else if (item.type == 'Text') {
|
|
333
|
-
return item.value
|
|
334
|
-
}
|
|
335
|
-
})
|
|
336
|
-
.join('')
|
|
337
|
-
if (content) {
|
|
338
|
-
return Promise.all(
|
|
339
|
-
[content].map(item =>
|
|
340
|
-
client.channelsMessagesPost(event.ChannelId, {
|
|
341
|
-
content: item,
|
|
342
|
-
msg_id: event.MessageId
|
|
343
|
-
})
|
|
344
|
-
)
|
|
345
|
-
)
|
|
346
|
-
}
|
|
347
|
-
const images = val.filter(
|
|
348
|
-
item => item.type == 'Image' || item.type == 'ImageFile' || item.type == 'ImageURL'
|
|
349
|
-
)
|
|
350
|
-
if (images && images.length > 0) {
|
|
351
|
-
return Promise.all(
|
|
352
|
-
images.map(async item => {
|
|
353
|
-
if (item.value == 'ImageURL') {
|
|
354
|
-
// 请求得到buffer
|
|
355
|
-
const data = await axios
|
|
356
|
-
.get(item.value, {
|
|
357
|
-
responseType: 'arraybuffer'
|
|
358
|
-
})
|
|
359
|
-
.then(res => res.data)
|
|
360
|
-
return client.postImage(event.ChannelId, {
|
|
361
|
-
msg_id: event.MessageId,
|
|
362
|
-
image: data
|
|
363
|
-
})
|
|
364
|
-
}
|
|
365
|
-
const file_data = item.type == 'ImageFile' ? readFileSync(item.value) : item.value
|
|
366
|
-
return client.postImage(event.ChannelId, {
|
|
367
|
-
msg_id: event.MessageId,
|
|
368
|
-
image: Buffer.isBuffer(file_data) ? file_data : Buffer.from(file_data)
|
|
369
|
-
})
|
|
370
|
-
})
|
|
371
|
-
)
|
|
372
|
-
}
|
|
373
|
-
return Promise.all([])
|
|
374
|
-
}
|
|
375
|
-
/**
|
|
376
|
-
*
|
|
377
|
-
* @param event
|
|
378
|
-
* @param val
|
|
379
|
-
* @returns
|
|
380
|
-
*/
|
|
381
|
-
const MESSAGE_CREATE = (client, event, val) => {
|
|
382
|
-
const content = val
|
|
383
|
-
.filter(item => item.type == 'Mention' || item.type == 'Text')
|
|
384
|
-
.map(item => {
|
|
385
|
-
// if (item.type == 'Link') {
|
|
386
|
-
// return `[${item.options?.title ?? item.value}](${item.value})`
|
|
387
|
-
// } else
|
|
388
|
-
if (item.type == 'Mention') {
|
|
389
|
-
if (
|
|
390
|
-
item.value == 'everyone' ||
|
|
391
|
-
item.value == 'all' ||
|
|
392
|
-
item.value == '' ||
|
|
393
|
-
typeof item.value != 'string'
|
|
394
|
-
) {
|
|
395
|
-
return `@everyone`
|
|
396
|
-
}
|
|
397
|
-
if (item.options?.belong == 'user') {
|
|
398
|
-
return `<@!${item.value}>`
|
|
399
|
-
} else if (item.options?.belong == 'channel') {
|
|
400
|
-
return `<#${item.value}>`
|
|
401
|
-
}
|
|
402
|
-
return ''
|
|
403
|
-
} else if (item.type == 'Text') {
|
|
404
|
-
return item.value
|
|
405
|
-
}
|
|
406
|
-
})
|
|
407
|
-
.join('')
|
|
408
|
-
if (content) {
|
|
409
|
-
return Promise.all(
|
|
410
|
-
[content].map(item =>
|
|
411
|
-
client.channelsMessagesPost(event.ChannelId, {
|
|
412
|
-
content: item,
|
|
413
|
-
msg_id: event.MessageId
|
|
414
|
-
})
|
|
415
|
-
)
|
|
416
|
-
)
|
|
417
|
-
}
|
|
418
|
-
const images = val.filter(
|
|
419
|
-
item => item.type == 'Image' || item.type == 'ImageFile' || item.type == 'ImageURL'
|
|
420
|
-
)
|
|
421
|
-
if (images && images.length > 0) {
|
|
422
|
-
return Promise.all(
|
|
423
|
-
images.map(async item => {
|
|
424
|
-
if (item.value == 'ImageURL') {
|
|
425
|
-
// 请求得到buffer
|
|
426
|
-
const data = await axios
|
|
427
|
-
.get(item.value, {
|
|
428
|
-
responseType: 'arraybuffer'
|
|
429
|
-
})
|
|
430
|
-
.then(res => res.data)
|
|
431
|
-
return client.postImage(event.ChannelId, {
|
|
432
|
-
msg_id: event.MessageId,
|
|
433
|
-
image: data
|
|
434
|
-
})
|
|
435
|
-
}
|
|
436
|
-
const file_data = item.type == 'ImageFile' ? readFileSync(item.value) : item.value
|
|
437
|
-
return client.postImage(event.ChannelId, {
|
|
438
|
-
msg_id: event.MessageId,
|
|
439
|
-
image: Buffer.isBuffer(file_data) ? file_data : Buffer.from(file_data)
|
|
440
|
-
})
|
|
441
|
-
})
|
|
442
|
-
)
|
|
443
|
-
}
|
|
444
|
-
return Promise.all([])
|
|
445
|
-
}
|
|
446
|
-
|
|
447
|
-
export {
|
|
448
|
-
AT_MESSAGE_CREATE,
|
|
449
|
-
C2C_MESSAGE_CREATE,
|
|
450
|
-
DIRECT_MESSAGE_CREATE,
|
|
451
|
-
GROUP_AT_MESSAGE_CREATE,
|
|
452
|
-
MESSAGE_CREATE
|
|
453
|
-
}
|