@alemonjs/qq-bot 2.1.0-alpha.3 → 2.1.0-alpha.4
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/dist/assets/index.css +1255 -1
- package/dist/assets/index.js +11364 -5
- package/dist/index.html +1 -1
- package/lib/register.js +61 -53
- package/lib/sdk/api.d.ts +970 -0
- package/lib/sdk/typing.d.ts +63 -0
- package/lib/sends.js +10 -8
- package/lib/utils.js +13 -0
- package/package.json +1 -1
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
type MessageType = 0 | 1 | 2 | 3 | 4 | 7
|
|
2
|
+
type FileType = 1 | 2 | 3 | 4
|
|
3
|
+
interface ButtonType {
|
|
4
|
+
id: string
|
|
5
|
+
render_data: {
|
|
6
|
+
label: string
|
|
7
|
+
visited_label: string
|
|
8
|
+
style?: number
|
|
9
|
+
}
|
|
10
|
+
action: {
|
|
11
|
+
type: number
|
|
12
|
+
permission: {
|
|
13
|
+
type: number
|
|
14
|
+
}
|
|
15
|
+
reply?: boolean
|
|
16
|
+
enter?: boolean
|
|
17
|
+
unsupport_tips?: string
|
|
18
|
+
data:
|
|
19
|
+
| string
|
|
20
|
+
| {
|
|
21
|
+
click: string
|
|
22
|
+
confirm: string
|
|
23
|
+
cancel: string
|
|
24
|
+
}
|
|
25
|
+
at_bot_show_channel_list?: boolean
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
interface KeyboardType {
|
|
29
|
+
id?: string
|
|
30
|
+
content?: {
|
|
31
|
+
rows: {
|
|
32
|
+
buttons: ButtonType[]
|
|
33
|
+
}[]
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
interface MarkdownType {
|
|
37
|
+
/** markdown 模版id,申请模版后获得 */
|
|
38
|
+
custom_template_id: string
|
|
39
|
+
/** 原生 markdown 文本内容(内邀使用) */
|
|
40
|
+
content?: string
|
|
41
|
+
/** 模版内变量与填充值的kv映射 */
|
|
42
|
+
params?: Array<{
|
|
43
|
+
key: string
|
|
44
|
+
values: string[]
|
|
45
|
+
}>
|
|
46
|
+
}
|
|
47
|
+
interface ApiRequestData {
|
|
48
|
+
content?: string
|
|
49
|
+
msg_type: MessageType
|
|
50
|
+
markdown?: MarkdownType
|
|
51
|
+
keyboard?: KeyboardType
|
|
52
|
+
media?: {
|
|
53
|
+
file_info: string
|
|
54
|
+
}
|
|
55
|
+
ark?: any
|
|
56
|
+
image?: any
|
|
57
|
+
message_reference?: any
|
|
58
|
+
event_id?: any
|
|
59
|
+
msg_id?: string
|
|
60
|
+
msg_seq?: number
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export type { ApiRequestData, ButtonType, FileType, KeyboardType, MarkdownType, MessageType }
|
package/lib/sends.js
CHANGED
|
@@ -212,7 +212,8 @@ const GROUP_AT_MESSAGE_CREATE = async (client, event, val) => {
|
|
|
212
212
|
});
|
|
213
213
|
}
|
|
214
214
|
try {
|
|
215
|
-
const
|
|
215
|
+
const getFileBase64 = () => readFileSync(item.value, 'base64');
|
|
216
|
+
const file_data = item.type == 'ImageFile' ? getFileBase64() : item.value;
|
|
216
217
|
const file_info = await client
|
|
217
218
|
.postRichMediaByGroup(event.GuildId, {
|
|
218
219
|
file_type: 1,
|
|
@@ -372,7 +373,8 @@ const C2C_MESSAGE_CREATE = (client, event, val) => {
|
|
|
372
373
|
id: res.id
|
|
373
374
|
});
|
|
374
375
|
}
|
|
375
|
-
const
|
|
376
|
+
const getFileBase64 = () => readFileSync(item.value, 'base64');
|
|
377
|
+
const file_data = item.type == 'ImageFile' ? getFileBase64() : item.value;
|
|
376
378
|
const file_info = await client
|
|
377
379
|
.postRichMediaByUsers(event.OpenId, {
|
|
378
380
|
file_type: 1,
|
|
@@ -517,10 +519,10 @@ const DIRECT_MESSAGE_CREATE = (client, event, val) => {
|
|
|
517
519
|
});
|
|
518
520
|
return createResult(ResultCode.Ok, 'client.postDirectImage', { id: res?.id });
|
|
519
521
|
}
|
|
520
|
-
const file_data = item.type == 'ImageFile' ? readFileSync(item.value) : item.value;
|
|
522
|
+
const file_data = item.type == 'ImageFile' ? readFileSync(item.value) : Buffer.from(item.value, 'base64');
|
|
521
523
|
const res = await client.postDirectImage(event.OpenId, {
|
|
522
524
|
msg_id: event.MessageId,
|
|
523
|
-
image:
|
|
525
|
+
image: file_data
|
|
524
526
|
});
|
|
525
527
|
return createResult(ResultCode.Ok, 'client.postDirectImage', { id: res?.id });
|
|
526
528
|
})).catch(err => [
|
|
@@ -583,10 +585,10 @@ const AT_MESSAGE_CREATE = (client, event, val) => {
|
|
|
583
585
|
});
|
|
584
586
|
return createResult(ResultCode.Ok, 'client.postImage', { id: res?.id });
|
|
585
587
|
}
|
|
586
|
-
const file_data = item.type == 'ImageFile' ? readFileSync(item.value) : item.value;
|
|
588
|
+
const file_data = item.type == 'ImageFile' ? readFileSync(item.value) : Buffer.from(item.value, 'base64');
|
|
587
589
|
const res = await client.postImage(event.ChannelId, {
|
|
588
590
|
msg_id: event.MessageId,
|
|
589
|
-
image:
|
|
591
|
+
image: file_data
|
|
590
592
|
});
|
|
591
593
|
return createResult(ResultCode.Ok, 'client.postImage', { id: res?.id });
|
|
592
594
|
})).catch(err => [
|
|
@@ -655,10 +657,10 @@ const MESSAGE_CREATE = (client, event, val) => {
|
|
|
655
657
|
});
|
|
656
658
|
return createResult(ResultCode.Ok, 'client.postImage', { id: res?.id });
|
|
657
659
|
}
|
|
658
|
-
const file_data = item.type == 'ImageFile' ? readFileSync(item.value) : item.value;
|
|
660
|
+
const file_data = item.type == 'ImageFile' ? readFileSync(item.value) : Buffer.from(item.value, 'base64');
|
|
659
661
|
const res = await client.postImage(event.ChannelId, {
|
|
660
662
|
msg_id: event.MessageId,
|
|
661
|
-
image:
|
|
663
|
+
image: file_data
|
|
662
664
|
});
|
|
663
665
|
return createResult(ResultCode.Ok, 'client.postImage', { id: res?.id });
|
|
664
666
|
})).catch(err => [
|
package/lib/utils.js
ADDED