@gakr-gakr/qqbot 0.1.0

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.
Files changed (149) hide show
  1. package/api.ts +56 -0
  2. package/autobot.plugin.json +167 -0
  3. package/channel-plugin-api.ts +1 -0
  4. package/index.ts +33 -0
  5. package/package.json +64 -0
  6. package/runtime-api.ts +9 -0
  7. package/secret-contract-api.ts +5 -0
  8. package/setup-entry.ts +13 -0
  9. package/setup-plugin-api.ts +3 -0
  10. package/skills/qqbot-channel/SKILL.md +262 -0
  11. package/skills/qqbot-channel/references/api_references.md +521 -0
  12. package/skills/qqbot-media/SKILL.md +37 -0
  13. package/skills/qqbot-remind/SKILL.md +153 -0
  14. package/src/bridge/approval/capability.ts +225 -0
  15. package/src/bridge/approval/handler-runtime.ts +204 -0
  16. package/src/bridge/bootstrap.ts +135 -0
  17. package/src/bridge/channel-entry.ts +18 -0
  18. package/src/bridge/commands/framework-context-adapter.ts +60 -0
  19. package/src/bridge/commands/framework-registration.ts +66 -0
  20. package/src/bridge/commands/from-parser.ts +60 -0
  21. package/src/bridge/commands/result-dispatcher.ts +76 -0
  22. package/src/bridge/config-shared.ts +132 -0
  23. package/src/bridge/config.ts +176 -0
  24. package/src/bridge/gateway.ts +178 -0
  25. package/src/bridge/logger.ts +31 -0
  26. package/src/bridge/narrowing.ts +31 -0
  27. package/src/bridge/plugin-version.ts +102 -0
  28. package/src/bridge/runtime.ts +25 -0
  29. package/src/bridge/sdk-adapter.ts +164 -0
  30. package/src/bridge/setup/finalize.ts +144 -0
  31. package/src/bridge/setup/surface.ts +34 -0
  32. package/src/bridge/tools/channel.ts +58 -0
  33. package/src/bridge/tools/index.ts +15 -0
  34. package/src/bridge/tools/remind.ts +91 -0
  35. package/src/channel.setup.ts +33 -0
  36. package/src/channel.ts +399 -0
  37. package/src/config-schema.ts +84 -0
  38. package/src/engine/access/index.ts +2 -0
  39. package/src/engine/access/resolve-policy.ts +30 -0
  40. package/src/engine/access/sender-match.ts +55 -0
  41. package/src/engine/access/types.ts +2 -0
  42. package/src/engine/adapter/audio.port.ts +27 -0
  43. package/src/engine/adapter/commands.port.ts +22 -0
  44. package/src/engine/adapter/history.port.ts +52 -0
  45. package/src/engine/adapter/index.ts +76 -0
  46. package/src/engine/adapter/mention-gate.port.ts +50 -0
  47. package/src/engine/adapter/types.ts +38 -0
  48. package/src/engine/api/api-client.ts +212 -0
  49. package/src/engine/api/media-chunked.ts +644 -0
  50. package/src/engine/api/media.ts +218 -0
  51. package/src/engine/api/messages.ts +293 -0
  52. package/src/engine/api/retry.ts +217 -0
  53. package/src/engine/api/routes.ts +95 -0
  54. package/src/engine/api/token.ts +277 -0
  55. package/src/engine/approval/index.ts +224 -0
  56. package/src/engine/commands/builtin/log-helpers.ts +341 -0
  57. package/src/engine/commands/builtin/register-all.ts +17 -0
  58. package/src/engine/commands/builtin/register-approve.ts +201 -0
  59. package/src/engine/commands/builtin/register-basic.ts +95 -0
  60. package/src/engine/commands/builtin/register-clear-storage.ts +187 -0
  61. package/src/engine/commands/builtin/register-logs.ts +20 -0
  62. package/src/engine/commands/builtin/register-streaming.ts +138 -0
  63. package/src/engine/commands/builtin/state.ts +31 -0
  64. package/src/engine/commands/slash-command-auth.ts +88 -0
  65. package/src/engine/commands/slash-command-handler.ts +168 -0
  66. package/src/engine/commands/slash-command-test-support.ts +39 -0
  67. package/src/engine/commands/slash-commands-impl.ts +61 -0
  68. package/src/engine/commands/slash-commands.ts +202 -0
  69. package/src/engine/config/credential-backup.ts +108 -0
  70. package/src/engine/config/credentials.ts +76 -0
  71. package/src/engine/config/group.ts +227 -0
  72. package/src/engine/config/resolve.ts +283 -0
  73. package/src/engine/config/setup-logic.ts +84 -0
  74. package/src/engine/gateway/active-cfg.ts +52 -0
  75. package/src/engine/gateway/codec.ts +47 -0
  76. package/src/engine/gateway/constants.ts +117 -0
  77. package/src/engine/gateway/event-dispatcher.ts +177 -0
  78. package/src/engine/gateway/gateway-connection.ts +356 -0
  79. package/src/engine/gateway/gateway.ts +267 -0
  80. package/src/engine/gateway/inbound-attachments.ts +360 -0
  81. package/src/engine/gateway/inbound-context.ts +82 -0
  82. package/src/engine/gateway/inbound-pipeline.ts +171 -0
  83. package/src/engine/gateway/interaction-handler.ts +345 -0
  84. package/src/engine/gateway/message-queue.ts +404 -0
  85. package/src/engine/gateway/outbound-dispatch.ts +590 -0
  86. package/src/engine/gateway/reconnect.ts +199 -0
  87. package/src/engine/gateway/stages/access-stage.ts +99 -0
  88. package/src/engine/gateway/stages/assembly-stage.ts +156 -0
  89. package/src/engine/gateway/stages/content-stage.ts +77 -0
  90. package/src/engine/gateway/stages/envelope-stage.ts +144 -0
  91. package/src/engine/gateway/stages/group-gate-stage.ts +223 -0
  92. package/src/engine/gateway/stages/index.ts +18 -0
  93. package/src/engine/gateway/stages/quote-stage.ts +113 -0
  94. package/src/engine/gateway/stages/refidx-stage.ts +62 -0
  95. package/src/engine/gateway/stages/stub-contexts.ts +77 -0
  96. package/src/engine/gateway/types.ts +230 -0
  97. package/src/engine/gateway/typing-keepalive.ts +102 -0
  98. package/src/engine/gateway/ws-client.ts +16 -0
  99. package/src/engine/group/activation.ts +88 -0
  100. package/src/engine/group/history.ts +321 -0
  101. package/src/engine/group/mention.ts +114 -0
  102. package/src/engine/group/message-gating.ts +108 -0
  103. package/src/engine/messaging/decode-media-path.ts +82 -0
  104. package/src/engine/messaging/media-source.ts +210 -0
  105. package/src/engine/messaging/media-type-detect.ts +27 -0
  106. package/src/engine/messaging/outbound-audio-port.ts +38 -0
  107. package/src/engine/messaging/outbound-deliver.ts +810 -0
  108. package/src/engine/messaging/outbound-media-send.ts +658 -0
  109. package/src/engine/messaging/outbound-reply.ts +27 -0
  110. package/src/engine/messaging/outbound-result-helpers.ts +54 -0
  111. package/src/engine/messaging/outbound-types.ts +47 -0
  112. package/src/engine/messaging/outbound.ts +485 -0
  113. package/src/engine/messaging/reply-dispatcher.ts +597 -0
  114. package/src/engine/messaging/reply-limiter.ts +164 -0
  115. package/src/engine/messaging/sender.ts +741 -0
  116. package/src/engine/messaging/streaming-c2c.ts +1192 -0
  117. package/src/engine/messaging/streaming-media-send.ts +544 -0
  118. package/src/engine/messaging/target-parser.ts +104 -0
  119. package/src/engine/ref/format-message-ref.ts +142 -0
  120. package/src/engine/ref/format-ref-entry.ts +27 -0
  121. package/src/engine/ref/store.ts +211 -0
  122. package/src/engine/ref/types.ts +27 -0
  123. package/src/engine/session/known-users.ts +138 -0
  124. package/src/engine/session/session-store.ts +207 -0
  125. package/src/engine/tools/channel-api.ts +244 -0
  126. package/src/engine/tools/remind-logic.ts +377 -0
  127. package/src/engine/types.ts +313 -0
  128. package/src/engine/utils/attachment-tags.ts +174 -0
  129. package/src/engine/utils/audio.ts +525 -0
  130. package/src/engine/utils/data-paths.ts +38 -0
  131. package/src/engine/utils/diagnostics.ts +93 -0
  132. package/src/engine/utils/file-utils.ts +215 -0
  133. package/src/engine/utils/format.ts +70 -0
  134. package/src/engine/utils/image-size.ts +249 -0
  135. package/src/engine/utils/log.ts +77 -0
  136. package/src/engine/utils/media-tags.ts +177 -0
  137. package/src/engine/utils/payload.ts +157 -0
  138. package/src/engine/utils/platform.ts +265 -0
  139. package/src/engine/utils/request-context.ts +60 -0
  140. package/src/engine/utils/string-normalize.ts +91 -0
  141. package/src/engine/utils/stt.ts +103 -0
  142. package/src/engine/utils/text-parsing.ts +155 -0
  143. package/src/engine/utils/upload-cache.ts +96 -0
  144. package/src/engine/utils/voice-text.ts +15 -0
  145. package/src/exec-approvals.ts +237 -0
  146. package/src/qqbot-test-support.ts +29 -0
  147. package/src/secret-contract.ts +82 -0
  148. package/src/types.ts +210 -0
  149. package/tsconfig.json +16 -0
package/api.ts ADDED
@@ -0,0 +1,56 @@
1
+ export { qqbotPlugin } from "./src/channel.js";
2
+ export { qqbotSetupPlugin } from "./src/channel.setup.js";
3
+ export { getFrameworkCommands } from "./src/engine/commands/slash-commands-impl.js";
4
+ export { registerChannelTool } from "./src/bridge/tools/channel.js";
5
+ export { registerRemindTool } from "./src/bridge/tools/remind.js";
6
+ export { registerQQBotTools } from "./src/bridge/tools/index.js";
7
+ export { registerQQBotFull } from "./src/bridge/channel-entry.js";
8
+ export {
9
+ type AudioFormatPolicy,
10
+ type C2CMessageEvent,
11
+ type GroupMessageEvent,
12
+ type GuildMessageEvent,
13
+ type MessageAttachment,
14
+ type QQBotAccountConfig,
15
+ type QQBotConfig,
16
+ type QQBotDmPolicy,
17
+ type QQBotExecApprovalConfig,
18
+ type QQBotGroupPolicy,
19
+ type ResolvedQQBotAccount,
20
+ type WSPayload,
21
+ } from "./src/types.js";
22
+ export {
23
+ applyQQBotAccountConfig,
24
+ DEFAULT_ACCOUNT_ID,
25
+ listQQBotAccountIds,
26
+ resolveDefaultQQBotAccountId,
27
+ resolveQQBotAccount,
28
+ } from "./src/bridge/config.js";
29
+ export {
30
+ buildMediaTarget,
31
+ checkMessageReplyLimit,
32
+ DEFAULT_MEDIA_SEND_ERROR,
33
+ getMessageReplyConfig,
34
+ getMessageReplyStats,
35
+ type MediaOutboundContext,
36
+ type MediaTargetContext,
37
+ MESSAGE_REPLY_LIMIT,
38
+ OUTBOUND_ERROR_CODES,
39
+ type OutboundContext,
40
+ type OutboundErrorCode,
41
+ type OutboundResult,
42
+ parseTarget,
43
+ recordMessageReply,
44
+ type ReplyLimitResult,
45
+ resolveOutboundMediaPath,
46
+ resolveUserFacingMediaError,
47
+ sendCronMessage,
48
+ sendDocument,
49
+ sendMedia,
50
+ sendPhoto,
51
+ sendProactiveMessage,
52
+ sendText,
53
+ sendVideoMsg,
54
+ sendVoice,
55
+ setOutboundAudioPort,
56
+ } from "./src/engine/messaging/outbound.js";
@@ -0,0 +1,167 @@
1
+ {
2
+ "id": "qqbot",
3
+ "activation": {
4
+ "onStartup": false
5
+ },
6
+ "channels": ["qqbot"],
7
+ "contracts": {
8
+ "tools": ["qqbot_channel_api", "qqbot_remind"]
9
+ },
10
+ "channelEnvVars": {
11
+ "qqbot": ["QQBOT_APP_ID", "QQBOT_CLIENT_SECRET"]
12
+ },
13
+ "enabledByDefault": true,
14
+ "skills": ["./skills"],
15
+ "configSchema": {
16
+ "type": "object",
17
+ "additionalProperties": true,
18
+ "$defs": {
19
+ "audioFormatPolicy": {
20
+ "type": "object",
21
+ "additionalProperties": false,
22
+ "properties": {
23
+ "sttDirectFormats": {
24
+ "type": "array",
25
+ "items": { "type": "string" }
26
+ },
27
+ "uploadDirectFormats": {
28
+ "type": "array",
29
+ "items": { "type": "string" }
30
+ },
31
+ "transcodeEnabled": { "type": "boolean" }
32
+ }
33
+ },
34
+ "stt": {
35
+ "type": "object",
36
+ "additionalProperties": false,
37
+ "properties": {
38
+ "enabled": { "type": "boolean" },
39
+ "provider": { "type": "string" },
40
+ "baseUrl": { "type": "string" },
41
+ "apiKey": { "type": "string" },
42
+ "model": { "type": "string" }
43
+ }
44
+ },
45
+ "secretRef": {
46
+ "type": "object",
47
+ "additionalProperties": false,
48
+ "properties": {
49
+ "source": {
50
+ "type": "string",
51
+ "enum": ["env", "file", "exec"]
52
+ },
53
+ "provider": { "type": "string" },
54
+ "id": { "type": "string" }
55
+ },
56
+ "required": ["source", "provider", "id"]
57
+ },
58
+ "secretInput": {
59
+ "anyOf": [{ "type": "string", "minLength": 1 }, { "$ref": "#/$defs/secretRef" }]
60
+ },
61
+ "account": {
62
+ "type": "object",
63
+ "additionalProperties": true,
64
+ "properties": {
65
+ "enabled": { "type": "boolean" },
66
+ "name": { "type": "string" },
67
+ "appId": { "type": "string" },
68
+ "clientSecret": { "$ref": "#/$defs/secretInput" },
69
+ "clientSecretFile": { "type": "string" },
70
+ "allowFrom": {
71
+ "type": "array",
72
+ "items": { "type": "string" }
73
+ },
74
+ "systemPrompt": { "type": "string" },
75
+ "markdownSupport": { "type": "boolean" },
76
+ "voiceDirectUploadFormats": {
77
+ "type": "array",
78
+ "items": { "type": "string" }
79
+ },
80
+ "audioFormatPolicy": { "$ref": "#/$defs/audioFormatPolicy" },
81
+ "urlDirectUpload": { "type": "boolean" },
82
+ "upgradeUrl": { "type": "string" },
83
+ "upgradeMode": {
84
+ "type": "string",
85
+ "enum": ["doc", "hot-reload"]
86
+ },
87
+ "streaming": {
88
+ "anyOf": [
89
+ {
90
+ "type": "boolean"
91
+ },
92
+ {
93
+ "type": "object",
94
+ "additionalProperties": true,
95
+ "properties": {
96
+ "mode": {
97
+ "type": "string",
98
+ "enum": ["off", "partial"],
99
+ "default": "partial"
100
+ },
101
+ "c2cStreamApi": {
102
+ "type": "boolean",
103
+ "description": "Use QQ C2C official stream_messages API (single-message typing-style updates)."
104
+ }
105
+ }
106
+ }
107
+ ]
108
+ }
109
+ }
110
+ }
111
+ },
112
+ "properties": {
113
+ "enabled": { "type": "boolean" },
114
+ "name": { "type": "string" },
115
+ "appId": { "type": "string" },
116
+ "clientSecret": { "$ref": "#/$defs/secretInput" },
117
+ "clientSecretFile": { "type": "string" },
118
+ "allowFrom": {
119
+ "type": "array",
120
+ "items": { "type": "string" }
121
+ },
122
+ "systemPrompt": { "type": "string" },
123
+ "markdownSupport": { "type": "boolean" },
124
+ "voiceDirectUploadFormats": {
125
+ "type": "array",
126
+ "items": { "type": "string" }
127
+ },
128
+ "audioFormatPolicy": { "$ref": "#/$defs/audioFormatPolicy" },
129
+ "stt": { "$ref": "#/$defs/stt" },
130
+ "urlDirectUpload": { "type": "boolean" },
131
+ "upgradeUrl": { "type": "string" },
132
+ "upgradeMode": {
133
+ "type": "string",
134
+ "enum": ["doc", "hot-reload"]
135
+ },
136
+ "streaming": {
137
+ "anyOf": [
138
+ {
139
+ "type": "boolean"
140
+ },
141
+ {
142
+ "type": "object",
143
+ "additionalProperties": false,
144
+ "properties": {
145
+ "mode": {
146
+ "type": "string",
147
+ "enum": ["off", "partial"],
148
+ "default": "partial"
149
+ },
150
+ "c2cStreamApi": {
151
+ "type": "boolean",
152
+ "description": "Use QQ C2C official stream_messages API (single-message typing-style updates)."
153
+ }
154
+ }
155
+ }
156
+ ]
157
+ },
158
+ "accounts": {
159
+ "type": "object",
160
+ "additionalProperties": {
161
+ "$ref": "#/$defs/account"
162
+ }
163
+ },
164
+ "defaultAccount": { "type": "string" }
165
+ }
166
+ }
167
+ }
@@ -0,0 +1 @@
1
+ export { qqbotPlugin } from "./src/channel.js";
package/index.ts ADDED
@@ -0,0 +1,33 @@
1
+ import {
2
+ defineBundledChannelEntry,
3
+ loadBundledEntryExportSync,
4
+ type AutoBotPluginApi,
5
+ } from "autobot/plugin-sdk/channel-entry-contract";
6
+
7
+ function registerQQBotFull(api: AutoBotPluginApi): void {
8
+ const register = loadBundledEntryExportSync<(api: AutoBotPluginApi) => void>(import.meta.url, {
9
+ specifier: "./api.js",
10
+ exportName: "registerQQBotFull",
11
+ });
12
+ register(api);
13
+ }
14
+
15
+ export default defineBundledChannelEntry({
16
+ id: "qqbot",
17
+ name: "QQ Bot",
18
+ description: "QQ Bot channel plugin",
19
+ importMetaUrl: import.meta.url,
20
+ plugin: {
21
+ specifier: "./channel-plugin-api.js",
22
+ exportName: "qqbotPlugin",
23
+ },
24
+ secrets: {
25
+ specifier: "./secret-contract-api.js",
26
+ exportName: "channelSecrets",
27
+ },
28
+ runtime: {
29
+ specifier: "./runtime-api.js",
30
+ exportName: "setQQBotRuntime",
31
+ },
32
+ registerFull: registerQQBotFull,
33
+ });
package/package.json ADDED
@@ -0,0 +1,64 @@
1
+ {
2
+ "name": "@gakr-gakr/qqbot",
3
+ "version": "0.1.0",
4
+ "private": false,
5
+ "description": "AutoBot QQ Bot channel plugin",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "https://github.com/autobot/autobot"
9
+ },
10
+ "type": "module",
11
+ "dependencies": {
12
+ "@tencent-connect/qqbot-connector": "1.1.0",
13
+ "mpg123-decoder": "1.0.3",
14
+ "silk-wasm": "3.7.1",
15
+ "ws": "8.20.1",
16
+ "zod": "4.4.3"
17
+ },
18
+ "devDependencies": {
19
+ "@gakr-gakr/plugin-sdk": "workspace:*",
20
+ "@gakr-gakr/autobot": "workspace:*",
21
+ "@types/ws": "8.18.1",
22
+ "autobot": "workspace:@gakr-gakr/autobot@*"
23
+ },
24
+ "peerDependencies": {
25
+ "@gakr-gakr/autobot": ">=0.1.0"
26
+ },
27
+ "peerDependenciesMeta": {
28
+ "@gakr-gakr/autobot": {
29
+ "optional": true
30
+ }
31
+ },
32
+ "autobot": {
33
+ "extensions": [
34
+ "./index.ts"
35
+ ],
36
+ "setupEntry": "./setup-entry.ts",
37
+ "channel": {
38
+ "id": "qqbot",
39
+ "label": "QQ Bot",
40
+ "selectionLabel": "QQ Bot (Official API)",
41
+ "detailLabel": "QQ Bot",
42
+ "docsPath": "/channels/qqbot",
43
+ "docsLabel": "qqbot",
44
+ "blurb": "connect to QQ via official QQ Bot API with group chat and direct message support.",
45
+ "systemImage": "bubble.left.and.bubble.right"
46
+ },
47
+ "install": {
48
+ "npmSpec": "@gakr-gakr/qqbot",
49
+ "localPath": "extensions/qqbot",
50
+ "defaultChoice": "npm",
51
+ "minHostVersion": ">=2026.4.10"
52
+ },
53
+ "compat": {
54
+ "pluginApi": ">=2026.5.19"
55
+ },
56
+ "build": {
57
+ "autobotVersion": "2026.5.19"
58
+ },
59
+ "release": {
60
+ "publishToClawHub": true,
61
+ "publishToNpm": true
62
+ }
63
+ }
64
+ }
package/runtime-api.ts ADDED
@@ -0,0 +1,9 @@
1
+ export type { ChannelPlugin, AutoBotPluginApi, PluginRuntime } from "autobot/plugin-sdk/core";
2
+ export type { AutoBotConfig } from "autobot/plugin-sdk/config-contracts";
3
+ export type {
4
+ AutoBotPluginService,
5
+ AutoBotPluginServiceContext,
6
+ PluginLogger,
7
+ } from "autobot/plugin-sdk/core";
8
+ export type { ResolvedQQBotAccount, QQBotAccountConfig } from "./src/types.js";
9
+ export { getQQBotRuntime, setQQBotRuntime } from "./src/bridge/runtime.js";
@@ -0,0 +1,5 @@
1
+ export {
2
+ channelSecrets,
3
+ collectRuntimeConfigAssignments,
4
+ secretTargetRegistryEntries,
5
+ } from "./src/secret-contract.js";
package/setup-entry.ts ADDED
@@ -0,0 +1,13 @@
1
+ import { defineBundledChannelSetupEntry } from "autobot/plugin-sdk/channel-entry-contract";
2
+
3
+ export default defineBundledChannelSetupEntry({
4
+ importMetaUrl: import.meta.url,
5
+ plugin: {
6
+ specifier: "./setup-plugin-api.js",
7
+ exportName: "qqbotSetupPlugin",
8
+ },
9
+ secrets: {
10
+ specifier: "./secret-contract-api.js",
11
+ exportName: "channelSecrets",
12
+ },
13
+ });
@@ -0,0 +1,3 @@
1
+ // Keep bundled setup entry imports narrow so setup loads do not pull the
2
+ // broader QQ Bot runtime plugin surface.
3
+ export { qqbotSetupPlugin } from "./src/channel.setup.js";
@@ -0,0 +1,262 @@
1
+ ---
2
+ name: qqbot-channel
3
+ description: QQ channel management skill. Use qqbot_channel_api to list guilds and channels, inspect members, publish posts, manage announcements, and work with schedules through the QQ Open Platform HTTP API with automatic token authentication.
4
+ metadata: { "autobot": { "emoji": "📡", "requires": { "config": ["channels.qqbot"] } } }
5
+ ---
6
+
7
+ # QQ 频道 API 请求指导
8
+
9
+ `qqbot_channel_api` 是一个 QQ 开放平台 HTTP 代理工具,**自动填充鉴权 Token**。你只需要指定 HTTP 方法、API 路径、请求体和查询参数。
10
+
11
+ ## 📚 详细参考文档
12
+
13
+ 每个接口的完整参数说明、返回值结构和枚举值定义:
14
+
15
+ - `references/api_references.md`
16
+
17
+ ---
18
+
19
+ ## 🔧 工具参数
20
+
21
+ | 参数 | 类型 | 必填 | 说明 |
22
+ | -------- | ------ | ---- | ---------------------------------------------------------------------------- |
23
+ | `method` | string | 是 | HTTP 方法:`GET`, `POST`, `PUT`, `PATCH`, `DELETE` |
24
+ | `path` | string | 是 | API 路径(不含域名),如 `/guilds/{guild_id}/channels`,需替换占位符为实际值 |
25
+ | `body` | object | 否 | 请求体 JSON(POST/PUT/PATCH 使用) |
26
+ | `query` | object | 否 | URL 查询参数键值对,值为字符串类型 |
27
+
28
+ > 基础 URL:`https://api.sgroup.qq.com`,鉴权头 `Authorization: QQBot {token}` 由工具自动填充。
29
+
30
+ ---
31
+
32
+ ## ⭐ 接口速查
33
+
34
+ ### 频道(Guild)
35
+
36
+ | 操作 | 方法 | 路径 | 参数说明 |
37
+ | ----------------- | ----- | ----------------------------------- | ------------------------------------------ |
38
+ | 获取频道列表 | `GET` | `/users/@me/guilds` | query: `before`, `after`, `limit`(最大100) |
39
+ | 获取频道 API 权限 | `GET` | `/guilds/{guild_id}/api_permission` | — |
40
+
41
+ ### 子频道(Channel)
42
+
43
+ | 操作 | 方法 | 路径 | 参数说明 |
44
+ | -------------- | -------- | ----------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------- |
45
+ | 获取子频道列表 | `GET` | `/guilds/{guild_id}/channels` | — |
46
+ | 获取子频道详情 | `GET` | `/channels/{channel_id}` | — |
47
+ | 创建子频道 | `POST` | `/guilds/{guild_id}/channels` | body: `name`\*, `type`\*, `position`\*, `sub_type`, `parent_id`, `private_type`, `private_user_ids`, `speak_permission`, `application_id` |
48
+ | 修改子频道 | `PATCH` | `/channels/{channel_id}` | body: `name`, `position`, `parent_id`, `private_type`, `speak_permission`(至少一个) |
49
+ | 删除子频道 | `DELETE` | `/channels/{channel_id}` | ⚠️ 不可逆 |
50
+
51
+ **子频道类型(type)**:`0`=文字, `2`=语音, `4`=分组(position≥2), `10005`=直播, `10006`=应用, `10007`=论坛
52
+
53
+ ### 成员(Member)
54
+
55
+ | 操作 | 方法 | 路径 | 参数说明 |
56
+ | ------------------ | ----- | -------------------------------------------- | --------------------------------------------- |
57
+ | 获取成员列表 | `GET` | `/guilds/{guild_id}/members` | query: `after`(首次填0), `limit`(1-400) |
58
+ | 获取成员详情 | `GET` | `/guilds/{guild_id}/members/{user_id}` | — |
59
+ | 获取身份组成员列表 | `GET` | `/guilds/{guild_id}/roles/{role_id}/members` | query: `start_index`(首次填0), `limit`(1-400) |
60
+ | 获取在线成员数 | `GET` | `/channels/{channel_id}/online_nums` | — |
61
+
62
+ ### 公告(Announces)
63
+
64
+ | 操作 | 方法 | 路径 | 参数说明 |
65
+ | -------- | -------- | ------------------------------------------- | ------------------------------------------------------------------------------------------------ |
66
+ | 创建公告 | `POST` | `/guilds/{guild_id}/announces` | body: `message_id`, `channel_id`, `announces_type`(0=成员,1=欢迎), `recommend_channels`(最多3条) |
67
+ | 删除公告 | `DELETE` | `/guilds/{guild_id}/announces/{message_id}` | message_id 设 `all` 删除所有 |
68
+
69
+ ### 论坛(Forum)— 仅私域机器人
70
+
71
+ | 操作 | 方法 | 路径 | 参数说明 |
72
+ | ------------ | -------- | ---------------------------------------------------- | ------------------------------------------------------------------------------ |
73
+ | 获取帖子列表 | `GET` | `/channels/{channel_id}/threads` | — |
74
+ | 获取帖子详情 | `GET` | `/channels/{channel_id}/threads/{thread_id}` | — |
75
+ | 发表帖子 | `PUT` | `/channels/{channel_id}/threads` | body: `title`\*, `content`\*, `format`(1=文本,2=HTML,3=Markdown,4=JSON,默认3) |
76
+ | 删除帖子 | `DELETE` | `/channels/{channel_id}/threads/{thread_id}` | ⚠️ 不可逆 |
77
+ | 发表评论 | `POST` | `/channels/{channel_id}/threads/{thread_id}/comment` | body: `thread_author`\*, `content`\*, `thread_create_time`, `image` |
78
+
79
+ ### 日程(Schedule)
80
+
81
+ | 操作 | 方法 | 路径 | 参数说明 |
82
+ | -------- | -------- | ------------------------------------------------ | ----------------------------------------------------------------------------------------------- |
83
+ | 创建日程 | `POST` | `/channels/{channel_id}/schedules` | body: `{ schedule: { name*, start_timestamp*, end_timestamp*, jump_channel_id, remind_type } }` |
84
+ | 修改日程 | `PATCH` | `/channels/{channel_id}/schedules/{schedule_id}` | body: `{ schedule: { name*, start_timestamp*, end_timestamp*, jump_channel_id, remind_type } }` |
85
+ | 删除日程 | `DELETE` | `/channels/{channel_id}/schedules/{schedule_id}` | ⚠️ 不可逆 |
86
+
87
+ **提醒类型(remind_type)**:`"0"`=不提醒, `"1"`=开始时, `"2"`=5分钟前, `"3"`=15分钟前, `"4"`=30分钟前, `"5"`=60分钟前
88
+
89
+ > `*` 表示必填参数
90
+
91
+ ---
92
+
93
+ ## 💡 调用示例
94
+
95
+ ### 获取频道列表
96
+
97
+ ```json
98
+ {
99
+ "method": "GET",
100
+ "path": "/users/@me/guilds",
101
+ "query": { "limit": "100" }
102
+ }
103
+ ```
104
+
105
+ ### 获取子频道列表
106
+
107
+ ```json
108
+ {
109
+ "method": "GET",
110
+ "path": "/guilds/123456/channels"
111
+ }
112
+ ```
113
+
114
+ ### 创建子频道
115
+
116
+ ```json
117
+ {
118
+ "method": "POST",
119
+ "path": "/guilds/123456/channels",
120
+ "body": {
121
+ "name": "新频道",
122
+ "type": 0,
123
+ "position": 1,
124
+ "sub_type": 0
125
+ }
126
+ }
127
+ ```
128
+
129
+ ### 获取成员列表(分页)
130
+
131
+ ```json
132
+ {
133
+ "method": "GET",
134
+ "path": "/guilds/123456/members",
135
+ "query": { "after": "0", "limit": "100" }
136
+ }
137
+ ```
138
+
139
+ ### 发表论坛帖子
140
+
141
+ ```json
142
+ {
143
+ "method": "PUT",
144
+ "path": "/channels/789012/threads",
145
+ "body": {
146
+ "title": "公告标题",
147
+ "content": "# 标题\n\n公告内容",
148
+ "format": 3
149
+ }
150
+ }
151
+ ```
152
+
153
+ ### 创建日程
154
+
155
+ ```json
156
+ {
157
+ "method": "POST",
158
+ "path": "/channels/456789/schedules",
159
+ "body": {
160
+ "schedule": {
161
+ "name": "周会",
162
+ "start_timestamp": "1770733800000",
163
+ "end_timestamp": "1770737400000",
164
+ "remind_type": "2"
165
+ }
166
+ }
167
+ }
168
+ ```
169
+
170
+ ### 创建推荐子频道公告
171
+
172
+ ```json
173
+ {
174
+ "method": "POST",
175
+ "path": "/guilds/123456/announces",
176
+ "body": {
177
+ "announces_type": 0,
178
+ "recommend_channels": [{ "channel_id": "789012", "introduce": "欢迎来到攻略频道" }]
179
+ }
180
+ }
181
+ ```
182
+
183
+ ### 删除所有公告
184
+
185
+ ```json
186
+ {
187
+ "method": "DELETE",
188
+ "path": "/guilds/123456/announces/all"
189
+ }
190
+ ```
191
+
192
+ ---
193
+
194
+ ## 🔄 常用操作流程
195
+
196
+ ### 获取频道和子频道信息
197
+
198
+ ```
199
+ 1. GET /users/@me/guilds → 获取频道列表,拿到 guild_id
200
+ 2. GET /guilds/{guild_id}/channels → 获取子频道列表,拿到 channel_id
201
+ 3. GET /channels/{channel_id} → 获取子频道详情
202
+ ```
203
+
204
+ ### 论坛发帖 + 评论
205
+
206
+ ```
207
+ 1. GET /guilds/{guild_id}/channels → 找到论坛子频道(type=10007)
208
+ 2. PUT /channels/{channel_id}/threads → 发表帖子
209
+ 3. GET /channels/{channel_id}/threads → 获取帖子列表
210
+ 4. GET /channels/{channel_id}/threads/{thread_id} → 获取帖子详情(含 author_id)
211
+ 5. POST /channels/{channel_id}/threads/{thread_id}/comment → 发表评论
212
+ ```
213
+
214
+ ### 成员管理
215
+
216
+ ```
217
+ 1. GET /users/@me/guilds → 获取 guild_id
218
+ 2. GET /guilds/{guild_id}/members?after=0&limit=100 → 获取成员列表
219
+ 翻页:用上次最后一个 user.id 作为 after,直到返回空数组
220
+ 3. GET /guilds/{guild_id}/members/{user_id} → 获取指定成员详情
221
+ ```
222
+
223
+ ### 展示成员头像
224
+
225
+ 成员详情返回的 `user.avatar` 是头像 URL,**必须使用 Markdown 图片语法展示**,让用户直接看到头像图片,而非纯文本链接:
226
+
227
+ ```
228
+ 成员信息:
229
+ · 昵称:{nick}
230
+ · 头像:
231
+ ![头像]({user.avatar})
232
+ ```
233
+
234
+ > **禁止**将头像 URL 作为纯文本或超链接展示(如 `查看头像`),必须用 `![描述](URL)` 语法内联显示。频道的 `icon` 字段同理。
235
+
236
+ ---
237
+
238
+ ## 🚨 错误码处理
239
+
240
+ | 错误码 | 说明 | 解决方案 |
241
+ | ---------- | ---------------- | ------------------------------------------------------------------------------------- |
242
+ | **401** | Token 鉴权失败 | 检查 AppID 和 ClientSecret 配置 |
243
+ | **11241** | 频道 API 无权限 | 前往 QQ 开放平台申请权限,或调用 `GET /guilds/{guild_id}/api_permission` 查看可用权限 |
244
+ | **11242** | 仅私域机器人可用 | 需在 QQ 开放平台将机器人切换为私域模式 |
245
+ | **11243** | 需要管理频道权限 | 确保机器人拥有管理权限 |
246
+ | **11281** | 日程频率限制 | 单管理员/天限 10 次,单频道/天限 100 次 |
247
+ | **304023** | 推荐子频道超限 | 推荐子频道最多 3 条 |
248
+
249
+ ---
250
+
251
+ ## ⚠️ 注意事项
252
+
253
+ 1. **路径中的占位符**(如 `{guild_id}`、`{channel_id}`)必须替换为实际值
254
+ 2. **query 参数的值必须为字符串类型**,如 `{ "limit": "100" }` 而非 `{ "limit": 100 }`
255
+ 3. **成员列表翻页**时可能返回重复成员,需按 `user.id` 去重
256
+ 4. **公告**的两种类型(消息公告和推荐子频道公告)会互相顶替
257
+ 5. **日程**的时间戳为毫秒级字符串
258
+ 6. **删除操作不可逆**,请谨慎使用
259
+ 7. **论坛操作**仅私域机器人可用
260
+ 8. **子频道分组**(type=4)的 `position` 必须 >= 2
261
+ 9. **日程操作**有频率限制:单个管理员每天 10 次,单个频道每天 100 次
262
+ 10. **头像/图标展示**:成员 `user.avatar` 和频道 `icon` 等图片 URL 必须使用 Markdown 图片语法 `![描述](URL)` 展示,禁止作为纯文本或超链接展示