@alemonjs/qq-bot 2.1.32 → 2.1.34
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 +1984 -35
- package/dist/assets/index.css +1 -1
- package/dist/assets/index.js +12 -5
- package/dist/index.html +1 -1
- package/lib/config.d.ts +44 -19
- package/lib/config.js +39 -35
- package/lib/desktop.d.ts +4 -1
- package/lib/desktop.js +53 -57
- package/lib/format.d.ts +26 -5
- package/lib/format.js +84 -101
- package/lib/hook.d.ts +82 -64
- package/lib/hook.js +35 -32
- package/lib/index.d.ts +6 -4
- package/lib/index.js +13 -16
- package/lib/index.webhook.d.ts +4 -1
- package/lib/index.webhook.js +12 -14
- package/lib/index.websoket.d.ts +6 -3
- package/lib/index.websoket.js +131 -41
- package/lib/message/AT_MESSAGE_CREATE.d.ts +36 -33
- package/lib/message/AT_MESSAGE_CREATE.js +1 -1
- package/lib/message/CHANNEL_CREATE.d.ts +17 -14
- package/lib/message/CHANNEL_CREATE.js +1 -1
- package/lib/message/CHANNEL_DELETE.d.ts +22 -14
- package/lib/message/CHANNEL_DELETE.js +1 -1
- package/lib/message/CHANNEL_UPDATE.d.ts +22 -14
- package/lib/message/CHANNEL_UPDATE.js +1 -1
- package/lib/message/DIRECT_MESSAGE_CREATE.d.ts +35 -27
- package/lib/message/DIRECT_MESSAGE_CREATE.js +1 -1
- package/lib/message/DIRECT_MESSAGE_DELETE.d.ts +23 -15
- package/lib/message/DIRECT_MESSAGE_DELETE.js +1 -1
- package/lib/message/ERROR.d.ts +4 -1
- package/lib/message/ERROR.js +1 -1
- package/lib/message/GUILD_CREATE.d.ts +22 -14
- package/lib/message/GUILD_CREATE.js +1 -1
- package/lib/message/GUILD_DELETE.d.ts +22 -14
- package/lib/message/GUILD_DELETE.js +1 -1
- package/lib/message/GUILD_MEMBER_ADD.d.ts +21 -13
- package/lib/message/GUILD_MEMBER_ADD.js +1 -1
- package/lib/message/GUILD_MEMBER_REMOVE.d.ts +21 -13
- package/lib/message/GUILD_MEMBER_REMOVE.js +1 -1
- package/lib/message/GUILD_MEMBER_UPDATE.d.ts +21 -13
- package/lib/message/GUILD_MEMBER_UPDATE.js +1 -1
- package/lib/message/GUILD_UPDATE.d.ts +22 -14
- package/lib/message/GUILD_UPDATE.js +1 -1
- package/lib/message/INTERACTION_CREATE.d.ts +52 -44
- package/lib/message/INTERACTION_CREATE.js +1 -1
- package/lib/message/MESSAGE_CREATE.d.ts +12 -1
- package/lib/message/MESSAGE_CREATE.js +1 -1
- package/lib/message/MESSAGE_DELETE.d.ts +12 -1
- package/lib/message/MESSAGE_DELETE.js +1 -1
- package/lib/message/MESSAGE_REACTION_ADD.d.ts +15 -12
- package/lib/message/MESSAGE_REACTION_ADD.js +1 -1
- package/lib/message/MESSAGE_REACTION_REMOVE.d.ts +15 -12
- package/lib/message/MESSAGE_REACTION_REMOVE.js +1 -1
- package/lib/message/PUBLIC_MESSAGE_DELETE.d.ts +20 -13
- package/lib/message/PUBLIC_MESSAGE_DELETE.js +1 -1
- package/lib/message/READY.d.ts +11 -5
- package/lib/message/READY.js +1 -1
- package/lib/message/group/C2C_MESSAGE_CREATE.d.ts +18 -15
- package/lib/message/group/C2C_MESSAGE_CREATE.js +1 -1
- package/lib/message/group/C2C_MSG_RECEIVE.d.ts +13 -3
- package/lib/message/group/C2C_MSG_RECEIVE.js +1 -1
- package/lib/message/group/C2C_MSG_REJECT.d.ts +9 -3
- package/lib/message/group/C2C_MSG_REJECT.js +1 -1
- package/lib/message/group/FRIEND_ADD.d.ts +13 -3
- package/lib/message/group/FRIEND_ADD.js +1 -1
- package/lib/message/group/FRIEND_DEL.d.ts +9 -3
- package/lib/message/group/FRIEND_DEL.js +1 -1
- package/lib/message/group/GROUP_ADD_ROBOT.d.ts +23 -4
- package/lib/message/group/GROUP_ADD_ROBOT.js +1 -1
- package/lib/message/group/GROUP_AT_MESSAGE_CREATE.d.ts +38 -32
- package/lib/message/group/GROUP_AT_MESSAGE_CREATE.js +1 -1
- package/lib/message/group/GROUP_DEL_ROBOT.d.ts +19 -4
- package/lib/message/group/GROUP_DEL_ROBOT.js +1 -1
- package/lib/message/group/GROUP_JOIN_REQUEST.d.ts +84 -0
- package/lib/message/group/GROUP_JOIN_REQUEST.js +1 -0
- package/lib/message/group/GROUP_MEMBER_ADD.d.ts +8 -5
- package/lib/message/group/GROUP_MEMBER_ADD.js +1 -1
- package/lib/message/group/GROUP_MEMBER_REMOVE.d.ts +8 -5
- package/lib/message/group/GROUP_MEMBER_REMOVE.js +1 -1
- package/lib/message/group/GROUP_MESSAGE_CREATE.d.ts +38 -32
- package/lib/message/group/GROUP_MESSAGE_CREATE.js +1 -1
- package/lib/message/group/GROUP_MSG_RECEIVE.d.ts +14 -4
- package/lib/message/group/GROUP_MSG_RECEIVE.js +1 -1
- package/lib/message/group/GROUP_MSG_REJECT.d.ts +10 -4
- package/lib/message/group/GROUP_MSG_REJECT.js +1 -1
- package/lib/message/group/MESSAGE_AUDIT_PASS.d.ts +12 -6
- package/lib/message/group/MESSAGE_AUDIT_PASS.js +1 -1
- package/lib/message/group/MESSAGE_AUDIT_REJECT.d.ts +12 -6
- package/lib/message/group/MESSAGE_AUDIT_REJECT.js +1 -1
- package/lib/register.d.ts +12 -9
- package/lib/register.js +1246 -1200
- package/lib/sdk/api.d.ts +937 -251
- package/lib/sdk/api.js +1481 -758
- package/lib/sdk/client.webhook.d.ts +25 -8
- package/lib/sdk/client.webhook.js +185 -189
- package/lib/sdk/client.websoket.d.ts +31 -9
- package/lib/sdk/client.websoket.js +369 -392
- package/lib/sdk/config.d.ts +6 -2
- package/lib/sdk/config.js +9 -6
- package/lib/sdk/instance.d.ts +11 -3
- package/lib/sdk/instance.js +73 -83
- package/lib/sdk/intents.d.ts +89 -3
- package/lib/sdk/intents.js +116 -31
- package/lib/sdk/message.d.ts +7 -4
- package/lib/sdk/message.group.d.ts +38 -33
- package/lib/sdk/message.group.js +1 -1
- package/lib/sdk/message.guild.d.ts +40 -37
- package/lib/sdk/message.guild.js +1 -1
- package/lib/sdk/message.js +1 -1
- package/lib/sdk/message.public.d.ts +8 -5
- package/lib/sdk/message.public.js +1 -1
- package/lib/sdk/qr-auth.d.ts +55 -0
- package/lib/sdk/qr-auth.js +169 -0
- package/lib/sdk/registry.d.ts +34 -24
- package/lib/sdk/registry.js +134 -114
- package/lib/sdk/session.d.ts +19 -15
- package/lib/sdk/session.js +51 -54
- package/lib/sdk/typing.d.ts +416 -68
- package/lib/sdk/typing.js +1 -1
- package/lib/sdk/webhook.secret.d.ts +33 -13
- package/lib/sdk/webhook.secret.js +50 -36
- package/lib/sends.d.ts +46 -25
- package/lib/sends.js +533 -497
- package/lib/types.d.ts +52 -41
- package/lib/types.js +1 -1
- package/lib/upload.d.ts +50 -0
- package/lib/upload.js +89 -0
- package/lib/utils.d.ts +9 -1
- package/lib/utils.js +10 -5
- package/package.json +11 -8
package/lib/sdk/session.js
CHANGED
|
@@ -1,56 +1,53 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { randomUUID } from "node:crypto";
|
|
2
|
+
import { dirname, join } from "node:path";
|
|
3
|
+
import { mkdir, readFile, rename, unlink, writeFile } from "node:fs/promises";
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
.catch(() => undefined);
|
|
52
|
-
return next;
|
|
53
|
-
}
|
|
54
|
-
}
|
|
5
|
+
//#region src/sdk/session.ts
|
|
6
|
+
/** Default store. Sessions contain no access token or application secret. */
|
|
7
|
+
var FileSessionStore = class {
|
|
8
|
+
root;
|
|
9
|
+
#queues = /* @__PURE__ */ new Map();
|
|
10
|
+
#generations = /* @__PURE__ */ new Map();
|
|
11
|
+
constructor(root = join(process.cwd(), ".data", "qq-bot", "sessions")) {
|
|
12
|
+
this.root = root;
|
|
13
|
+
}
|
|
14
|
+
#path(botId) {
|
|
15
|
+
return join(this.root, `${encodeURIComponent(botId)}.json`);
|
|
16
|
+
}
|
|
17
|
+
async load(botId) {
|
|
18
|
+
try {
|
|
19
|
+
const value = JSON.parse(await readFile(this.#path(botId), "utf8"));
|
|
20
|
+
return value?.botId === botId && typeof value.sessionId === "string" && Number.isFinite(value.sequence) ? value : null;
|
|
21
|
+
} catch {
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
async save(session) {
|
|
26
|
+
const generation = this.#generations.get(session.botId) || 0;
|
|
27
|
+
await this.#enqueue(session.botId, async () => {
|
|
28
|
+
if (generation !== (this.#generations.get(session.botId) || 0)) return;
|
|
29
|
+
const path = this.#path(session.botId);
|
|
30
|
+
const temp = `${path}.${process.pid}.${randomUUID()}.tmp`;
|
|
31
|
+
await mkdir(dirname(path), { recursive: true });
|
|
32
|
+
await writeFile(temp, JSON.stringify(session), "utf8");
|
|
33
|
+
await rename(temp, path);
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
async clear(botId) {
|
|
37
|
+
this.#generations.set(botId, (this.#generations.get(botId) || 0) + 1);
|
|
38
|
+
await this.#enqueue(botId, async () => {
|
|
39
|
+
await unlink(this.#path(botId)).catch(() => void 0);
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
#enqueue(botId, task) {
|
|
43
|
+
const next = (this.#queues.get(botId) || Promise.resolve()).catch(() => void 0).then(task);
|
|
44
|
+
this.#queues.set(botId, next);
|
|
45
|
+
next.finally(() => {
|
|
46
|
+
if (this.#queues.get(botId) === next) this.#queues.delete(botId);
|
|
47
|
+
}).catch(() => void 0);
|
|
48
|
+
return next;
|
|
49
|
+
}
|
|
50
|
+
};
|
|
55
51
|
|
|
56
|
-
|
|
52
|
+
//#endregion
|
|
53
|
+
export { FileSessionStore };
|
package/lib/sdk/typing.d.ts
CHANGED
|
@@ -1,73 +1,421 @@
|
|
|
1
|
-
import { IntentsEnum } from
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
import { IntentsEnum } from "./intents.js";
|
|
2
|
+
import { SessionStore } from "./session.js";
|
|
3
|
+
//#region src/sdk/typing.d.ts
|
|
4
|
+
type MessageType = 0 | 1 | 2 | 3 | 4 | 6 | 7;
|
|
5
|
+
type FileType = 1 | 2 | 3 | 4;
|
|
6
|
+
interface ButtonType {
|
|
7
|
+
id: string;
|
|
8
|
+
render_data: {
|
|
9
|
+
label: string;
|
|
10
|
+
visited_label: string;
|
|
11
|
+
style?: number;
|
|
12
|
+
};
|
|
13
|
+
action: {
|
|
14
|
+
type: number;
|
|
15
|
+
permission: {
|
|
16
|
+
type: number;
|
|
11
17
|
};
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
unsupport_tips?: string;
|
|
20
|
-
data: string | {
|
|
21
|
-
click: string;
|
|
22
|
-
confirm: string;
|
|
23
|
-
cancel: string;
|
|
24
|
-
};
|
|
25
|
-
at_bot_show_channel_list?: boolean;
|
|
18
|
+
reply?: boolean;
|
|
19
|
+
enter?: boolean;
|
|
20
|
+
unsupport_tips?: string;
|
|
21
|
+
data: string | {
|
|
22
|
+
click: string;
|
|
23
|
+
confirm: string;
|
|
24
|
+
cancel: string;
|
|
26
25
|
};
|
|
26
|
+
at_bot_show_channel_list?: boolean;
|
|
27
|
+
};
|
|
27
28
|
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
29
|
+
interface KeyboardType {
|
|
30
|
+
id?: string;
|
|
31
|
+
content?: {
|
|
32
|
+
rows: {
|
|
33
|
+
buttons: ButtonType[];
|
|
34
|
+
}[];
|
|
35
|
+
};
|
|
35
36
|
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
37
|
+
interface MarkdownType {
|
|
38
|
+
/** markdown 模版id,申请模版后获得 */
|
|
39
|
+
custom_template_id?: string;
|
|
40
|
+
/** 原生 markdown 文本内容(内邀使用) */
|
|
41
|
+
content?: string;
|
|
42
|
+
/** 模版内变量与填充值的kv映射 */
|
|
43
|
+
params?: Array<{
|
|
44
|
+
key: string;
|
|
45
|
+
values: string[];
|
|
46
|
+
}>;
|
|
47
|
+
}
|
|
48
|
+
interface ApiRequestData {
|
|
49
|
+
content?: string;
|
|
50
|
+
msg_type: MessageType;
|
|
51
|
+
markdown?: MarkdownType;
|
|
52
|
+
keyboard?: KeyboardType;
|
|
53
|
+
media?: {
|
|
54
|
+
file_info: string;
|
|
55
|
+
};
|
|
56
|
+
ark?: any;
|
|
57
|
+
image?: any;
|
|
58
|
+
message_reference?: any;
|
|
59
|
+
event_id?: any;
|
|
60
|
+
msg_id?: string;
|
|
61
|
+
msg_seq?: number;
|
|
62
|
+
/**
|
|
63
|
+
* 互动召回消息,true 时不校验 msg_id/event_id 有效期
|
|
64
|
+
*/
|
|
65
|
+
is_wakeup?: boolean;
|
|
66
|
+
/**
|
|
67
|
+
* 是否校验图片转存结果。true 时图片转存失败将返回错误且不发送消息,默认 false
|
|
68
|
+
*/
|
|
69
|
+
force_verify_image_resource?: boolean;
|
|
70
|
+
/**
|
|
71
|
+
* 输入状态通知(msg_type=6,仅单聊支持)
|
|
72
|
+
*/
|
|
73
|
+
input_notify?: {
|
|
74
|
+
/**
|
|
75
|
+
* 输入状态类型,当前固定为 1(正在输入)
|
|
76
|
+
*/
|
|
77
|
+
input_type: number;
|
|
78
|
+
/**
|
|
79
|
+
* 展示时长(秒)
|
|
80
|
+
*/
|
|
81
|
+
input_second: number;
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* 用户入群验证信息
|
|
86
|
+
*/
|
|
87
|
+
interface VerifyInfo {
|
|
88
|
+
/**
|
|
89
|
+
* 验证方式:verify_message 或 admin_review_qa
|
|
90
|
+
*/
|
|
91
|
+
method: string;
|
|
92
|
+
/**
|
|
93
|
+
* 验证消息内容,仅 method=verify_message 时可能携带
|
|
94
|
+
*/
|
|
95
|
+
verify_message?: string;
|
|
96
|
+
/**
|
|
97
|
+
* 管理员问答列表,仅 method=admin_review_qa 时可能携带
|
|
98
|
+
*/
|
|
99
|
+
review_qa_list?: {
|
|
100
|
+
/**
|
|
101
|
+
* 管理员设置的问题
|
|
102
|
+
*/
|
|
103
|
+
question: string;
|
|
104
|
+
/**
|
|
105
|
+
* 申请人填写的答案
|
|
106
|
+
*/
|
|
107
|
+
answer: string;
|
|
108
|
+
}[];
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* 入群申请
|
|
112
|
+
*/
|
|
113
|
+
interface JoinRequest {
|
|
114
|
+
/**
|
|
115
|
+
* 申请 ID,审批接口需要回传
|
|
116
|
+
*/
|
|
117
|
+
join_request_id: string;
|
|
118
|
+
/**
|
|
119
|
+
* 安全提示语
|
|
120
|
+
*/
|
|
121
|
+
risk_tips?: string;
|
|
122
|
+
/**
|
|
123
|
+
* 用户在应用或开放平台下的统一标识
|
|
124
|
+
*/
|
|
125
|
+
union_openid?: string;
|
|
126
|
+
/**
|
|
127
|
+
* 申请人的 openid
|
|
128
|
+
*/
|
|
129
|
+
member_openid: string;
|
|
130
|
+
/**
|
|
131
|
+
* 申请人昵称
|
|
132
|
+
*/
|
|
133
|
+
username: string;
|
|
134
|
+
/**
|
|
135
|
+
* 申请时间戳,RFC3339 格式
|
|
136
|
+
*/
|
|
137
|
+
apply_at: string;
|
|
138
|
+
/**
|
|
139
|
+
* self_apply 主动申请,invited 被邀请
|
|
140
|
+
*/
|
|
141
|
+
apply_source: string;
|
|
142
|
+
/**
|
|
143
|
+
* 邀请人的 openid,仅 apply_source=invited 时生效
|
|
144
|
+
*/
|
|
145
|
+
invited_by?: string;
|
|
146
|
+
/**
|
|
147
|
+
* 是否为机器人账号
|
|
148
|
+
*/
|
|
149
|
+
bot: boolean;
|
|
150
|
+
/**
|
|
151
|
+
* 用户入群验证信息
|
|
152
|
+
*/
|
|
153
|
+
verify_info?: VerifyInfo;
|
|
154
|
+
/**
|
|
155
|
+
* 自动审批通过的扩展信息
|
|
156
|
+
*/
|
|
157
|
+
auto_approved?: {
|
|
158
|
+
/**
|
|
159
|
+
* 自动审批通过所命中的策略 ID
|
|
160
|
+
*/
|
|
161
|
+
strategy_id: string;
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* 群全局禁言规则
|
|
166
|
+
*/
|
|
167
|
+
interface GlobalMuteRule {
|
|
168
|
+
/**
|
|
169
|
+
* none 不禁言 / always 始终禁言 / schedule 按计划禁言
|
|
170
|
+
*/
|
|
171
|
+
mode: 'none' | 'always' | 'schedule';
|
|
172
|
+
/**
|
|
173
|
+
* 定时禁言规则
|
|
174
|
+
*/
|
|
175
|
+
schedule_rules?: {
|
|
176
|
+
task_id: string;
|
|
177
|
+
start_at: string;
|
|
178
|
+
end_at: string;
|
|
179
|
+
enabled: boolean;
|
|
180
|
+
}[];
|
|
181
|
+
/**
|
|
182
|
+
* 周期禁言规则
|
|
183
|
+
*/
|
|
184
|
+
recurring_rules?: {
|
|
185
|
+
task_id: string;
|
|
186
|
+
weekdays: number[];
|
|
187
|
+
start_time: string;
|
|
188
|
+
end_time: string;
|
|
189
|
+
enabled: boolean;
|
|
190
|
+
}[];
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* 群成员禁言状态
|
|
194
|
+
*/
|
|
195
|
+
interface MemberMuteState {
|
|
196
|
+
member_openid: string;
|
|
197
|
+
mute_expire_at: string;
|
|
198
|
+
username: string;
|
|
199
|
+
union_openid: string;
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* 设置群成员禁言
|
|
203
|
+
*/
|
|
204
|
+
interface SetMemberMuteState {
|
|
205
|
+
/**
|
|
206
|
+
* add 增加 / update 更新到期时间 / del 解除
|
|
207
|
+
*/
|
|
208
|
+
op: 'add' | 'update' | 'del';
|
|
209
|
+
/**
|
|
210
|
+
* 群成员 openid(只能操作普通成员)
|
|
211
|
+
*/
|
|
212
|
+
member_openid: string;
|
|
213
|
+
/**
|
|
214
|
+
* RFC3339 到期时间,op=del 可传空串立即解除
|
|
215
|
+
*/
|
|
216
|
+
mute_expire_at?: string;
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* 入群自动审批策略
|
|
220
|
+
*/
|
|
221
|
+
interface JoinApprovalStrategy {
|
|
222
|
+
strategy_id: string;
|
|
223
|
+
group_openids: string[];
|
|
224
|
+
group_ids: string[];
|
|
225
|
+
/**
|
|
226
|
+
* 白名单人数估算
|
|
227
|
+
*/
|
|
228
|
+
whitelist_user_count: number;
|
|
229
|
+
is_enable: 'on' | 'off';
|
|
230
|
+
expire_at: string;
|
|
231
|
+
created_at: string;
|
|
232
|
+
updated_at: string;
|
|
233
|
+
remark: string;
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* 策略群操作
|
|
237
|
+
*/
|
|
238
|
+
interface GroupAction {
|
|
239
|
+
op: 'add' | 'del';
|
|
240
|
+
group_openids?: string[];
|
|
241
|
+
group_ids?: string[];
|
|
242
|
+
}
|
|
243
|
+
/**
|
|
244
|
+
* 分片上传准备参数
|
|
245
|
+
*/
|
|
246
|
+
interface UploadPrepareData {
|
|
247
|
+
/**
|
|
248
|
+
* 1 图片 / 2 视频 / 3 语音 / 4 文件
|
|
249
|
+
*/
|
|
250
|
+
file_type: FileType;
|
|
251
|
+
file_name: string;
|
|
252
|
+
/**
|
|
253
|
+
* 文件大小(字节)
|
|
254
|
+
*/
|
|
255
|
+
file_size: string;
|
|
256
|
+
/**
|
|
257
|
+
* 完整文件 MD5
|
|
258
|
+
*/
|
|
259
|
+
md5: string;
|
|
260
|
+
/**
|
|
261
|
+
* 完整文件 SHA1
|
|
262
|
+
*/
|
|
263
|
+
sha1: string;
|
|
264
|
+
/**
|
|
265
|
+
* 文件前 10002432 字节(约 10MB)的 MD5
|
|
266
|
+
*/
|
|
267
|
+
md5_10m: string;
|
|
268
|
+
}
|
|
269
|
+
/**
|
|
270
|
+
* 分片信息
|
|
271
|
+
*/
|
|
272
|
+
interface UploadPart {
|
|
273
|
+
/**
|
|
274
|
+
* 分片序号,从 0 开始
|
|
275
|
+
*/
|
|
276
|
+
index: number;
|
|
277
|
+
/**
|
|
278
|
+
* 预签名上传地址(COS 直传)
|
|
279
|
+
*/
|
|
280
|
+
presigned_url: string;
|
|
281
|
+
/**
|
|
282
|
+
* 当前分片大小(字节)
|
|
283
|
+
*/
|
|
284
|
+
block_size: string;
|
|
285
|
+
}
|
|
286
|
+
/**
|
|
287
|
+
* 上传并发/重试配置
|
|
288
|
+
*/
|
|
289
|
+
interface UploadConfig {
|
|
290
|
+
concurrency: number;
|
|
291
|
+
retry_timeout: number;
|
|
292
|
+
retry_delay: number;
|
|
293
|
+
}
|
|
294
|
+
/**
|
|
295
|
+
* 分片上传准备结果
|
|
296
|
+
*/
|
|
297
|
+
interface UploadPrepareResult {
|
|
298
|
+
upload_id: string;
|
|
299
|
+
block_size: string;
|
|
300
|
+
parts: UploadPart[];
|
|
301
|
+
upload_config: UploadConfig;
|
|
302
|
+
}
|
|
303
|
+
/**
|
|
304
|
+
* 分片完成参数
|
|
305
|
+
*/
|
|
306
|
+
interface UploadPartFinishData {
|
|
307
|
+
upload_id: string;
|
|
308
|
+
/**
|
|
309
|
+
* 分片序号,对应 parts.index
|
|
310
|
+
*/
|
|
311
|
+
part_index: number;
|
|
312
|
+
/**
|
|
313
|
+
* 当前分片大小(字节)
|
|
314
|
+
*/
|
|
315
|
+
block_size: string;
|
|
316
|
+
/**
|
|
317
|
+
* 当前分片内容 MD5
|
|
318
|
+
*/
|
|
319
|
+
md5: string;
|
|
320
|
+
}
|
|
321
|
+
/**
|
|
322
|
+
* 流式消息参数(仅单聊)
|
|
323
|
+
*/
|
|
324
|
+
interface StreamMessageData {
|
|
325
|
+
/**
|
|
326
|
+
* append 追加(默认)/ replace 替换(传当前全量正文)
|
|
327
|
+
*/
|
|
328
|
+
input_mode?: 'append' | 'replace';
|
|
329
|
+
/**
|
|
330
|
+
* 1 生成中 / 10 生成结束
|
|
331
|
+
*/
|
|
332
|
+
input_state?: 1 | 10;
|
|
333
|
+
content_type?: 'text' | 'markdown';
|
|
334
|
+
content_raw?: string;
|
|
335
|
+
event_id?: string;
|
|
336
|
+
msg_id?: string;
|
|
337
|
+
/**
|
|
338
|
+
* 去重序号,同一条流式消息内保持一致
|
|
339
|
+
*/
|
|
340
|
+
msg_seq?: number;
|
|
341
|
+
/**
|
|
342
|
+
* 流式分片序号,从 0 递增
|
|
343
|
+
*/
|
|
344
|
+
index?: number;
|
|
345
|
+
/**
|
|
346
|
+
* 首次请求不填,后续填首次响应中的 id
|
|
347
|
+
*/
|
|
348
|
+
stream_msg_id?: string;
|
|
349
|
+
is_wakeup?: boolean;
|
|
350
|
+
}
|
|
351
|
+
/**
|
|
352
|
+
* 流式消息响应
|
|
353
|
+
*/
|
|
354
|
+
interface StreamMessageResult {
|
|
355
|
+
id: string;
|
|
356
|
+
timestamp: string;
|
|
357
|
+
ext_info?: {
|
|
358
|
+
ref_idx?: string;
|
|
359
|
+
};
|
|
360
|
+
/**
|
|
361
|
+
* 流式消息剩余长度(字符)
|
|
362
|
+
*/
|
|
363
|
+
remain_msg_len?: number;
|
|
364
|
+
}
|
|
365
|
+
interface Options {
|
|
366
|
+
/**
|
|
367
|
+
* 应用编号
|
|
368
|
+
*/
|
|
369
|
+
app_id: string;
|
|
370
|
+
/**
|
|
371
|
+
* 密钥
|
|
372
|
+
*/
|
|
373
|
+
secret: string;
|
|
374
|
+
/**
|
|
375
|
+
* 分片
|
|
376
|
+
* [0, 1]
|
|
377
|
+
*/
|
|
378
|
+
shard?: number[];
|
|
379
|
+
/**
|
|
380
|
+
* 事件订阅
|
|
381
|
+
*/
|
|
382
|
+
intents?: IntentsEnum[];
|
|
383
|
+
/**
|
|
384
|
+
* 是否是私域
|
|
385
|
+
* false
|
|
386
|
+
*/
|
|
387
|
+
is_private?: boolean;
|
|
388
|
+
/**
|
|
389
|
+
* 是否是沙盒环境
|
|
390
|
+
* false
|
|
391
|
+
*/
|
|
392
|
+
sandbox?: boolean;
|
|
393
|
+
/**
|
|
394
|
+
* 路由
|
|
395
|
+
*/
|
|
396
|
+
route?: string;
|
|
397
|
+
/**
|
|
398
|
+
* 端口
|
|
399
|
+
*/
|
|
400
|
+
port?: string;
|
|
401
|
+
/**
|
|
402
|
+
* WebSocket 地址
|
|
403
|
+
*/
|
|
404
|
+
ws?: string;
|
|
405
|
+
/**
|
|
406
|
+
* WebSocket 网关地址
|
|
407
|
+
*/
|
|
408
|
+
gatewayURL?: string;
|
|
409
|
+
/**
|
|
410
|
+
* API 基础地址
|
|
411
|
+
*/
|
|
412
|
+
base_url_gateway?: string;
|
|
413
|
+
/**
|
|
414
|
+
* API 基础地址(获取 access_token)
|
|
415
|
+
*/
|
|
416
|
+
base_url_app_access_token?: string;
|
|
417
|
+
/** Programmatic persistence override; file persistence is the default. */
|
|
418
|
+
sessionStore?: SessionStore;
|
|
73
419
|
}
|
|
420
|
+
//#endregion
|
|
421
|
+
export { ApiRequestData, ButtonType, FileType, GlobalMuteRule, GroupAction, JoinApprovalStrategy, JoinRequest, KeyboardType, MarkdownType, MemberMuteState, MessageType, Options, SetMemberMuteState, StreamMessageData, StreamMessageResult, UploadConfig, UploadPart, UploadPartFinishData, UploadPrepareData, UploadPrepareResult, VerifyInfo };
|
package/lib/sdk/typing.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
export { };
|
|
@@ -1,14 +1,34 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
1
|
+
//#region src/sdk/webhook.secret.d.ts
|
|
2
|
+
declare class WebhookAPI {
|
|
3
|
+
config: {
|
|
4
|
+
secret: string;
|
|
5
|
+
};
|
|
6
|
+
constructor(config: {
|
|
7
|
+
secret: string;
|
|
8
|
+
});
|
|
9
|
+
/**
|
|
10
|
+
* 验证签名
|
|
11
|
+
* @param ts
|
|
12
|
+
* @param body
|
|
13
|
+
* @param sign
|
|
14
|
+
* @returns
|
|
15
|
+
*/
|
|
16
|
+
validSign(ts: any, body: any, sign: any): boolean;
|
|
17
|
+
/**
|
|
18
|
+
* 生成签名
|
|
19
|
+
* @param eventTs
|
|
20
|
+
* @param plainToken
|
|
21
|
+
* @returns
|
|
22
|
+
*/
|
|
23
|
+
getSign(eventTs: any, plainToken: any): string;
|
|
24
|
+
/**
|
|
25
|
+
* 获取 key
|
|
26
|
+
* @returns
|
|
27
|
+
*/
|
|
28
|
+
getKey(): {
|
|
29
|
+
privateKey: Buffer<ArrayBuffer>;
|
|
30
|
+
publicKey: Uint8Array<ArrayBufferLike>;
|
|
31
|
+
};
|
|
14
32
|
}
|
|
33
|
+
//#endregion
|
|
34
|
+
export { WebhookAPI };
|