@linjz/opencode-qqbot 0.3.5 → 0.3.7
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 +74 -39
- package/bin/openqq-setup.mjs +50 -50
- package/bin/openqq.js +47 -47
- package/dist/opencode-qqbot-plugin.js +10 -1
- package/dist/openqq-bot.js +365 -70
- package/package.json +69 -61
- package/src/_FOLDER.md +19 -19
- package/src/bridge.ts +936 -796
- package/src/commands.ts +554 -514
- package/src/config.ts +121 -121
- package/src/core/bot-launcher.ts +146 -134
- package/src/core/card-approval.ts +146 -146
- package/src/core/context-buffer.ts +78 -78
- package/src/core/delivery.ts +284 -284
- package/src/core/discovery.ts +151 -151
- package/src/core/error-rescue.ts +33 -0
- package/src/core/file-log.ts +45 -45
- package/src/core/form-bridge.ts +304 -304
- package/src/core/inflight-journal.ts +217 -151
- package/src/core/instance-lock.ts +122 -122
- package/src/core/linkwatch.ts +195 -195
- package/src/core/message-queue.ts +80 -0
- package/src/core/mirror.ts +173 -173
- package/src/core/permission.ts +301 -301
- package/src/core/reply-limiter.ts +106 -106
- package/src/core/send-media.ts +90 -90
- package/src/core/util.ts +8 -8
- package/src/index.ts +162 -162
- package/src/opencode/_FOLDER.md +11 -11
- package/src/opencode/client.ts +387 -386
- package/src/opencode/eventstream.ts +138 -138
- package/src/opencode/history.ts +143 -143
- package/src/opencode/mirror.ts +65 -65
- package/src/opencode/sessions.ts +158 -158
- package/src/plugin-entry.ts +112 -112
- package/src/qq/_FOLDER.md +13 -13
- package/src/qq/api.ts +539 -539
- package/src/qq/gateway.ts +492 -492
- package/src/qq/media.ts +219 -204
- package/src/qq/sender.ts +300 -300
- package/src/qq/types.ts +154 -152
- package/tsconfig.json +24 -24
package/src/qq/types.ts
CHANGED
|
@@ -1,152 +1,154 @@
|
|
|
1
|
-
// @input: (none)
|
|
2
|
-
// @output: MessageContext, C2CMessageEvent, GroupMessageEvent, WSPayload, QQBotConfig
|
|
3
|
-
// @pos: qq层 - QQ Bot 消息事件和协议类型定义
|
|
4
|
-
export interface QQBotConfig {
|
|
5
|
-
appId: string
|
|
6
|
-
clientSecret: string
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* 富媒体附件
|
|
11
|
-
*/
|
|
12
|
-
export interface MessageAttachment {
|
|
13
|
-
content_type: string
|
|
14
|
-
filename?: string
|
|
15
|
-
height?: number
|
|
16
|
-
width?: number
|
|
17
|
-
size?: number
|
|
18
|
-
url: string
|
|
19
|
-
voice_wav_url?: string
|
|
20
|
-
/** 语音消息的 QQ 内置 ASR 转写文本(免费,省下载省 STT 调用) */
|
|
21
|
-
asr_refer_text?: string
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* C2C 消息事件
|
|
26
|
-
*/
|
|
27
|
-
export interface C2CMessageEvent {
|
|
28
|
-
author: {
|
|
29
|
-
id: string
|
|
30
|
-
union_openid: string
|
|
31
|
-
user_openid: string
|
|
32
|
-
}
|
|
33
|
-
content: string
|
|
34
|
-
id: string
|
|
35
|
-
timestamp: string
|
|
36
|
-
message_scene?: {
|
|
37
|
-
source: string
|
|
38
|
-
}
|
|
39
|
-
attachments?: MessageAttachment[]
|
|
40
|
-
/** 长按回复引用的消息 id(QQ 客户端引用消息) */
|
|
41
|
-
message_reference?: { message_id: string }
|
|
42
|
-
/** 引用消息的嵌入内容载体(message_type=103 时随事件透传,官方未完全文档化) */
|
|
43
|
-
message_type?: number
|
|
44
|
-
msg_elements?: unknown
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* 频道 AT 消息事件
|
|
49
|
-
*/
|
|
50
|
-
export interface GuildMessageEvent {
|
|
51
|
-
id: string
|
|
52
|
-
channel_id: string
|
|
53
|
-
guild_id: string
|
|
54
|
-
content: string
|
|
55
|
-
timestamp: string
|
|
56
|
-
author: {
|
|
57
|
-
id: string
|
|
58
|
-
username?: string
|
|
59
|
-
bot?: boolean
|
|
60
|
-
}
|
|
61
|
-
member?: {
|
|
62
|
-
nick?: string
|
|
63
|
-
joined_at?: string
|
|
64
|
-
}
|
|
65
|
-
attachments?: MessageAttachment[]
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* 群聊 AT 消息事件
|
|
70
|
-
*/
|
|
71
|
-
export interface GroupMessageEvent {
|
|
72
|
-
author: {
|
|
73
|
-
id: string
|
|
74
|
-
member_openid: string
|
|
75
|
-
}
|
|
76
|
-
content: string
|
|
77
|
-
id: string
|
|
78
|
-
timestamp: string
|
|
79
|
-
group_id: string
|
|
80
|
-
group_openid: string
|
|
81
|
-
attachments?: MessageAttachment[]
|
|
82
|
-
/** 长按回复引用的消息 id(QQ 客户端引用消息) */
|
|
83
|
-
message_reference?: { message_id: string }
|
|
84
|
-
/** 引用消息的嵌入内容载体(message_type=103 时随事件透传,官方未完全文档化) */
|
|
85
|
-
message_type?: number
|
|
86
|
-
msg_elements?: unknown
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
/**
|
|
90
|
-
* Hello 事件数据
|
|
91
|
-
*/
|
|
92
|
-
export interface GatewayHelloData {
|
|
93
|
-
heartbeat_interval: number
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
/**
|
|
97
|
-
* READY 事件数据
|
|
98
|
-
*/
|
|
99
|
-
export interface GatewayReadyData {
|
|
100
|
-
session_id: string
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
/**
|
|
104
|
-
* WebSocket 事件负载
|
|
105
|
-
*/
|
|
106
|
-
export interface WSPayload<T = unknown> {
|
|
107
|
-
|
|
108
|
-
op: number
|
|
109
|
-
d?: T
|
|
110
|
-
s?: number
|
|
111
|
-
t?: string
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
/**
|
|
115
|
-
* 按钮交互回调事件(INTERACTION_CREATE)——A 项卡片审批(2026-10-29)。
|
|
116
|
-
* 形状对齐 P0 官方 @tencent-connect/qqbot-nodejs protocol/types.ts。
|
|
117
|
-
*/
|
|
118
|
-
export interface InteractionButtonResolved {
|
|
119
|
-
button_id?: string
|
|
120
|
-
button_data?: string
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
export interface InteractionEvent {
|
|
124
|
-
id: string
|
|
125
|
-
type?: number
|
|
126
|
-
scene?: string
|
|
127
|
-
user_openid?: string
|
|
128
|
-
group_openid?: string
|
|
129
|
-
/** 群场景点击者身份(自我评审 2026-10-29:挂起槽对群用户用 member_openid 索引,
|
|
130
|
-
* 只认 user_openid 会导致群按钮点击被静默拒识) */
|
|
131
|
-
group_member_openid?: string
|
|
132
|
-
data?: { type?: number; resolved?: InteractionButtonResolved }
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
/**
|
|
136
|
-
* 桥接层统一使用的消息上下文
|
|
137
|
-
*/
|
|
138
|
-
export interface MessageContext {
|
|
139
|
-
type: "c2c" | "group"
|
|
140
|
-
userId: string
|
|
141
|
-
groupId?: string
|
|
142
|
-
msgId: string
|
|
143
|
-
content: string
|
|
144
|
-
/** 长按回复引用的消息 id(经 message_reference 透传) */
|
|
145
|
-
referencedMsgId?: string
|
|
146
|
-
/** 解析后的引用上文(bridge 从 context-buffer 解析得到,注入 prompt 前缀) */
|
|
147
|
-
quoteText?: string
|
|
148
|
-
/** 图片等富媒体附件(原生附件接入 2026-10-14;此前在网关被静默丢弃) */
|
|
149
|
-
attachments?: MessageAttachment[]
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
1
|
+
// @input: (none)
|
|
2
|
+
// @output: MessageContext, C2CMessageEvent, GroupMessageEvent, WSPayload, QQBotConfig
|
|
3
|
+
// @pos: qq层 - QQ Bot 消息事件和协议类型定义
|
|
4
|
+
export interface QQBotConfig {
|
|
5
|
+
appId: string
|
|
6
|
+
clientSecret: string
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* 富媒体附件
|
|
11
|
+
*/
|
|
12
|
+
export interface MessageAttachment {
|
|
13
|
+
content_type: string
|
|
14
|
+
filename?: string
|
|
15
|
+
height?: number
|
|
16
|
+
width?: number
|
|
17
|
+
size?: number
|
|
18
|
+
url: string
|
|
19
|
+
voice_wav_url?: string
|
|
20
|
+
/** 语音消息的 QQ 内置 ASR 转写文本(免费,省下载省 STT 调用) */
|
|
21
|
+
asr_refer_text?: string
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* C2C 消息事件
|
|
26
|
+
*/
|
|
27
|
+
export interface C2CMessageEvent {
|
|
28
|
+
author: {
|
|
29
|
+
id: string
|
|
30
|
+
union_openid: string
|
|
31
|
+
user_openid: string
|
|
32
|
+
}
|
|
33
|
+
content: string
|
|
34
|
+
id: string
|
|
35
|
+
timestamp: string
|
|
36
|
+
message_scene?: {
|
|
37
|
+
source: string
|
|
38
|
+
}
|
|
39
|
+
attachments?: MessageAttachment[]
|
|
40
|
+
/** 长按回复引用的消息 id(QQ 客户端引用消息) */
|
|
41
|
+
message_reference?: { message_id: string }
|
|
42
|
+
/** 引用消息的嵌入内容载体(message_type=103 时随事件透传,官方未完全文档化) */
|
|
43
|
+
message_type?: number
|
|
44
|
+
msg_elements?: unknown
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* 频道 AT 消息事件
|
|
49
|
+
*/
|
|
50
|
+
export interface GuildMessageEvent {
|
|
51
|
+
id: string
|
|
52
|
+
channel_id: string
|
|
53
|
+
guild_id: string
|
|
54
|
+
content: string
|
|
55
|
+
timestamp: string
|
|
56
|
+
author: {
|
|
57
|
+
id: string
|
|
58
|
+
username?: string
|
|
59
|
+
bot?: boolean
|
|
60
|
+
}
|
|
61
|
+
member?: {
|
|
62
|
+
nick?: string
|
|
63
|
+
joined_at?: string
|
|
64
|
+
}
|
|
65
|
+
attachments?: MessageAttachment[]
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* 群聊 AT 消息事件
|
|
70
|
+
*/
|
|
71
|
+
export interface GroupMessageEvent {
|
|
72
|
+
author: {
|
|
73
|
+
id: string
|
|
74
|
+
member_openid: string
|
|
75
|
+
}
|
|
76
|
+
content: string
|
|
77
|
+
id: string
|
|
78
|
+
timestamp: string
|
|
79
|
+
group_id: string
|
|
80
|
+
group_openid: string
|
|
81
|
+
attachments?: MessageAttachment[]
|
|
82
|
+
/** 长按回复引用的消息 id(QQ 客户端引用消息) */
|
|
83
|
+
message_reference?: { message_id: string }
|
|
84
|
+
/** 引用消息的嵌入内容载体(message_type=103 时随事件透传,官方未完全文档化) */
|
|
85
|
+
message_type?: number
|
|
86
|
+
msg_elements?: unknown
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Hello 事件数据
|
|
91
|
+
*/
|
|
92
|
+
export interface GatewayHelloData {
|
|
93
|
+
heartbeat_interval: number
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* READY 事件数据
|
|
98
|
+
*/
|
|
99
|
+
export interface GatewayReadyData {
|
|
100
|
+
session_id: string
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* WebSocket 事件负载
|
|
105
|
+
*/
|
|
106
|
+
export interface WSPayload<T = unknown> {
|
|
107
|
+
|
|
108
|
+
op: number
|
|
109
|
+
d?: T
|
|
110
|
+
s?: number
|
|
111
|
+
t?: string
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* 按钮交互回调事件(INTERACTION_CREATE)——A 项卡片审批(2026-10-29)。
|
|
116
|
+
* 形状对齐 P0 官方 @tencent-connect/qqbot-nodejs protocol/types.ts。
|
|
117
|
+
*/
|
|
118
|
+
export interface InteractionButtonResolved {
|
|
119
|
+
button_id?: string
|
|
120
|
+
button_data?: string
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
export interface InteractionEvent {
|
|
124
|
+
id: string
|
|
125
|
+
type?: number
|
|
126
|
+
scene?: string
|
|
127
|
+
user_openid?: string
|
|
128
|
+
group_openid?: string
|
|
129
|
+
/** 群场景点击者身份(自我评审 2026-10-29:挂起槽对群用户用 member_openid 索引,
|
|
130
|
+
* 只认 user_openid 会导致群按钮点击被静默拒识) */
|
|
131
|
+
group_member_openid?: string
|
|
132
|
+
data?: { type?: number; resolved?: InteractionButtonResolved }
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* 桥接层统一使用的消息上下文
|
|
137
|
+
*/
|
|
138
|
+
export interface MessageContext {
|
|
139
|
+
type: "c2c" | "group"
|
|
140
|
+
userId: string
|
|
141
|
+
groupId?: string
|
|
142
|
+
msgId: string
|
|
143
|
+
content: string
|
|
144
|
+
/** 长按回复引用的消息 id(经 message_reference 透传) */
|
|
145
|
+
referencedMsgId?: string
|
|
146
|
+
/** 解析后的引用上文(bridge 从 context-buffer 解析得到,注入 prompt 前缀) */
|
|
147
|
+
quoteText?: string
|
|
148
|
+
/** 图片等富媒体附件(原生附件接入 2026-10-14;此前在网关被静默丢弃) */
|
|
149
|
+
attachments?: MessageAttachment[]
|
|
150
|
+
/** 排队时预下载的附件(Q1:避免 drain 时 QQ 签名 URL 过期——入队即落盘) */
|
|
151
|
+
preparedAttachments?: import("./media.js").PreparedAttachments
|
|
152
|
+
timestamp?: string
|
|
153
|
+
rawEvent?: C2CMessageEvent | GroupMessageEvent
|
|
154
|
+
}
|
package/tsconfig.json
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"target": "ES2022",
|
|
4
|
-
"module": "ESNext",
|
|
5
|
-
"moduleResolution": "bundler",
|
|
6
|
-
"lib": ["ES2022"],
|
|
7
|
-
"outDir": "dist",
|
|
8
|
-
"rootDir": "src",
|
|
9
|
-
"strict": true,
|
|
10
|
-
"esModuleInterop": true,
|
|
11
|
-
"skipLibCheck": true,
|
|
12
|
-
"forceConsistentCasingInFileNames": true,
|
|
13
|
-
"resolveJsonModule": true,
|
|
14
|
-
"declaration": true,
|
|
15
|
-
"declarationMap": true,
|
|
16
|
-
"sourceMap": true,
|
|
17
|
-
"noUnusedLocals": true,
|
|
18
|
-
"noUnusedParameters": true,
|
|
19
|
-
"noFallthroughCasesInSwitch": true,
|
|
20
|
-
"types": ["node"]
|
|
21
|
-
},
|
|
22
|
-
"include": ["src/**/*.ts"],
|
|
23
|
-
"exclude": ["node_modules", "dist"]
|
|
24
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2022",
|
|
4
|
+
"module": "ESNext",
|
|
5
|
+
"moduleResolution": "bundler",
|
|
6
|
+
"lib": ["ES2022"],
|
|
7
|
+
"outDir": "dist",
|
|
8
|
+
"rootDir": "src",
|
|
9
|
+
"strict": true,
|
|
10
|
+
"esModuleInterop": true,
|
|
11
|
+
"skipLibCheck": true,
|
|
12
|
+
"forceConsistentCasingInFileNames": true,
|
|
13
|
+
"resolveJsonModule": true,
|
|
14
|
+
"declaration": true,
|
|
15
|
+
"declarationMap": true,
|
|
16
|
+
"sourceMap": true,
|
|
17
|
+
"noUnusedLocals": true,
|
|
18
|
+
"noUnusedParameters": true,
|
|
19
|
+
"noFallthroughCasesInSwitch": true,
|
|
20
|
+
"types": ["node"]
|
|
21
|
+
},
|
|
22
|
+
"include": ["src/**/*.ts"],
|
|
23
|
+
"exclude": ["node_modules", "dist"]
|
|
24
|
+
}
|