@sliverp/qqbot 1.3.5 → 1.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/bin/qqbot-cli.js +2 -2
- package/clawdbot.plugin.json +16 -0
- package/dist/index.d.ts +17 -0
- package/dist/src/api.d.ts +194 -0
- package/dist/src/api.js +555 -0
- package/dist/src/channel.d.ts +3 -0
- package/dist/src/channel.js +146 -0
- package/dist/src/config.d.ts +25 -0
- package/dist/src/config.js +148 -0
- package/dist/src/gateway.d.ts +17 -0
- package/dist/src/gateway.js +722 -0
- package/dist/src/image-server.d.ts +62 -0
- package/dist/src/image-server.js +401 -0
- package/dist/src/known-users.d.ts +100 -0
- package/dist/src/known-users.js +264 -0
- package/dist/src/onboarding.d.ts +10 -0
- package/dist/src/onboarding.js +190 -0
- package/dist/src/outbound.d.ts +149 -0
- package/dist/src/outbound.js +476 -0
- package/dist/src/proactive.d.ts +170 -0
- package/dist/src/proactive.js +398 -0
- package/dist/src/runtime.d.ts +3 -0
- package/dist/src/runtime.js +10 -0
- package/dist/src/session-store.d.ts +49 -0
- package/dist/src/session-store.js +242 -0
- package/dist/src/types.d.ts +116 -0
- package/dist/src/types.js +1 -0
- package/dist/src/utils/image-size.d.ts +51 -0
- package/dist/src/utils/image-size.js +234 -0
- package/dist/src/utils/payload.d.ts +112 -0
- package/dist/src/utils/payload.js +186 -0
- package/moltbot.plugin.json +16 -0
- package/openclaw.plugin.json +16 -0
- package/package.json +5 -4
package/bin/qqbot-cli.js
CHANGED
|
@@ -164,8 +164,8 @@ function upgrade() {
|
|
|
164
164
|
}
|
|
165
165
|
|
|
166
166
|
console.log('\n=== 升级完成 ===');
|
|
167
|
-
console.log(`\n
|
|
168
|
-
console.log(` ${foundInstallation} gateway --verbose`);
|
|
167
|
+
console.log(`\n可以运行以下命令前台运行启动机器人:`);
|
|
168
|
+
console.log(` ${foundInstallation} gateway stop && ${foundInstallation} gateway --port 18789 --verbose`);
|
|
169
169
|
}
|
|
170
170
|
|
|
171
171
|
// 安装命令
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"id": "qqbot",
|
|
3
|
+
"name": "QQ Bot Channel",
|
|
4
|
+
"description": "QQ Bot channel plugin with message support, cron jobs, and proactive messaging",
|
|
5
|
+
"channels": ["qqbot"],
|
|
6
|
+
"skills": ["skills/qqbot-cron", "skills/qqbot-media"],
|
|
7
|
+
"capabilities": {
|
|
8
|
+
"proactiveMessaging": true,
|
|
9
|
+
"cronJobs": true
|
|
10
|
+
},
|
|
11
|
+
"configSchema": {
|
|
12
|
+
"type": "object",
|
|
13
|
+
"additionalProperties": false,
|
|
14
|
+
"properties": {}
|
|
15
|
+
}
|
|
16
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { OpenClawPluginApi } from "openclaw/plugin-sdk";
|
|
2
|
+
declare const plugin: {
|
|
3
|
+
id: string;
|
|
4
|
+
name: string;
|
|
5
|
+
description: string;
|
|
6
|
+
configSchema: unknown;
|
|
7
|
+
register(api: OpenClawPluginApi): void;
|
|
8
|
+
};
|
|
9
|
+
export default plugin;
|
|
10
|
+
export { qqbotPlugin } from "./src/channel.js";
|
|
11
|
+
export { setQQBotRuntime, getQQBotRuntime } from "./src/runtime.js";
|
|
12
|
+
export { qqbotOnboardingAdapter } from "./src/onboarding.js";
|
|
13
|
+
export * from "./src/types.js";
|
|
14
|
+
export * from "./src/api.js";
|
|
15
|
+
export * from "./src/config.js";
|
|
16
|
+
export * from "./src/gateway.js";
|
|
17
|
+
export * from "./src/outbound.js";
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* QQ Bot API 鉴权和请求封装
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* 初始化 API 配置
|
|
6
|
+
* @param options.markdownSupport - 是否支持 markdown 消息(默认 false,需要机器人具备该权限才能启用)
|
|
7
|
+
*/
|
|
8
|
+
export declare function initApiConfig(options: {
|
|
9
|
+
markdownSupport?: boolean;
|
|
10
|
+
}): void;
|
|
11
|
+
/**
|
|
12
|
+
* 获取当前是否支持 markdown
|
|
13
|
+
*/
|
|
14
|
+
export declare function isMarkdownSupport(): boolean;
|
|
15
|
+
/**
|
|
16
|
+
* 获取 AccessToken(带缓存 + singleflight 并发安全)
|
|
17
|
+
*
|
|
18
|
+
* 使用 singleflight 模式:当多个请求同时发现 Token 过期时,
|
|
19
|
+
* 只有第一个请求会真正去获取新 Token,其他请求复用同一个 Promise。
|
|
20
|
+
*/
|
|
21
|
+
export declare function getAccessToken(appId: string, clientSecret: string): Promise<string>;
|
|
22
|
+
/**
|
|
23
|
+
* 清除 Token 缓存
|
|
24
|
+
*/
|
|
25
|
+
export declare function clearTokenCache(): void;
|
|
26
|
+
/**
|
|
27
|
+
* 获取 Token 缓存状态(用于监控)
|
|
28
|
+
*/
|
|
29
|
+
export declare function getTokenStatus(): {
|
|
30
|
+
status: "valid" | "expired" | "refreshing" | "none";
|
|
31
|
+
expiresAt: number | null;
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* 获取并递增消息序号
|
|
35
|
+
* 返回的 seq 会基于时间戳,避免进程重启后重复
|
|
36
|
+
*/
|
|
37
|
+
export declare function getNextMsgSeq(msgId: string): number;
|
|
38
|
+
/**
|
|
39
|
+
* API 请求封装
|
|
40
|
+
*/
|
|
41
|
+
export declare function apiRequest<T = unknown>(accessToken: string, method: string, path: string, body?: unknown): Promise<T>;
|
|
42
|
+
/**
|
|
43
|
+
* 获取 WebSocket Gateway URL
|
|
44
|
+
*/
|
|
45
|
+
export declare function getGatewayUrl(accessToken: string): Promise<string>;
|
|
46
|
+
/**
|
|
47
|
+
* 消息响应
|
|
48
|
+
*/
|
|
49
|
+
export interface MessageResponse {
|
|
50
|
+
id: string;
|
|
51
|
+
timestamp: number | string;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* 发送 C2C 单聊消息
|
|
55
|
+
*/
|
|
56
|
+
export declare function sendC2CMessage(accessToken: string, openid: string, content: string, msgId?: string): Promise<MessageResponse>;
|
|
57
|
+
/**
|
|
58
|
+
* 发送 C2C 输入状态提示(告知用户机器人正在输入)
|
|
59
|
+
*/
|
|
60
|
+
export declare function sendC2CInputNotify(accessToken: string, openid: string, msgId?: string, inputSecond?: number): Promise<void>;
|
|
61
|
+
/**
|
|
62
|
+
* 发送频道消息(不支持流式)
|
|
63
|
+
*/
|
|
64
|
+
export declare function sendChannelMessage(accessToken: string, channelId: string, content: string, msgId?: string): Promise<{
|
|
65
|
+
id: string;
|
|
66
|
+
timestamp: string;
|
|
67
|
+
}>;
|
|
68
|
+
/**
|
|
69
|
+
* 发送群聊消息
|
|
70
|
+
*/
|
|
71
|
+
export declare function sendGroupMessage(accessToken: string, groupOpenid: string, content: string, msgId?: string): Promise<MessageResponse>;
|
|
72
|
+
/**
|
|
73
|
+
* 主动发送 C2C 单聊消息(不需要 msg_id,每月限 4 条/用户)
|
|
74
|
+
*
|
|
75
|
+
* 注意:
|
|
76
|
+
* 1. 内容不能为空(对应 markdown.content 字段)
|
|
77
|
+
* 2. 不支持流式发送
|
|
78
|
+
*/
|
|
79
|
+
export declare function sendProactiveC2CMessage(accessToken: string, openid: string, content: string): Promise<{
|
|
80
|
+
id: string;
|
|
81
|
+
timestamp: number;
|
|
82
|
+
}>;
|
|
83
|
+
/**
|
|
84
|
+
* 主动发送群聊消息(不需要 msg_id,每月限 4 条/群)
|
|
85
|
+
*
|
|
86
|
+
* 注意:
|
|
87
|
+
* 1. 内容不能为空(对应 markdown.content 字段)
|
|
88
|
+
* 2. 不支持流式发送
|
|
89
|
+
*/
|
|
90
|
+
export declare function sendProactiveGroupMessage(accessToken: string, groupOpenid: string, content: string): Promise<{
|
|
91
|
+
id: string;
|
|
92
|
+
timestamp: string;
|
|
93
|
+
}>;
|
|
94
|
+
/**
|
|
95
|
+
* 媒体文件类型
|
|
96
|
+
*/
|
|
97
|
+
export declare enum MediaFileType {
|
|
98
|
+
IMAGE = 1,
|
|
99
|
+
VIDEO = 2,
|
|
100
|
+
VOICE = 3,
|
|
101
|
+
FILE = 4
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* 上传富媒体文件的响应
|
|
105
|
+
*/
|
|
106
|
+
export interface UploadMediaResponse {
|
|
107
|
+
file_uuid: string;
|
|
108
|
+
file_info: string;
|
|
109
|
+
ttl: number;
|
|
110
|
+
id?: string;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* 上传富媒体文件到 C2C 单聊
|
|
114
|
+
* @param url - 公网可访问的图片 URL(与 fileData 二选一)
|
|
115
|
+
* @param fileData - Base64 编码的文件内容(与 url 二选一)
|
|
116
|
+
*/
|
|
117
|
+
export declare function uploadC2CMedia(accessToken: string, openid: string, fileType: MediaFileType, url?: string, fileData?: string, srvSendMsg?: boolean): Promise<UploadMediaResponse>;
|
|
118
|
+
/**
|
|
119
|
+
* 上传富媒体文件到群聊
|
|
120
|
+
* @param url - 公网可访问的图片 URL(与 fileData 二选一)
|
|
121
|
+
* @param fileData - Base64 编码的文件内容(与 url 二选一)
|
|
122
|
+
*/
|
|
123
|
+
export declare function uploadGroupMedia(accessToken: string, groupOpenid: string, fileType: MediaFileType, url?: string, fileData?: string, srvSendMsg?: boolean): Promise<UploadMediaResponse>;
|
|
124
|
+
/**
|
|
125
|
+
* 发送 C2C 单聊富媒体消息
|
|
126
|
+
*/
|
|
127
|
+
export declare function sendC2CMediaMessage(accessToken: string, openid: string, fileInfo: string, msgId?: string, content?: string): Promise<{
|
|
128
|
+
id: string;
|
|
129
|
+
timestamp: number;
|
|
130
|
+
}>;
|
|
131
|
+
/**
|
|
132
|
+
* 发送群聊富媒体消息
|
|
133
|
+
*/
|
|
134
|
+
export declare function sendGroupMediaMessage(accessToken: string, groupOpenid: string, fileInfo: string, msgId?: string, content?: string): Promise<{
|
|
135
|
+
id: string;
|
|
136
|
+
timestamp: string;
|
|
137
|
+
}>;
|
|
138
|
+
/**
|
|
139
|
+
* 发送带图片的 C2C 单聊消息(封装上传+发送)
|
|
140
|
+
* @param imageUrl - 图片来源,支持:
|
|
141
|
+
* - 公网 URL: https://example.com/image.png
|
|
142
|
+
* - Base64 Data URL: data:image/png;base64,xxxxx
|
|
143
|
+
*/
|
|
144
|
+
export declare function sendC2CImageMessage(accessToken: string, openid: string, imageUrl: string, msgId?: string, content?: string): Promise<{
|
|
145
|
+
id: string;
|
|
146
|
+
timestamp: number;
|
|
147
|
+
}>;
|
|
148
|
+
/**
|
|
149
|
+
* 发送带图片的群聊消息(封装上传+发送)
|
|
150
|
+
* @param imageUrl - 图片来源,支持:
|
|
151
|
+
* - 公网 URL: https://example.com/image.png
|
|
152
|
+
* - Base64 Data URL: data:image/png;base64,xxxxx
|
|
153
|
+
*/
|
|
154
|
+
export declare function sendGroupImageMessage(accessToken: string, groupOpenid: string, imageUrl: string, msgId?: string, content?: string): Promise<{
|
|
155
|
+
id: string;
|
|
156
|
+
timestamp: string;
|
|
157
|
+
}>;
|
|
158
|
+
/**
|
|
159
|
+
* 后台 Token 刷新配置
|
|
160
|
+
*/
|
|
161
|
+
interface BackgroundTokenRefreshOptions {
|
|
162
|
+
/** 提前刷新时间(毫秒,默认 5 分钟) */
|
|
163
|
+
refreshAheadMs?: number;
|
|
164
|
+
/** 随机偏移范围(毫秒,默认 0-30 秒) */
|
|
165
|
+
randomOffsetMs?: number;
|
|
166
|
+
/** 最小刷新间隔(毫秒,默认 1 分钟) */
|
|
167
|
+
minRefreshIntervalMs?: number;
|
|
168
|
+
/** 失败后重试间隔(毫秒,默认 5 秒) */
|
|
169
|
+
retryDelayMs?: number;
|
|
170
|
+
/** 日志函数 */
|
|
171
|
+
log?: {
|
|
172
|
+
info: (msg: string) => void;
|
|
173
|
+
error: (msg: string) => void;
|
|
174
|
+
debug?: (msg: string) => void;
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* 启动后台 Token 刷新
|
|
179
|
+
* 在后台定时刷新 Token,避免请求时才发现过期
|
|
180
|
+
*
|
|
181
|
+
* @param appId 应用 ID
|
|
182
|
+
* @param clientSecret 应用密钥
|
|
183
|
+
* @param options 配置选项
|
|
184
|
+
*/
|
|
185
|
+
export declare function startBackgroundTokenRefresh(appId: string, clientSecret: string, options?: BackgroundTokenRefreshOptions): void;
|
|
186
|
+
/**
|
|
187
|
+
* 停止后台 Token 刷新
|
|
188
|
+
*/
|
|
189
|
+
export declare function stopBackgroundTokenRefresh(): void;
|
|
190
|
+
/**
|
|
191
|
+
* 检查后台 Token 刷新是否正在运行
|
|
192
|
+
*/
|
|
193
|
+
export declare function isBackgroundTokenRefreshRunning(): boolean;
|
|
194
|
+
export {};
|