@tencent-connect/openclaw-qqbot 1.6.0-alpha.2 → 1.6.0-alpha.3
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/index.d.ts +17 -0
- package/dist/index.js +22 -0
- package/dist/src/api.d.ts +147 -0
- package/dist/src/api.js +583 -0
- package/dist/src/channel.d.ts +3 -0
- package/dist/src/channel.js +337 -0
- package/dist/src/config.d.ts +25 -0
- package/dist/src/config.js +161 -0
- package/dist/src/gateway.d.ts +18 -0
- package/dist/src/gateway.js +2579 -0
- package/dist/src/image-server.d.ts +68 -0
- package/dist/src/image-server.js +462 -0
- package/dist/src/known-users.d.ts +100 -0
- package/dist/src/known-users.js +263 -0
- package/dist/src/onboarding.d.ts +10 -0
- package/dist/src/onboarding.js +203 -0
- package/dist/src/outbound.d.ts +203 -0
- package/dist/src/outbound.js +1103 -0
- package/dist/src/proactive.d.ts +170 -0
- package/dist/src/proactive.js +399 -0
- package/dist/src/ref-index-store.d.ts +70 -0
- package/dist/src/ref-index-store.js +274 -0
- package/dist/src/runtime.d.ts +3 -0
- package/dist/src/runtime.js +10 -0
- package/dist/src/session-store.d.ts +52 -0
- package/dist/src/session-store.js +254 -0
- package/dist/src/slash-commands.d.ts +69 -0
- package/dist/src/slash-commands.js +233 -0
- package/dist/src/types.d.ts +169 -0
- package/dist/src/types.js +1 -0
- package/dist/src/update-checker.d.ts +21 -0
- package/dist/src/update-checker.js +116 -0
- package/dist/src/user-messages.d.ts +43 -0
- package/dist/src/user-messages.js +65 -0
- package/dist/src/utils/audio-convert.d.ts +89 -0
- package/dist/src/utils/audio-convert.js +704 -0
- package/dist/src/utils/file-utils.d.ts +46 -0
- package/dist/src/utils/file-utils.js +107 -0
- package/dist/src/utils/image-size.d.ts +51 -0
- package/dist/src/utils/image-size.js +234 -0
- package/dist/src/utils/media-tags.d.ts +14 -0
- package/dist/src/utils/media-tags.js +158 -0
- package/dist/src/utils/payload.d.ts +112 -0
- package/dist/src/utils/payload.js +186 -0
- package/dist/src/utils/platform.d.ts +127 -0
- package/dist/src/utils/platform.js +374 -0
- package/dist/src/utils/upload-cache.d.ts +34 -0
- package/dist/src/utils/upload-cache.js +93 -0
- package/package.json +1 -1
- package/scripts/upgrade-via-source.sh +16 -20
- package/src/gateway.ts +17 -1
- package/src/slash-commands.ts +37 -151
- package/src/update-checker.ts +45 -15
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";
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { emptyPluginConfigSchema } from "openclaw/plugin-sdk";
|
|
2
|
+
import { qqbotPlugin } from "./src/channel.js";
|
|
3
|
+
import { setQQBotRuntime } from "./src/runtime.js";
|
|
4
|
+
const plugin = {
|
|
5
|
+
id: "openclaw-qqbot",
|
|
6
|
+
name: "QQ Bot",
|
|
7
|
+
description: "QQ Bot channel plugin",
|
|
8
|
+
configSchema: emptyPluginConfigSchema(),
|
|
9
|
+
register(api) {
|
|
10
|
+
setQQBotRuntime(api.runtime);
|
|
11
|
+
api.registerChannel({ plugin: qqbotPlugin });
|
|
12
|
+
},
|
|
13
|
+
};
|
|
14
|
+
export default plugin;
|
|
15
|
+
export { qqbotPlugin } from "./src/channel.js";
|
|
16
|
+
export { setQQBotRuntime, getQQBotRuntime } from "./src/runtime.js";
|
|
17
|
+
export { qqbotOnboardingAdapter } from "./src/onboarding.js";
|
|
18
|
+
export * from "./src/types.js";
|
|
19
|
+
export * from "./src/api.js";
|
|
20
|
+
export * from "./src/config.js";
|
|
21
|
+
export * from "./src/gateway.js";
|
|
22
|
+
export * from "./src/outbound.js";
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* QQ Bot API 鉴权和请求封装
|
|
3
|
+
* [修复版] 已重构为支持多实例并发,消除全局变量冲突
|
|
4
|
+
*/
|
|
5
|
+
export declare const PLUGIN_USER_AGENT: string;
|
|
6
|
+
/** 出站消息元信息(结构化存储,不做预格式化) */
|
|
7
|
+
export interface OutboundMeta {
|
|
8
|
+
/** 消息文本内容 */
|
|
9
|
+
text?: string;
|
|
10
|
+
/** 媒体类型 */
|
|
11
|
+
mediaType?: "image" | "voice" | "video" | "file";
|
|
12
|
+
/** 媒体来源:在线 URL */
|
|
13
|
+
mediaUrl?: string;
|
|
14
|
+
/** 媒体来源:本地文件路径或文件名 */
|
|
15
|
+
mediaLocalPath?: string;
|
|
16
|
+
/** TTS 原文本(仅 voice 类型有效,用于保存 TTS 前的文本内容) */
|
|
17
|
+
ttsText?: string;
|
|
18
|
+
}
|
|
19
|
+
type OnMessageSentCallback = (refIdx: string, meta: OutboundMeta) => void;
|
|
20
|
+
/**
|
|
21
|
+
* 注册出站消息回调
|
|
22
|
+
* 当消息发送成功且 QQ 返回 ref_idx 时,自动回调此函数
|
|
23
|
+
* 用于在最底层统一缓存 bot 出站消息的 refIdx
|
|
24
|
+
*/
|
|
25
|
+
export declare function onMessageSent(callback: OnMessageSentCallback): void;
|
|
26
|
+
/**
|
|
27
|
+
* 初始化 API 配置
|
|
28
|
+
* @param options.markdownSupport - 是否支持 markdown 消息(默认 false,需要机器人具备该权限才能启用)
|
|
29
|
+
*/
|
|
30
|
+
export declare function initApiConfig(options: {
|
|
31
|
+
markdownSupport?: boolean;
|
|
32
|
+
}): void;
|
|
33
|
+
/**
|
|
34
|
+
* 获取当前是否支持 markdown
|
|
35
|
+
*/
|
|
36
|
+
export declare function isMarkdownSupport(): boolean;
|
|
37
|
+
/**
|
|
38
|
+
* 获取 AccessToken(带缓存 + singleflight 并发安全)
|
|
39
|
+
*
|
|
40
|
+
* 使用 singleflight 模式:当多个请求同时发现 Token 过期时,
|
|
41
|
+
* 只有第一个请求会真正去获取新 Token,其他请求复用同一个 Promise。
|
|
42
|
+
*
|
|
43
|
+
* 按 appId 隔离,支持多机器人并发请求。
|
|
44
|
+
*/
|
|
45
|
+
export declare function getAccessToken(appId: string, clientSecret: string): Promise<string>;
|
|
46
|
+
/**
|
|
47
|
+
* 清除 Token 缓存
|
|
48
|
+
* @param appId 选填。如果有,只清空特定账号的缓存;如果没有,清空所有账号。
|
|
49
|
+
*/
|
|
50
|
+
export declare function clearTokenCache(appId?: string): void;
|
|
51
|
+
/**
|
|
52
|
+
* 获取 Token 缓存状态(用于监控)
|
|
53
|
+
*/
|
|
54
|
+
export declare function getTokenStatus(appId: string): {
|
|
55
|
+
status: "valid" | "expired" | "refreshing" | "none";
|
|
56
|
+
expiresAt: number | null;
|
|
57
|
+
};
|
|
58
|
+
/**
|
|
59
|
+
* 获取全局唯一的消息序号(范围 0 ~ 65535)
|
|
60
|
+
* 使用毫秒级时间戳低位 + 随机数异或混合,无状态,避免碰撞
|
|
61
|
+
*/
|
|
62
|
+
export declare function getNextMsgSeq(_msgId: string): number;
|
|
63
|
+
/**
|
|
64
|
+
* API 请求封装
|
|
65
|
+
*/
|
|
66
|
+
export declare function apiRequest<T = unknown>(accessToken: string, method: string, path: string, body?: unknown, timeoutMs?: number): Promise<T>;
|
|
67
|
+
export declare function getGatewayUrl(accessToken: string): Promise<string>;
|
|
68
|
+
export interface MessageResponse {
|
|
69
|
+
id: string;
|
|
70
|
+
timestamp: number | string;
|
|
71
|
+
/** 消息的引用索引信息(出站时由 QQ 服务端返回) */
|
|
72
|
+
ext_info?: {
|
|
73
|
+
ref_idx?: string;
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
export declare function sendC2CMessage(accessToken: string, openid: string, content: string, msgId?: string, messageReference?: string): Promise<MessageResponse>;
|
|
77
|
+
export declare function sendC2CInputNotify(accessToken: string, openid: string, msgId?: string, inputSecond?: number): Promise<{
|
|
78
|
+
refIdx?: string;
|
|
79
|
+
}>;
|
|
80
|
+
export declare function sendChannelMessage(accessToken: string, channelId: string, content: string, msgId?: string): Promise<{
|
|
81
|
+
id: string;
|
|
82
|
+
timestamp: string;
|
|
83
|
+
}>;
|
|
84
|
+
export declare function sendGroupMessage(accessToken: string, groupOpenid: string, content: string, msgId?: string): Promise<MessageResponse>;
|
|
85
|
+
export declare function sendProactiveC2CMessage(accessToken: string, openid: string, content: string): Promise<MessageResponse>;
|
|
86
|
+
export declare function sendProactiveGroupMessage(accessToken: string, groupOpenid: string, content: string): Promise<{
|
|
87
|
+
id: string;
|
|
88
|
+
timestamp: string;
|
|
89
|
+
}>;
|
|
90
|
+
export declare enum MediaFileType {
|
|
91
|
+
IMAGE = 1,
|
|
92
|
+
VIDEO = 2,
|
|
93
|
+
VOICE = 3,
|
|
94
|
+
FILE = 4
|
|
95
|
+
}
|
|
96
|
+
export interface UploadMediaResponse {
|
|
97
|
+
file_uuid: string;
|
|
98
|
+
file_info: string;
|
|
99
|
+
ttl: number;
|
|
100
|
+
id?: string;
|
|
101
|
+
}
|
|
102
|
+
export declare function uploadC2CMedia(accessToken: string, openid: string, fileType: MediaFileType, url?: string, fileData?: string, srvSendMsg?: boolean, fileName?: string): Promise<UploadMediaResponse>;
|
|
103
|
+
export declare function uploadGroupMedia(accessToken: string, groupOpenid: string, fileType: MediaFileType, url?: string, fileData?: string, srvSendMsg?: boolean, fileName?: string): Promise<UploadMediaResponse>;
|
|
104
|
+
export declare function sendC2CMediaMessage(accessToken: string, openid: string, fileInfo: string, msgId?: string, content?: string, meta?: OutboundMeta): Promise<MessageResponse>;
|
|
105
|
+
export declare function sendGroupMediaMessage(accessToken: string, groupOpenid: string, fileInfo: string, msgId?: string, content?: string): Promise<{
|
|
106
|
+
id: string;
|
|
107
|
+
timestamp: string;
|
|
108
|
+
}>;
|
|
109
|
+
export declare function sendC2CImageMessage(accessToken: string, openid: string, imageUrl: string, msgId?: string, content?: string, localPath?: string): Promise<MessageResponse>;
|
|
110
|
+
export declare function sendGroupImageMessage(accessToken: string, groupOpenid: string, imageUrl: string, msgId?: string, content?: string): Promise<{
|
|
111
|
+
id: string;
|
|
112
|
+
timestamp: string;
|
|
113
|
+
}>;
|
|
114
|
+
export declare function sendC2CVoiceMessage(accessToken: string, openid: string, voiceBase64?: string, voiceUrl?: string, msgId?: string, ttsText?: string, filePath?: string): Promise<MessageResponse>;
|
|
115
|
+
export declare function sendGroupVoiceMessage(accessToken: string, groupOpenid: string, voiceBase64?: string, voiceUrl?: string, msgId?: string): Promise<{
|
|
116
|
+
id: string;
|
|
117
|
+
timestamp: string;
|
|
118
|
+
}>;
|
|
119
|
+
export declare function sendC2CFileMessage(accessToken: string, openid: string, fileBase64?: string, fileUrl?: string, msgId?: string, fileName?: string, localFilePath?: string): Promise<MessageResponse>;
|
|
120
|
+
export declare function sendGroupFileMessage(accessToken: string, groupOpenid: string, fileBase64?: string, fileUrl?: string, msgId?: string, fileName?: string): Promise<{
|
|
121
|
+
id: string;
|
|
122
|
+
timestamp: string;
|
|
123
|
+
}>;
|
|
124
|
+
export declare function sendC2CVideoMessage(accessToken: string, openid: string, videoUrl?: string, videoBase64?: string, msgId?: string, content?: string, localPath?: string): Promise<MessageResponse>;
|
|
125
|
+
export declare function sendGroupVideoMessage(accessToken: string, groupOpenid: string, videoUrl?: string, videoBase64?: string, msgId?: string, content?: string): Promise<{
|
|
126
|
+
id: string;
|
|
127
|
+
timestamp: string;
|
|
128
|
+
}>;
|
|
129
|
+
interface BackgroundTokenRefreshOptions {
|
|
130
|
+
refreshAheadMs?: number;
|
|
131
|
+
randomOffsetMs?: number;
|
|
132
|
+
minRefreshIntervalMs?: number;
|
|
133
|
+
retryDelayMs?: number;
|
|
134
|
+
log?: {
|
|
135
|
+
info: (msg: string) => void;
|
|
136
|
+
error: (msg: string) => void;
|
|
137
|
+
debug?: (msg: string) => void;
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
export declare function startBackgroundTokenRefresh(appId: string, clientSecret: string, options?: BackgroundTokenRefreshOptions): void;
|
|
141
|
+
/**
|
|
142
|
+
* 停止后台 Token 刷新
|
|
143
|
+
* @param appId 选填。如果有,仅停止该账号的定时刷新。
|
|
144
|
+
*/
|
|
145
|
+
export declare function stopBackgroundTokenRefresh(appId?: string): void;
|
|
146
|
+
export declare function isBackgroundTokenRefreshRunning(appId?: string): boolean;
|
|
147
|
+
export {};
|