@sliverp/qqbot 1.3.1 → 1.3.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/bin/qqbot-cli.js +227 -0
- package/package.json +10 -1
- package/clawdbot.plugin.json +0 -16
- package/dist/index.d.ts +0 -17
- package/dist/src/api.d.ts +0 -194
- package/dist/src/api.js +0 -555
- package/dist/src/channel.d.ts +0 -3
- package/dist/src/channel.js +0 -146
- package/dist/src/config.d.ts +0 -25
- package/dist/src/config.js +0 -148
- package/dist/src/gateway.d.ts +0 -17
- package/dist/src/gateway.js +0 -722
- package/dist/src/image-server.d.ts +0 -62
- package/dist/src/image-server.js +0 -401
- package/dist/src/known-users.d.ts +0 -100
- package/dist/src/known-users.js +0 -264
- package/dist/src/onboarding.d.ts +0 -10
- package/dist/src/onboarding.js +0 -190
- package/dist/src/outbound.d.ts +0 -149
- package/dist/src/outbound.js +0 -476
- package/dist/src/proactive.d.ts +0 -170
- package/dist/src/proactive.js +0 -398
- package/dist/src/runtime.d.ts +0 -3
- package/dist/src/runtime.js +0 -10
- package/dist/src/session-store.d.ts +0 -49
- package/dist/src/session-store.js +0 -242
- package/dist/src/types.d.ts +0 -116
- package/dist/src/types.js +0 -1
- package/dist/src/utils/image-size.d.ts +0 -51
- package/dist/src/utils/image-size.js +0 -234
- package/dist/src/utils/payload.d.ts +0 -112
- package/dist/src/utils/payload.js +0 -186
- package/moltbot.plugin.json +0 -16
- package/openclaw.plugin.json +0 -16
- package/qqbot-1.3.0.tgz +0 -0
- package/scripts/proactive-api-server.ts +0 -346
- package/scripts/send-proactive.ts +0 -273
- package/scripts/upgrade.sh +0 -106
- package/skills/qqbot-cron/SKILL.md +0 -490
- package/skills/qqbot-media/SKILL.md +0 -138
- package/upgrade-and-run.sh +0 -89
package/bin/qqbot-cli.js
ADDED
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* QQBot CLI - 用于升级和管理 QQBot 插件
|
|
5
|
+
*
|
|
6
|
+
* 用法:
|
|
7
|
+
* npx @sliverp/qqbot upgrade # 升级插件
|
|
8
|
+
* npx @sliverp/qqbot install # 安装插件
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import { execSync } from 'child_process';
|
|
12
|
+
import { existsSync, readFileSync, writeFileSync, rmSync } from 'fs';
|
|
13
|
+
import { homedir } from 'os';
|
|
14
|
+
import { join, dirname } from 'path';
|
|
15
|
+
import { fileURLToPath } from 'url';
|
|
16
|
+
|
|
17
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
18
|
+
const __dirname = dirname(__filename);
|
|
19
|
+
|
|
20
|
+
// 获取包的根目录
|
|
21
|
+
const PKG_ROOT = join(__dirname, '..');
|
|
22
|
+
|
|
23
|
+
const args = process.argv.slice(2);
|
|
24
|
+
const command = args[0];
|
|
25
|
+
|
|
26
|
+
// 检测使用的是 clawdbot 还是 openclaw
|
|
27
|
+
function detectInstallation() {
|
|
28
|
+
const home = homedir();
|
|
29
|
+
if (existsSync(join(home, '.openclaw'))) {
|
|
30
|
+
return 'openclaw';
|
|
31
|
+
}
|
|
32
|
+
if (existsSync(join(home, '.clawdbot'))) {
|
|
33
|
+
return 'clawdbot';
|
|
34
|
+
}
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// 清理旧版本插件,返回旧的 qqbot 配置
|
|
39
|
+
function cleanupInstallation(appName) {
|
|
40
|
+
const home = homedir();
|
|
41
|
+
const appDir = join(home, `.${appName}`);
|
|
42
|
+
const configFile = join(appDir, `${appName}.json`);
|
|
43
|
+
const extensionDir = join(appDir, 'extensions', 'qqbot');
|
|
44
|
+
|
|
45
|
+
let oldQqbotConfig = null;
|
|
46
|
+
|
|
47
|
+
console.log(`\n>>> 处理 ${appName} 安装...`);
|
|
48
|
+
|
|
49
|
+
// 1. 先读取旧的 qqbot 配置
|
|
50
|
+
if (existsSync(configFile)) {
|
|
51
|
+
try {
|
|
52
|
+
const config = JSON.parse(readFileSync(configFile, 'utf8'));
|
|
53
|
+
if (config.channels?.qqbot) {
|
|
54
|
+
oldQqbotConfig = { ...config.channels.qqbot };
|
|
55
|
+
console.log('已保存旧的 qqbot 配置');
|
|
56
|
+
}
|
|
57
|
+
} catch (err) {
|
|
58
|
+
console.error('读取配置文件失败:', err.message);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// 2. 删除旧的扩展目录
|
|
63
|
+
if (existsSync(extensionDir)) {
|
|
64
|
+
console.log(`删除旧版本插件: ${extensionDir}`);
|
|
65
|
+
rmSync(extensionDir, { recursive: true, force: true });
|
|
66
|
+
} else {
|
|
67
|
+
console.log('未找到旧版本插件目录,跳过删除');
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// 3. 清理配置文件中的 qqbot 相关字段
|
|
71
|
+
if (existsSync(configFile)) {
|
|
72
|
+
console.log('清理配置文件中的 qqbot 字段...');
|
|
73
|
+
try {
|
|
74
|
+
const config = JSON.parse(readFileSync(configFile, 'utf8'));
|
|
75
|
+
|
|
76
|
+
// 删除 channels.qqbot
|
|
77
|
+
if (config.channels?.qqbot) {
|
|
78
|
+
delete config.channels.qqbot;
|
|
79
|
+
console.log(' - 已删除 channels.qqbot');
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// 删除 plugins.entries.qqbot
|
|
83
|
+
if (config.plugins?.entries?.qqbot) {
|
|
84
|
+
delete config.plugins.entries.qqbot;
|
|
85
|
+
console.log(' - 已删除 plugins.entries.qqbot');
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// 删除 plugins.installs.qqbot
|
|
89
|
+
if (config.plugins?.installs?.qqbot) {
|
|
90
|
+
delete config.plugins.installs.qqbot;
|
|
91
|
+
console.log(' - 已删除 plugins.installs.qqbot');
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
writeFileSync(configFile, JSON.stringify(config, null, 2));
|
|
95
|
+
console.log('配置文件已更新');
|
|
96
|
+
} catch (err) {
|
|
97
|
+
console.error('清理配置文件失败:', err.message);
|
|
98
|
+
}
|
|
99
|
+
} else {
|
|
100
|
+
console.log(`未找到配置文件: ${configFile}`);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
return oldQqbotConfig;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
// 执行命令并继承 stdio
|
|
107
|
+
function runCommand(cmd, args = []) {
|
|
108
|
+
try {
|
|
109
|
+
execSync([cmd, ...args].join(' '), { stdio: 'inherit' });
|
|
110
|
+
return true;
|
|
111
|
+
} catch (err) {
|
|
112
|
+
return false;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
// 升级命令
|
|
117
|
+
function upgrade() {
|
|
118
|
+
console.log('=== QQBot 插件升级脚本 ===');
|
|
119
|
+
|
|
120
|
+
let foundInstallation = null;
|
|
121
|
+
let savedConfig = null;
|
|
122
|
+
const home = homedir();
|
|
123
|
+
|
|
124
|
+
// 检查 openclaw
|
|
125
|
+
if (existsSync(join(home, '.openclaw'))) {
|
|
126
|
+
savedConfig = cleanupInstallation('openclaw');
|
|
127
|
+
foundInstallation = 'openclaw';
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
// 检查 clawdbot
|
|
131
|
+
if (existsSync(join(home, '.clawdbot'))) {
|
|
132
|
+
const clawdbotConfig = cleanupInstallation('clawdbot');
|
|
133
|
+
if (!savedConfig) savedConfig = clawdbotConfig;
|
|
134
|
+
foundInstallation = 'clawdbot';
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
if (!foundInstallation) {
|
|
138
|
+
console.log('\n未找到 clawdbot 或 openclaw 安装目录');
|
|
139
|
+
console.log('请确认已安装 clawdbot 或 openclaw');
|
|
140
|
+
process.exit(1);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
console.log('\n=== 清理完成 ===');
|
|
144
|
+
|
|
145
|
+
// 自动安装插件
|
|
146
|
+
console.log('\n[1/2] 安装新版本插件...');
|
|
147
|
+
runCommand(foundInstallation, ['plugins', 'install', '@sliverp/qqbot']);
|
|
148
|
+
|
|
149
|
+
// 自动配置通道(使用保存的 appId 和 clientSecret)
|
|
150
|
+
console.log('\n[2/2] 配置机器人通道...');
|
|
151
|
+
if (savedConfig?.appId && savedConfig?.clientSecret) {
|
|
152
|
+
const token = `${savedConfig.appId}:${savedConfig.clientSecret}`;
|
|
153
|
+
console.log(`使用已保存的配置: appId=${savedConfig.appId}`);
|
|
154
|
+
runCommand(foundInstallation, ['channels', 'add', '--channel', 'qqbot', '--token', `"${token}"`]);
|
|
155
|
+
|
|
156
|
+
// 恢复其他配置项(如 markdownSupport)
|
|
157
|
+
if (savedConfig.markdownSupport !== undefined) {
|
|
158
|
+
runCommand(foundInstallation, ['config', 'set', 'channels.qqbot.markdownSupport', String(savedConfig.markdownSupport)]);
|
|
159
|
+
}
|
|
160
|
+
} else {
|
|
161
|
+
console.log('未找到已保存的 qqbot 配置,请手动配置:');
|
|
162
|
+
console.log(` ${foundInstallation} channels add --channel qqbot --token "AppID:AppSecret"`);
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
console.log('\n=== 升级完成 ===');
|
|
167
|
+
console.log(`\n可以运行以下命令启动机器人:`);
|
|
168
|
+
console.log(` ${foundInstallation} gateway --verbose`);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
// 安装命令
|
|
172
|
+
function install() {
|
|
173
|
+
console.log('=== QQBot 插件安装 ===');
|
|
174
|
+
|
|
175
|
+
const cmd = detectInstallation();
|
|
176
|
+
if (!cmd) {
|
|
177
|
+
console.log('未找到 clawdbot 或 openclaw 安装');
|
|
178
|
+
console.log('请先安装 openclaw 或 clawdbot');
|
|
179
|
+
process.exit(1);
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
console.log(`\n使用 ${cmd} 安装插件...`);
|
|
183
|
+
runCommand(cmd, ['plugins', 'install', '@sliverp/qqbot']);
|
|
184
|
+
|
|
185
|
+
console.log('\n=== 安装完成 ===');
|
|
186
|
+
console.log('\n请配置机器人通道:');
|
|
187
|
+
console.log(` ${cmd} channels add --channel qqbot --token "AppID:AppSecret"`);
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
// 显示帮助
|
|
191
|
+
function showHelp() {
|
|
192
|
+
console.log(`
|
|
193
|
+
QQBot CLI - QQ机器人插件管理工具
|
|
194
|
+
|
|
195
|
+
用法:
|
|
196
|
+
npx @sliverp/qqbot <命令>
|
|
197
|
+
|
|
198
|
+
命令:
|
|
199
|
+
upgrade 清理旧版本插件(升级前执行)
|
|
200
|
+
install 安装插件到 openclaw/clawdbot
|
|
201
|
+
|
|
202
|
+
示例:
|
|
203
|
+
npx @sliverp/qqbot upgrade
|
|
204
|
+
npx @sliverp/qqbot install
|
|
205
|
+
`);
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
// 主入口
|
|
209
|
+
switch (command) {
|
|
210
|
+
case 'upgrade':
|
|
211
|
+
upgrade();
|
|
212
|
+
break;
|
|
213
|
+
case 'install':
|
|
214
|
+
install();
|
|
215
|
+
break;
|
|
216
|
+
case '-h':
|
|
217
|
+
case '--help':
|
|
218
|
+
case 'help':
|
|
219
|
+
showHelp();
|
|
220
|
+
break;
|
|
221
|
+
default:
|
|
222
|
+
if (command) {
|
|
223
|
+
console.log(`未知命令: ${command}`);
|
|
224
|
+
}
|
|
225
|
+
showHelp();
|
|
226
|
+
process.exit(command ? 1 : 0);
|
|
227
|
+
}
|
package/package.json
CHANGED
|
@@ -1,9 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sliverp/qqbot",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.4",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
|
+
"bin": {
|
|
8
|
+
"qqbot": "./bin/qqbot-cli.js"
|
|
9
|
+
},
|
|
10
|
+
"files": [
|
|
11
|
+
"bin",
|
|
12
|
+
"src",
|
|
13
|
+
"index.ts",
|
|
14
|
+
"tsconfig.json"
|
|
15
|
+
],
|
|
7
16
|
"clawdbot": {
|
|
8
17
|
"extensions": ["./index.ts"]
|
|
9
18
|
},
|
package/clawdbot.plugin.json
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
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
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
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/src/api.d.ts
DELETED
|
@@ -1,194 +0,0 @@
|
|
|
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 {};
|