@napuketto/adapter 0.0.1
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/LICENSE +21 -0
- package/dist/core/index.d.mts +2 -0
- package/dist/core/index.mjs +2 -0
- package/dist/core-Bj5L8WeZ.mjs +149 -0
- package/dist/core-Bj5L8WeZ.mjs.map +1 -0
- package/dist/index-C1nIfPiU.d.mts +109 -0
- package/dist/index-C1nIfPiU.d.mts.map +1 -0
- package/dist/index.d.mts +11 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +1 -0
- package/dist/onebot11/index.d.mts +798 -0
- package/dist/onebot11/index.d.mts.map +1 -0
- package/dist/onebot11/index.mjs +3695 -0
- package/dist/onebot11/index.mjs.map +1 -0
- package/package.json +48 -0
|
@@ -0,0 +1,798 @@
|
|
|
1
|
+
import { l as ErrorCodeMap, o as ActionRegistry, r as ProtocolConfig, t as BaseProtocolAdapter } from "../index-C1nIfPiU.mjs";
|
|
2
|
+
import { CanonicalElement, FriendApi, GroupApi, GroupCache, GroupNotifyApi, MsgApi, MsgEventChannel, Peer, ProfileApi, ProfileLikeApi, RichMediaApi, TicketApi, WebApi } from "@napuketto/kernel";
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
import { EventBroadcaster, TransportAdapter } from "@napuketto/network";
|
|
5
|
+
//#region src/onebot11/action/error-map.d.ts
|
|
6
|
+
/** OB11 错误码映射表(send_msg 等所有 OB11 动作共用)。 */
|
|
7
|
+
declare const ob11ErrorCodeMap: ErrorCodeMap;
|
|
8
|
+
//#endregion
|
|
9
|
+
//#region src/onebot11/action/group/get-group-at-all-remain.d.ts
|
|
10
|
+
/** @全体剩余次数返回结构。 */
|
|
11
|
+
interface AtAllRemainInfo {
|
|
12
|
+
can_at_all: boolean;
|
|
13
|
+
remain_at_all_count_for_uin: number;
|
|
14
|
+
remain_at_all_count_for_group: number;
|
|
15
|
+
}
|
|
16
|
+
//#endregion
|
|
17
|
+
//#region src/onebot11/helper/message-unique.d.ts
|
|
18
|
+
declare class MessageUnique {
|
|
19
|
+
/** NT msgId → OB11 message_id。 */
|
|
20
|
+
private readonly msgIdToInt;
|
|
21
|
+
/** OB11 message_id → NT msgId。 */
|
|
22
|
+
private readonly intToMsgId;
|
|
23
|
+
/** NT msgId → Peer(delete_msg / get_msg 等只有 message_id 时反查用)。 */
|
|
24
|
+
private readonly msgIdToPeer;
|
|
25
|
+
/** 递增计数器。 */
|
|
26
|
+
private cursor;
|
|
27
|
+
/** 已释放的槽位(可复用)。 */
|
|
28
|
+
private readonly freed;
|
|
29
|
+
/**
|
|
30
|
+
* 为新 NT 消息分配 OB11 message_id(幂等:同一 msgId 返回同一 id)。
|
|
31
|
+
* peer 可选:传入则记录,供 message_id → peer 反查。
|
|
32
|
+
*/
|
|
33
|
+
alloc(msgId: string, peer?: Peer): number;
|
|
34
|
+
/** OB11 message_id → NT msgId。 */
|
|
35
|
+
getMsgId(messageId: number): string | undefined;
|
|
36
|
+
/** NT msgId → OB11 message_id(未分配返回 undefined)。 */
|
|
37
|
+
getMessageId(msgId: string): number | undefined;
|
|
38
|
+
/** NT msgId → Peer(alloc 时未记录返回 undefined)。 */
|
|
39
|
+
getPeer(msgId: string): Peer | undefined;
|
|
40
|
+
/** 释放 NT msgId 占用的槽位(消息过期/删除时调用,可选)。 */
|
|
41
|
+
release(msgId: string): void;
|
|
42
|
+
/** 取下一个可用 id:优先释放池,否则递增(溢出后线性扫描空洞)。 */
|
|
43
|
+
private nextFreeId;
|
|
44
|
+
}
|
|
45
|
+
//#endregion
|
|
46
|
+
//#region src/onebot11/api/one-bot-api.d.ts
|
|
47
|
+
/** 系统类本地回调(get_version_info / clean_cache / download_file / 进程控制用)。 */
|
|
48
|
+
interface OneBotSystemOptions {
|
|
49
|
+
/** 运行版本(get_version_info 用,缺省 unknown)。 */
|
|
50
|
+
appVersion: string;
|
|
51
|
+
/** 缓存清理回调(clean_cache 用,未配置抛错)。 */
|
|
52
|
+
cleanCache?: () => Promise<void>;
|
|
53
|
+
/** 缓存目录(download_file 保存路径)。 */
|
|
54
|
+
cacheDir?: string;
|
|
55
|
+
/** 进程退出回调(bot_exit 用)。 */
|
|
56
|
+
exit?: () => Promise<void>;
|
|
57
|
+
/** 进程重启回调(set_restart 用,缺省退化为退出)。 */
|
|
58
|
+
restart?: () => Promise<void>;
|
|
59
|
+
}
|
|
60
|
+
/** OneBotApi 构造参数。 */
|
|
61
|
+
interface OneBotApiOptions {
|
|
62
|
+
msgApi: MsgApi;
|
|
63
|
+
groupApi: GroupApi;
|
|
64
|
+
groupNotifyApi: GroupNotifyApi;
|
|
65
|
+
friendApi: FriendApi;
|
|
66
|
+
ticketApi: TicketApi;
|
|
67
|
+
richMediaApi: RichMediaApi;
|
|
68
|
+
profileApi: ProfileApi;
|
|
69
|
+
profileLikeApi: ProfileLikeApi;
|
|
70
|
+
webApi: WebApi;
|
|
71
|
+
/** 登录身份(get_login_info 用)。 */
|
|
72
|
+
self: {
|
|
73
|
+
uin: string;
|
|
74
|
+
nickname: string;
|
|
75
|
+
};
|
|
76
|
+
/** 系统类本地信息。 */
|
|
77
|
+
system: OneBotSystemOptions;
|
|
78
|
+
/** 群/成员缓存(ADR-008,读缓存动作用;未装配时动作直查 api)。 */
|
|
79
|
+
groupCache?: GroupCache;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* OneBot 11 动作统一依赖聚合(P2-16)。
|
|
83
|
+
* 各动作经 `Pick<OneBotApi, ...>` 取所需成员;注册处只构造一次本对象。
|
|
84
|
+
*/
|
|
85
|
+
declare class OneBotApi {
|
|
86
|
+
/** kernel 消息 API(send_msg 等消息类动作用)。 */
|
|
87
|
+
readonly msgApi: MsgApi;
|
|
88
|
+
/** kernel 群 API。 */
|
|
89
|
+
readonly groupApi: GroupApi;
|
|
90
|
+
/** kernel 群通知 API(群请求/禁言列表用)。 */
|
|
91
|
+
readonly groupNotifyApi: GroupNotifyApi;
|
|
92
|
+
/** kernel 好友 API。 */
|
|
93
|
+
readonly friendApi: FriendApi;
|
|
94
|
+
/** kernel 票据 API(get_clientkey/get_cookies 用)。 */
|
|
95
|
+
readonly ticketApi: TicketApi;
|
|
96
|
+
/** kernel 富媒体 API(群文件/翻译用)。 */
|
|
97
|
+
readonly richMediaApi: RichMediaApi;
|
|
98
|
+
/** kernel 资料 API(签名/昵称/头像用)。 */
|
|
99
|
+
readonly profileApi: ProfileApi;
|
|
100
|
+
/** kernel 点赞 API(send_like 用)。 */
|
|
101
|
+
readonly profileLikeApi: ProfileLikeApi;
|
|
102
|
+
/** kernel 群空间 web API(精华/荣誉用)。 */
|
|
103
|
+
readonly webApi: WebApi;
|
|
104
|
+
/** 群/成员缓存(ADR-008;翻译层只读消费,缺失惰性回填)。 */
|
|
105
|
+
readonly groupCache: GroupCache | undefined;
|
|
106
|
+
/** OB11 message_id ↔ NT msgId 双向映射(收链路与动作共用同一映射空间)。 */
|
|
107
|
+
readonly messageUnique: MessageUnique;
|
|
108
|
+
/** 登录身份(get_login_info 用)。 */
|
|
109
|
+
readonly self: {
|
|
110
|
+
uin: string;
|
|
111
|
+
nickname: string;
|
|
112
|
+
};
|
|
113
|
+
/** 机器人自身 uin(get_cookies / csrf 用)。 */
|
|
114
|
+
readonly selfUin: string;
|
|
115
|
+
/** 运行版本(get_version_info 用)。 */
|
|
116
|
+
readonly appVersion: string;
|
|
117
|
+
/** 缓存清理回调(clean_cache 用)。 */
|
|
118
|
+
readonly cleanCache: (() => Promise<void>) | undefined;
|
|
119
|
+
/** 缓存目录(download_file 用)。 */
|
|
120
|
+
readonly cacheDir: string | undefined;
|
|
121
|
+
/** 进程退出回调(bot_exit 用)。 */
|
|
122
|
+
readonly exit: (() => Promise<void>) | undefined;
|
|
123
|
+
/** 进程重启回调(set_restart 用)。 */
|
|
124
|
+
readonly restart: (() => Promise<void>) | undefined;
|
|
125
|
+
constructor(opts: OneBotApiOptions);
|
|
126
|
+
/** uin→uid 转换(委托 groupApi;私聊目标/成员 user_id 用)。 */
|
|
127
|
+
uinToUid(uins: string[]): Promise<Map<string, string>>;
|
|
128
|
+
/** uid→uin 转换(委托 groupApi;notice/grayTip 用)。 */
|
|
129
|
+
uidToUin(uids: string[]): Promise<Map<string, string>>;
|
|
130
|
+
}
|
|
131
|
+
//#endregion
|
|
132
|
+
//#region src/onebot11/action/index.d.ts
|
|
133
|
+
/** 动作注册表依赖(P2-16:动作只依赖一个聚合对象)。 */
|
|
134
|
+
interface Ob11ActionDeps {
|
|
135
|
+
/** OneBotApi 聚合(9 个 kernel apis + messageUnique + self/system)。 */
|
|
136
|
+
api: OneBotApi;
|
|
137
|
+
}
|
|
138
|
+
/** 构建 OB11 动作注册表(所有 OB11 动作在此注册,按组拆分控制行数)。 */
|
|
139
|
+
declare function createOb11ActionRegistry(deps: Ob11ActionDeps): ActionRegistry;
|
|
140
|
+
//#endregion
|
|
141
|
+
//#region src/onebot11/helper/config.d.ts
|
|
142
|
+
/** OB11 配置 schema。 */
|
|
143
|
+
declare const ob11ConfigSchema: z.ZodObject<{
|
|
144
|
+
token: z.ZodOptional<z.ZodString>;
|
|
145
|
+
heartbeatInterval: z.ZodDefault<z.ZodNumber>;
|
|
146
|
+
reportSelfMessage: z.ZodDefault<z.ZodBoolean>;
|
|
147
|
+
messagePostFormat: z.ZodDefault<z.ZodEnum<{
|
|
148
|
+
array: "array";
|
|
149
|
+
string: "string";
|
|
150
|
+
}>>;
|
|
151
|
+
httpServers: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
152
|
+
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
153
|
+
host: z.ZodDefault<z.ZodString>;
|
|
154
|
+
port: z.ZodDefault<z.ZodNumber>;
|
|
155
|
+
token: z.ZodOptional<z.ZodString>;
|
|
156
|
+
}, z.core.$strip>>>;
|
|
157
|
+
httpPostUrls: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
158
|
+
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
159
|
+
url: z.ZodOptional<z.ZodString>;
|
|
160
|
+
token: z.ZodOptional<z.ZodString>;
|
|
161
|
+
timeoutMs: z.ZodOptional<z.ZodNumber>;
|
|
162
|
+
}, z.core.$strip>>>;
|
|
163
|
+
wsServers: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
164
|
+
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
165
|
+
host: z.ZodDefault<z.ZodString>;
|
|
166
|
+
port: z.ZodDefault<z.ZodNumber>;
|
|
167
|
+
token: z.ZodOptional<z.ZodString>;
|
|
168
|
+
heartbeatInterval: z.ZodDefault<z.ZodNumber>;
|
|
169
|
+
}, z.core.$strip>>>;
|
|
170
|
+
wsReverseUrls: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
171
|
+
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
172
|
+
url: z.ZodOptional<z.ZodString>;
|
|
173
|
+
token: z.ZodOptional<z.ZodString>;
|
|
174
|
+
reconnectDelayMs: z.ZodDefault<z.ZodNumber>;
|
|
175
|
+
maxReconnectAttempts: z.ZodOptional<z.ZodNumber>;
|
|
176
|
+
rejectUnauthorized: z.ZodDefault<z.ZodBoolean>;
|
|
177
|
+
heartbeatInterval: z.ZodDefault<z.ZodNumber>;
|
|
178
|
+
}, z.core.$strip>>>;
|
|
179
|
+
}, z.core.$strip>;
|
|
180
|
+
/** OB11 配置类型(由 schema 推导)。 */
|
|
181
|
+
type OB11Config = z.infer<typeof ob11ConfigSchema>;
|
|
182
|
+
//#endregion
|
|
183
|
+
//#region src/onebot11/helper/cqcode.d.ts
|
|
184
|
+
/**
|
|
185
|
+
* CQ 码编解码(OneBot 11 消息段序列化格式)
|
|
186
|
+
*
|
|
187
|
+
* 纯函数、无 OB11 类型依赖:本文件只处理「文本 ↔ CQ 码片段」的通用编解码,
|
|
188
|
+
* segment 级别的映射在 data.ts(OB11Constructor)。
|
|
189
|
+
*
|
|
190
|
+
* 转义规则(OneBot 11 规范):
|
|
191
|
+
* - 纯文本:& → &,[ → [,] → ]
|
|
192
|
+
* - 参数值:额外 , → ,
|
|
193
|
+
*/
|
|
194
|
+
/** CQ 码片段([CQ:type,key=value,...] 的结构化表示)。 */
|
|
195
|
+
interface CqCode {
|
|
196
|
+
type: string;
|
|
197
|
+
params: Record<string, string>;
|
|
198
|
+
}
|
|
199
|
+
/** 转义纯文本(& [ ];& 必须先转,避免二次转义)。 */
|
|
200
|
+
declare function escapeCqText(text: string): string;
|
|
201
|
+
/** 转义 CQ 码参数值(& [ ] ,)。 */
|
|
202
|
+
declare function escapeCqParam(value: string): string;
|
|
203
|
+
/** 反转义(, ] [ &;& 必须最后解,避免二次转义误伤)。 */
|
|
204
|
+
declare function unescapeCqText(text: string): string;
|
|
205
|
+
/** 编码单个 CQ 码(undefined 参数自动省略)。 */
|
|
206
|
+
declare function encodeCqCode(type: string, params: Record<string, string | number | undefined>): string;
|
|
207
|
+
/** 解析一条消息文本 → 文本片段与 CQ 码片段的混合数组(文本已反转义)。 */
|
|
208
|
+
declare function parseCqMessage(text: string): Array<string | CqCode>;
|
|
209
|
+
/** 将混合片段数组序列化回消息文本(parseCqMessage 的逆操作)。 */
|
|
210
|
+
declare function serializeCqParts(parts: Array<string | CqCode>): string;
|
|
211
|
+
//#endregion
|
|
212
|
+
//#region src/onebot11/types/index.d.ts
|
|
213
|
+
/**
|
|
214
|
+
* OneBot 11 类型定义(自研描述,参考公开协议规范)
|
|
215
|
+
* 对应 ADR-001:接口签名是外部协议事实,可自研描述,不复制实现。
|
|
216
|
+
*/
|
|
217
|
+
/** OB11 统一返回结构。 */
|
|
218
|
+
interface OB11Return<T> {
|
|
219
|
+
status: "ok" | "failed";
|
|
220
|
+
retcode: number;
|
|
221
|
+
data: T;
|
|
222
|
+
message: string;
|
|
223
|
+
echo?: unknown;
|
|
224
|
+
}
|
|
225
|
+
/** OB11 消息段(segment)。 */
|
|
226
|
+
type OB11MessageSegment = {
|
|
227
|
+
type: "text";
|
|
228
|
+
data: {
|
|
229
|
+
text: string;
|
|
230
|
+
};
|
|
231
|
+
} | {
|
|
232
|
+
type: "at";
|
|
233
|
+
data: {
|
|
234
|
+
qq: string;
|
|
235
|
+
name?: string;
|
|
236
|
+
};
|
|
237
|
+
} | {
|
|
238
|
+
type: "face";
|
|
239
|
+
data: {
|
|
240
|
+
id: string;
|
|
241
|
+
};
|
|
242
|
+
} | {
|
|
243
|
+
type: "image";
|
|
244
|
+
data: {
|
|
245
|
+
file: string;
|
|
246
|
+
url?: string;
|
|
247
|
+
};
|
|
248
|
+
} | {
|
|
249
|
+
type: "record";
|
|
250
|
+
data: {
|
|
251
|
+
file: string;
|
|
252
|
+
url?: string;
|
|
253
|
+
};
|
|
254
|
+
} | {
|
|
255
|
+
type: "video";
|
|
256
|
+
data: {
|
|
257
|
+
file: string;
|
|
258
|
+
url?: string;
|
|
259
|
+
};
|
|
260
|
+
} | {
|
|
261
|
+
type: "reply";
|
|
262
|
+
data: {
|
|
263
|
+
id: string;
|
|
264
|
+
};
|
|
265
|
+
} | {
|
|
266
|
+
type: "forward";
|
|
267
|
+
data: {
|
|
268
|
+
id: string;
|
|
269
|
+
};
|
|
270
|
+
} | {
|
|
271
|
+
type: "json";
|
|
272
|
+
data: {
|
|
273
|
+
data: string;
|
|
274
|
+
};
|
|
275
|
+
} | {
|
|
276
|
+
type: "xml";
|
|
277
|
+
data: {
|
|
278
|
+
data: string;
|
|
279
|
+
};
|
|
280
|
+
} | {
|
|
281
|
+
type: "string";
|
|
282
|
+
data: {
|
|
283
|
+
text: string;
|
|
284
|
+
};
|
|
285
|
+
};
|
|
286
|
+
/** OB11 消息(segment 数组或 CQ 码字符串)。 */
|
|
287
|
+
type OB11Message = string | OB11MessageSegment[];
|
|
288
|
+
/** 消息发送来源。 */
|
|
289
|
+
interface Sender {
|
|
290
|
+
user_id: number;
|
|
291
|
+
nickname?: string;
|
|
292
|
+
card?: string;
|
|
293
|
+
role?: "owner" | "admin" | "member";
|
|
294
|
+
}
|
|
295
|
+
/** 群信息(get_group_info 返回)。 */
|
|
296
|
+
interface GroupInfo {
|
|
297
|
+
group_id: number;
|
|
298
|
+
group_name: string;
|
|
299
|
+
member_count?: number;
|
|
300
|
+
max_member_count?: number;
|
|
301
|
+
}
|
|
302
|
+
/** 登录信息(get_login_info 返回)。 */
|
|
303
|
+
interface LoginInfo {
|
|
304
|
+
user_id: number;
|
|
305
|
+
nickname: string;
|
|
306
|
+
}
|
|
307
|
+
/** OB11 消息信息(get_msg / 历史消息返回项)。 */
|
|
308
|
+
interface OB11MessageInfo {
|
|
309
|
+
message_id: number;
|
|
310
|
+
real_id?: number;
|
|
311
|
+
message_type: "group" | "private";
|
|
312
|
+
sender: {
|
|
313
|
+
user_id: number;
|
|
314
|
+
nickname: string;
|
|
315
|
+
card?: string;
|
|
316
|
+
role?: "owner" | "admin" | "member";
|
|
317
|
+
};
|
|
318
|
+
time: number;
|
|
319
|
+
message: OB11MessageSegment[];
|
|
320
|
+
raw_message: string;
|
|
321
|
+
group_id?: number;
|
|
322
|
+
user_id?: number;
|
|
323
|
+
}
|
|
324
|
+
/** 性别枚举。 */
|
|
325
|
+
type Sex = "male" | "female" | "unknown";
|
|
326
|
+
/** 群成员信息(get_group_member_info 返回,含 go-cqhttp 扩展字段)。 */
|
|
327
|
+
interface GroupMemberInfo {
|
|
328
|
+
group_id: number;
|
|
329
|
+
user_id: number;
|
|
330
|
+
nickname: string;
|
|
331
|
+
card?: string;
|
|
332
|
+
sex?: Sex;
|
|
333
|
+
age?: number;
|
|
334
|
+
area?: string;
|
|
335
|
+
join_time?: number;
|
|
336
|
+
last_sent_time?: number;
|
|
337
|
+
level?: string;
|
|
338
|
+
role: "owner" | "admin" | "member";
|
|
339
|
+
unfriendly?: boolean;
|
|
340
|
+
title?: string;
|
|
341
|
+
title_expire_time?: number;
|
|
342
|
+
card_changeable?: boolean;
|
|
343
|
+
/** go-cqhttp 扩展。 */
|
|
344
|
+
qq_level?: number;
|
|
345
|
+
group_level?: number;
|
|
346
|
+
special_title?: string;
|
|
347
|
+
shut_up_timestamp?: number;
|
|
348
|
+
is_friend?: boolean;
|
|
349
|
+
is_bot?: boolean;
|
|
350
|
+
}
|
|
351
|
+
/** 好友信息(get_friend_list 返回)。 */
|
|
352
|
+
interface FriendInfo {
|
|
353
|
+
user_id: number;
|
|
354
|
+
nickname: string;
|
|
355
|
+
remark?: string;
|
|
356
|
+
}
|
|
357
|
+
/** 陌生人信息(get_stranger_info 返回)。 */
|
|
358
|
+
interface StrangerInfo {
|
|
359
|
+
user_id: number;
|
|
360
|
+
nickname: string;
|
|
361
|
+
sex?: Sex;
|
|
362
|
+
age?: number;
|
|
363
|
+
/** go-cqhttp 扩展。 */
|
|
364
|
+
qid?: string;
|
|
365
|
+
level?: number;
|
|
366
|
+
login_days?: number;
|
|
367
|
+
uid?: string;
|
|
368
|
+
}
|
|
369
|
+
/** 群荣誉成员项(get_group_honor_info 返回列表项)。 */
|
|
370
|
+
interface HonorMember {
|
|
371
|
+
user_id: number;
|
|
372
|
+
nickname: string;
|
|
373
|
+
avatar?: string;
|
|
374
|
+
day_count?: number;
|
|
375
|
+
description?: string;
|
|
376
|
+
}
|
|
377
|
+
/** 当前龙王(可能为 null)。 */
|
|
378
|
+
interface CurrentTalkative {
|
|
379
|
+
user_id: number;
|
|
380
|
+
nickname: string;
|
|
381
|
+
day_count: number;
|
|
382
|
+
}
|
|
383
|
+
/** 群荣誉信息(get_group_honor_info 返回)。 */
|
|
384
|
+
interface GroupHonorInfo {
|
|
385
|
+
group_id: number;
|
|
386
|
+
current_talkative?: CurrentTalkative | null;
|
|
387
|
+
talkative_list: HonorMember[];
|
|
388
|
+
performer_list: HonorMember[];
|
|
389
|
+
legend_list: HonorMember[];
|
|
390
|
+
strong_newbie_list: HonorMember[];
|
|
391
|
+
emotion_list: HonorMember[];
|
|
392
|
+
}
|
|
393
|
+
/** 版本信息(get_version_info 返回,含 go-cqhttp 扩展字段)。 */
|
|
394
|
+
interface VersionInfo {
|
|
395
|
+
app_name: string;
|
|
396
|
+
app_version: string;
|
|
397
|
+
protocol_version: "v11";
|
|
398
|
+
/** go-cqhttp 扩展。 */
|
|
399
|
+
app_full_name?: string;
|
|
400
|
+
runtime_version?: string;
|
|
401
|
+
runtime_os?: string;
|
|
402
|
+
sign_library?: Record<string, unknown>;
|
|
403
|
+
configuration?: Record<string, unknown>;
|
|
404
|
+
walle_version?: string;
|
|
405
|
+
}
|
|
406
|
+
//#endregion
|
|
407
|
+
//#region src/onebot11/helper/data.d.ts
|
|
408
|
+
/** canonical 元素数组 → OB11 segment 数组(无法表达的元素静默跳过)。 */
|
|
409
|
+
declare function canonicalToSegments(elements: CanonicalElement[]): OB11MessageSegment[];
|
|
410
|
+
/** OB11 segment 数组 → canonical 元素数组。 */
|
|
411
|
+
declare function segmentsToCanonical(segments: OB11MessageSegment[]): CanonicalElement[];
|
|
412
|
+
/** OB11 segment 数组 → CQ 码字符串(text 段转义拼接,特殊段编码)。 */
|
|
413
|
+
declare function segmentsToCqMessage(segments: OB11MessageSegment[]): string;
|
|
414
|
+
/** CQ 码字符串 → OB11 segment 数组(未知 CQ 类型保留为 text 段原文)。 */
|
|
415
|
+
declare function cqMessageToSegments(text: string): OB11MessageSegment[];
|
|
416
|
+
/** canonical 元素数组 → CQ 码字符串。 */
|
|
417
|
+
declare function canonicalToCqMessage(elements: CanonicalElement[]): string;
|
|
418
|
+
/** CQ 码字符串 → canonical 元素数组。 */
|
|
419
|
+
declare function cqMessageToCanonical(text: string): CanonicalElement[];
|
|
420
|
+
//#endregion
|
|
421
|
+
//#region src/onebot11/event/base.d.ts
|
|
422
|
+
/**
|
|
423
|
+
* OneBot 11 事件基类(OB11 公开协议规范,自研描述)
|
|
424
|
+
*
|
|
425
|
+
* 所有事件共有的三个字段:time(Unix 秒)/ self_id(机器人 QQ 号)/ post_type(事件大类)。
|
|
426
|
+
* 各事件类型通过 post_type + 二级判别字段(message_type/notice_type/request_type/meta_event_type)
|
|
427
|
+
* 组成可判别联合,适配器广播与第三方框架消费都靠判别字段收窄。
|
|
428
|
+
*/
|
|
429
|
+
/** OB11 post_type(事件大类)。 */
|
|
430
|
+
type OB11PostType = "message" | "notice" | "request" | "meta_event";
|
|
431
|
+
/** OB11 事件基类。 */
|
|
432
|
+
interface OB11BaseEvent {
|
|
433
|
+
/** 事件发生时间(Unix 秒)。 */
|
|
434
|
+
time: number;
|
|
435
|
+
/** 机器人自身 QQ 号。 */
|
|
436
|
+
self_id: number;
|
|
437
|
+
/** 事件大类。 */
|
|
438
|
+
post_type: OB11PostType;
|
|
439
|
+
}
|
|
440
|
+
//#endregion
|
|
441
|
+
//#region src/onebot11/event/message.d.ts
|
|
442
|
+
/** 匿名用户信息(群匿名消息,go-cqhttp 兼容)。 */
|
|
443
|
+
interface Anonymous {
|
|
444
|
+
id: number;
|
|
445
|
+
name: string;
|
|
446
|
+
flag: string;
|
|
447
|
+
}
|
|
448
|
+
/** 群消息发送者(role 必填 + 群头衔)。 */
|
|
449
|
+
interface GroupSender extends Sender {
|
|
450
|
+
role: "owner" | "admin" | "member";
|
|
451
|
+
title?: string;
|
|
452
|
+
}
|
|
453
|
+
/** 群消息事件。 */
|
|
454
|
+
interface OB11GroupMessageEvent extends OB11BaseEvent {
|
|
455
|
+
post_type: "message";
|
|
456
|
+
message_type: "group";
|
|
457
|
+
/** 消息子类型:normal 普通 / anonymous 匿名 / notice 系统提示。 */
|
|
458
|
+
sub_type: "normal" | "anonymous" | "notice";
|
|
459
|
+
message_id: number;
|
|
460
|
+
group_id: number;
|
|
461
|
+
user_id: number;
|
|
462
|
+
message: OB11Message;
|
|
463
|
+
raw_message: string;
|
|
464
|
+
font: number;
|
|
465
|
+
sender: GroupSender;
|
|
466
|
+
anonymous?: Anonymous;
|
|
467
|
+
}
|
|
468
|
+
/** 私聊消息事件。 */
|
|
469
|
+
interface OB11PrivateMessageEvent extends OB11BaseEvent {
|
|
470
|
+
post_type: "message";
|
|
471
|
+
message_type: "private";
|
|
472
|
+
/** 消息子类型:friend 好友 / group 临时会话 / other / self 自身。 */
|
|
473
|
+
sub_type: "friend" | "group" | "other" | "self";
|
|
474
|
+
message_id: number;
|
|
475
|
+
user_id: number;
|
|
476
|
+
message: OB11Message;
|
|
477
|
+
raw_message: string;
|
|
478
|
+
font: number;
|
|
479
|
+
sender: Sender;
|
|
480
|
+
/** 临时会话来源(0=未知,其他=来源群号)。 */
|
|
481
|
+
temp_source?: number;
|
|
482
|
+
}
|
|
483
|
+
/** OB11 消息事件联合。 */
|
|
484
|
+
type OB11MessageEvent = OB11GroupMessageEvent | OB11PrivateMessageEvent;
|
|
485
|
+
//#endregion
|
|
486
|
+
//#region src/onebot11/event/meta.d.ts
|
|
487
|
+
/** 运行状态(get_status 返回 + 心跳 status,扩展字段透传)。 */
|
|
488
|
+
interface OB11Status {
|
|
489
|
+
online: boolean;
|
|
490
|
+
good: boolean;
|
|
491
|
+
[key: string]: unknown;
|
|
492
|
+
}
|
|
493
|
+
/** 生命周期事件(适配器 enable/disable/connect 时广播)。 */
|
|
494
|
+
interface OB11LifecycleMetaEvent extends OB11BaseEvent {
|
|
495
|
+
post_type: "meta_event";
|
|
496
|
+
meta_event_type: "lifecycle";
|
|
497
|
+
sub_type: "enable" | "disable" | "connect";
|
|
498
|
+
}
|
|
499
|
+
/** 心跳事件(按配置 interval 毫秒定时广播)。 */
|
|
500
|
+
interface OB11HeartbeatMetaEvent extends OB11BaseEvent {
|
|
501
|
+
post_type: "meta_event";
|
|
502
|
+
meta_event_type: "heartbeat";
|
|
503
|
+
/** 心跳间隔(毫秒)。 */
|
|
504
|
+
interval: number;
|
|
505
|
+
status: OB11Status;
|
|
506
|
+
}
|
|
507
|
+
/** OB11 元事件联合。 */
|
|
508
|
+
type OB11MetaEvent = OB11LifecycleMetaEvent | OB11HeartbeatMetaEvent;
|
|
509
|
+
//#endregion
|
|
510
|
+
//#region src/onebot11/event/notice.d.ts
|
|
511
|
+
/** 群文件信息(group_upload 的 file 字段)。 */
|
|
512
|
+
interface GroupFileInfo {
|
|
513
|
+
id: string;
|
|
514
|
+
name: string;
|
|
515
|
+
size: number;
|
|
516
|
+
busid: number;
|
|
517
|
+
}
|
|
518
|
+
/** 离线文件信息(offline_file 的 file 字段)。 */
|
|
519
|
+
interface OfflineFileInfo {
|
|
520
|
+
name: string;
|
|
521
|
+
size: number;
|
|
522
|
+
url: string;
|
|
523
|
+
}
|
|
524
|
+
/** 消息表情回应项(msg_emoji_like 的 likes 项)。 */
|
|
525
|
+
interface EmojiLikeItem {
|
|
526
|
+
nickname: string;
|
|
527
|
+
user_id: number;
|
|
528
|
+
face_id: number;
|
|
529
|
+
}
|
|
530
|
+
/** 群文件上传(群成员上传了文件)。 */
|
|
531
|
+
interface OB11GroupUploadNoticeEvent extends OB11BaseEvent {
|
|
532
|
+
post_type: "notice";
|
|
533
|
+
notice_type: "group_upload";
|
|
534
|
+
group_id: number;
|
|
535
|
+
user_id: number;
|
|
536
|
+
file: GroupFileInfo;
|
|
537
|
+
}
|
|
538
|
+
/** 群管理员变更。 */
|
|
539
|
+
interface OB11GroupAdminNoticeEvent extends OB11BaseEvent {
|
|
540
|
+
post_type: "notice";
|
|
541
|
+
notice_type: "group_admin";
|
|
542
|
+
sub_type: "set" | "unset";
|
|
543
|
+
group_id: number;
|
|
544
|
+
user_id: number;
|
|
545
|
+
}
|
|
546
|
+
/** 群成员减少(主动退群 / 被踢 / 机器人被踢)。 */
|
|
547
|
+
interface OB11GroupDecreaseNoticeEvent extends OB11BaseEvent {
|
|
548
|
+
post_type: "notice";
|
|
549
|
+
notice_type: "group_decrease";
|
|
550
|
+
sub_type: "leave" | "kick" | "kick_me";
|
|
551
|
+
group_id: number;
|
|
552
|
+
operator_id: number;
|
|
553
|
+
user_id: number;
|
|
554
|
+
}
|
|
555
|
+
/** 群成员增加(管理员同意入群 / 成员邀请入群)。 */
|
|
556
|
+
interface OB11GroupIncreaseNoticeEvent extends OB11BaseEvent {
|
|
557
|
+
post_type: "notice";
|
|
558
|
+
notice_type: "group_increase";
|
|
559
|
+
sub_type: "approve" | "invite";
|
|
560
|
+
group_id: number;
|
|
561
|
+
operator_id: number;
|
|
562
|
+
user_id: number;
|
|
563
|
+
}
|
|
564
|
+
/** 群禁言(禁言 / 解除禁言)。 */
|
|
565
|
+
interface OB11GroupBanNoticeEvent extends OB11BaseEvent {
|
|
566
|
+
post_type: "notice";
|
|
567
|
+
notice_type: "group_ban";
|
|
568
|
+
sub_type: "ban" | "lift_ban";
|
|
569
|
+
group_id: number;
|
|
570
|
+
operator_id: number;
|
|
571
|
+
user_id: number;
|
|
572
|
+
/** 禁言时长(秒,0 表示解除禁言)。 */
|
|
573
|
+
duration: number;
|
|
574
|
+
}
|
|
575
|
+
/** 好友添加。 */
|
|
576
|
+
interface OB11FriendAddNoticeEvent extends OB11BaseEvent {
|
|
577
|
+
post_type: "notice";
|
|
578
|
+
notice_type: "friend_add";
|
|
579
|
+
user_id: number;
|
|
580
|
+
}
|
|
581
|
+
/** 群消息撤回。 */
|
|
582
|
+
interface OB11GroupRecallNoticeEvent extends OB11BaseEvent {
|
|
583
|
+
post_type: "notice";
|
|
584
|
+
notice_type: "group_recall";
|
|
585
|
+
group_id: number;
|
|
586
|
+
user_id: number;
|
|
587
|
+
operator_id: number;
|
|
588
|
+
message_id: number;
|
|
589
|
+
}
|
|
590
|
+
/** 好友消息撤回。 */
|
|
591
|
+
interface OB11FriendRecallNoticeEvent extends OB11BaseEvent {
|
|
592
|
+
post_type: "notice";
|
|
593
|
+
notice_type: "friend_recall";
|
|
594
|
+
user_id: number;
|
|
595
|
+
message_id: number;
|
|
596
|
+
}
|
|
597
|
+
/** 群成员名片变更(go-cqhttp 扩展)。 */
|
|
598
|
+
interface OB11GroupCardNoticeEvent extends OB11BaseEvent {
|
|
599
|
+
post_type: "notice";
|
|
600
|
+
notice_type: "group_card";
|
|
601
|
+
group_id: number;
|
|
602
|
+
user_id: number;
|
|
603
|
+
card_new: string;
|
|
604
|
+
card_old: string;
|
|
605
|
+
}
|
|
606
|
+
/** 群消息精华(go-cqhttp 扩展)。 */
|
|
607
|
+
interface OB11GroupEssenceNoticeEvent extends OB11BaseEvent {
|
|
608
|
+
post_type: "notice";
|
|
609
|
+
notice_type: "group_essence";
|
|
610
|
+
sub_type: "add" | "delete";
|
|
611
|
+
group_id: number;
|
|
612
|
+
sender_id: number;
|
|
613
|
+
operator_id: number;
|
|
614
|
+
message_id: number;
|
|
615
|
+
}
|
|
616
|
+
/** 系统通知(go-cqhttp 扩展):戳一戳 / 红包运气王 / 群荣誉。 */
|
|
617
|
+
interface OB11NotifyNoticeEvent extends OB11BaseEvent {
|
|
618
|
+
post_type: "notice";
|
|
619
|
+
notice_type: "notify";
|
|
620
|
+
sub_type: "poke" | "lucky_notify" | "honor";
|
|
621
|
+
group_id: number;
|
|
622
|
+
user_id: number;
|
|
623
|
+
target_id: number;
|
|
624
|
+
/** honor 子类型时的荣誉类型(talkative 龙王 / performer 群聊之火 / emotion 快乐源泉)。 */
|
|
625
|
+
honor_type?: "talkative" | "performer" | "emotion";
|
|
626
|
+
}
|
|
627
|
+
/** 离线文件上传(go-cqhttp 扩展)。 */
|
|
628
|
+
interface OB11OfflineFileNoticeEvent extends OB11BaseEvent {
|
|
629
|
+
post_type: "notice";
|
|
630
|
+
notice_type: "offline_file";
|
|
631
|
+
user_id: number;
|
|
632
|
+
file: OfflineFileInfo;
|
|
633
|
+
}
|
|
634
|
+
/** 群签到(NapCat 扩展)。 */
|
|
635
|
+
interface OB11GroupSignNoticeEvent extends OB11BaseEvent {
|
|
636
|
+
post_type: "notice";
|
|
637
|
+
notice_type: "group_sign";
|
|
638
|
+
group_id: number;
|
|
639
|
+
user_id: number;
|
|
640
|
+
}
|
|
641
|
+
/** 消息表情回应(NapCat 扩展)。 */
|
|
642
|
+
interface OB11MsgEmojiLikeNoticeEvent extends OB11BaseEvent {
|
|
643
|
+
post_type: "notice";
|
|
644
|
+
notice_type: "msg_emoji_like";
|
|
645
|
+
user_id: number;
|
|
646
|
+
group_id: number;
|
|
647
|
+
message_id: number;
|
|
648
|
+
likes: EmojiLikeItem[];
|
|
649
|
+
}
|
|
650
|
+
/** 群成员头衔变更(NapCat 扩展)。 */
|
|
651
|
+
interface OB11GroupTitleNoticeEvent extends OB11BaseEvent {
|
|
652
|
+
post_type: "notice";
|
|
653
|
+
notice_type: "group_title";
|
|
654
|
+
group_id: number;
|
|
655
|
+
user_id: number;
|
|
656
|
+
title: string;
|
|
657
|
+
}
|
|
658
|
+
/** OB11 通知事件联合。 */
|
|
659
|
+
type OB11NoticeEvent = OB11GroupUploadNoticeEvent | OB11GroupAdminNoticeEvent | OB11GroupDecreaseNoticeEvent | OB11GroupIncreaseNoticeEvent | OB11GroupBanNoticeEvent | OB11FriendAddNoticeEvent | OB11GroupRecallNoticeEvent | OB11FriendRecallNoticeEvent | OB11GroupCardNoticeEvent | OB11GroupEssenceNoticeEvent | OB11NotifyNoticeEvent | OB11OfflineFileNoticeEvent | OB11GroupSignNoticeEvent | OB11MsgEmojiLikeNoticeEvent | OB11GroupTitleNoticeEvent;
|
|
660
|
+
//#endregion
|
|
661
|
+
//#region src/onebot11/event/request.d.ts
|
|
662
|
+
/** 加好友请求。 */
|
|
663
|
+
interface OB11FriendRequestEvent extends OB11BaseEvent {
|
|
664
|
+
post_type: "request";
|
|
665
|
+
request_type: "friend";
|
|
666
|
+
user_id: number;
|
|
667
|
+
/** 验证信息。 */
|
|
668
|
+
comment: string;
|
|
669
|
+
/** 请求 flag,应答时原样传回。 */
|
|
670
|
+
flag: string;
|
|
671
|
+
}
|
|
672
|
+
/** 加群请求 / 邀请。 */
|
|
673
|
+
interface OB11GroupRequestEvent extends OB11BaseEvent {
|
|
674
|
+
post_type: "request";
|
|
675
|
+
request_type: "group";
|
|
676
|
+
/** add 他人申请入群 / invite 群主或管理邀请。 */
|
|
677
|
+
sub_type: "add" | "invite";
|
|
678
|
+
group_id: number;
|
|
679
|
+
user_id: number;
|
|
680
|
+
comment: string;
|
|
681
|
+
flag: string;
|
|
682
|
+
}
|
|
683
|
+
/** OB11 请求事件联合。 */
|
|
684
|
+
type OB11RequestEvent = OB11FriendRequestEvent | OB11GroupRequestEvent;
|
|
685
|
+
//#endregion
|
|
686
|
+
//#region src/onebot11/event/index.d.ts
|
|
687
|
+
/** OB11 事件联合(所有事件共用 time/self_id/post_type,按 post_type 收窄)。 */
|
|
688
|
+
type OB11Event = OB11MessageEvent | OB11NoticeEvent | OB11RequestEvent | OB11MetaEvent;
|
|
689
|
+
//#endregion
|
|
690
|
+
//#region src/onebot11/adapter.d.ts
|
|
691
|
+
/** 适配器构造参数(api 相关字段继承 OneBotApiOptions,P2-16 聚合)。 */
|
|
692
|
+
interface OneBot11AdapterOptions extends OneBotApiOptions {
|
|
693
|
+
/** 协议配置(zod 校验 + JSON 读写)。 */
|
|
694
|
+
config: ProtocolConfig<OB11Config>;
|
|
695
|
+
/** network 事件广播(注册传输适配器后 emit 推给第三方)。 */
|
|
696
|
+
broadcaster: EventBroadcaster;
|
|
697
|
+
/** kernel 消息事件通道(消息收链路入口)。 */
|
|
698
|
+
msgChannel: MsgEventChannel;
|
|
699
|
+
}
|
|
700
|
+
/** OneBot 11 协议适配器。 */
|
|
701
|
+
declare class NapukettoOneBot11Adapter extends BaseProtocolAdapter<OB11Config> {
|
|
702
|
+
readonly protocol = "onebot11";
|
|
703
|
+
readonly configSchema: import("zod").ZodObject<{
|
|
704
|
+
token: import("zod").ZodOptional<import("zod").ZodString>;
|
|
705
|
+
heartbeatInterval: import("zod").ZodDefault<import("zod").ZodNumber>;
|
|
706
|
+
reportSelfMessage: import("zod").ZodDefault<import("zod").ZodBoolean>;
|
|
707
|
+
messagePostFormat: import("zod").ZodDefault<import("zod").ZodEnum<{
|
|
708
|
+
array: "array";
|
|
709
|
+
string: "string";
|
|
710
|
+
}>>;
|
|
711
|
+
httpServers: import("zod").ZodDefault<import("zod").ZodArray<import("zod").ZodObject<{
|
|
712
|
+
enabled: import("zod").ZodDefault<import("zod").ZodBoolean>;
|
|
713
|
+
host: import("zod").ZodDefault<import("zod").ZodString>;
|
|
714
|
+
port: import("zod").ZodDefault<import("zod").ZodNumber>;
|
|
715
|
+
token: import("zod").ZodOptional<import("zod").ZodString>;
|
|
716
|
+
}, import("zod/v4/core").$strip>>>;
|
|
717
|
+
httpPostUrls: import("zod").ZodDefault<import("zod").ZodArray<import("zod").ZodObject<{
|
|
718
|
+
enabled: import("zod").ZodDefault<import("zod").ZodBoolean>;
|
|
719
|
+
url: import("zod").ZodOptional<import("zod").ZodString>;
|
|
720
|
+
token: import("zod").ZodOptional<import("zod").ZodString>;
|
|
721
|
+
timeoutMs: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
722
|
+
}, import("zod/v4/core").$strip>>>;
|
|
723
|
+
wsServers: import("zod").ZodDefault<import("zod").ZodArray<import("zod").ZodObject<{
|
|
724
|
+
enabled: import("zod").ZodDefault<import("zod").ZodBoolean>;
|
|
725
|
+
host: import("zod").ZodDefault<import("zod").ZodString>;
|
|
726
|
+
port: import("zod").ZodDefault<import("zod").ZodNumber>;
|
|
727
|
+
token: import("zod").ZodOptional<import("zod").ZodString>;
|
|
728
|
+
heartbeatInterval: import("zod").ZodDefault<import("zod").ZodNumber>;
|
|
729
|
+
}, import("zod/v4/core").$strip>>>;
|
|
730
|
+
wsReverseUrls: import("zod").ZodDefault<import("zod").ZodArray<import("zod").ZodObject<{
|
|
731
|
+
enabled: import("zod").ZodDefault<import("zod").ZodBoolean>;
|
|
732
|
+
url: import("zod").ZodOptional<import("zod").ZodString>;
|
|
733
|
+
token: import("zod").ZodOptional<import("zod").ZodString>;
|
|
734
|
+
reconnectDelayMs: import("zod").ZodDefault<import("zod").ZodNumber>;
|
|
735
|
+
maxReconnectAttempts: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
736
|
+
rejectUnauthorized: import("zod").ZodDefault<import("zod").ZodBoolean>;
|
|
737
|
+
heartbeatInterval: import("zod").ZodDefault<import("zod").ZodNumber>;
|
|
738
|
+
}, import("zod/v4/core").$strip>>>;
|
|
739
|
+
}, import("zod/v4/core").$strip>;
|
|
740
|
+
private readonly msgChannel;
|
|
741
|
+
private readonly selfUin;
|
|
742
|
+
private readonly oneBotApi;
|
|
743
|
+
private readonly registry;
|
|
744
|
+
private unsubscribe;
|
|
745
|
+
private transports;
|
|
746
|
+
private heartbeatTimer;
|
|
747
|
+
private reportSelfMessage;
|
|
748
|
+
private messageFormat;
|
|
749
|
+
constructor(opts: OneBot11AdapterOptions);
|
|
750
|
+
/** 启动传输:装配(HTTP/WS)+ 打开 server/client + 广播 lifecycle enable + 起心跳。 */
|
|
751
|
+
private startTransports;
|
|
752
|
+
/** 心跳 meta 事件(interval 毫秒,0 关闭)。 */
|
|
753
|
+
private startHeartbeat;
|
|
754
|
+
/** 停止:心跳 + 传输 + 退订。 */
|
|
755
|
+
private stopAll;
|
|
756
|
+
/** 订阅 kernel 消息事件(幂等)。 */
|
|
757
|
+
private subscribe;
|
|
758
|
+
/**
|
|
759
|
+
* 广播消息事件(P2-19:接收方向 ID 转换)。
|
|
760
|
+
* 收集 at uid → 一次批量 uidToUin → 构造上下文 → 翻译广播。
|
|
761
|
+
* 翻译失败退化为原样(不阻塞上报)。
|
|
762
|
+
*/
|
|
763
|
+
private broadcastMessageEvent;
|
|
764
|
+
/** 广播 grayTip → notice 事件(批量 uidToUin 后翻译,纯函数)。 */
|
|
765
|
+
private broadcastNotice;
|
|
766
|
+
/** 退订(幂等)。 */
|
|
767
|
+
private unsubscribeAll;
|
|
768
|
+
/**
|
|
769
|
+
* 请求分发(挂到 network transport 的 onRequest):
|
|
770
|
+
* OB11 标准请求 { action, params, echo } → 动作注册表 → handle(HTTP)/websocketHandle(WS)。
|
|
771
|
+
*/
|
|
772
|
+
handleRequest(req: unknown, respond: (res: unknown) => void): Promise<void>;
|
|
773
|
+
}
|
|
774
|
+
//#endregion
|
|
775
|
+
//#region src/onebot11/transport.d.ts
|
|
776
|
+
/** 传输装配结果。 */
|
|
777
|
+
interface Ob11TransportSet {
|
|
778
|
+
/** 反向 server(HTTP/WS,第三方调用入口)。 */
|
|
779
|
+
servers: TransportAdapter[];
|
|
780
|
+
/** 事件上报传输(正向 client,已注册到 broadcaster)。 */
|
|
781
|
+
transports: TransportAdapter[];
|
|
782
|
+
/** 停止:关闭全部传输(幂等)。 */
|
|
783
|
+
close: () => Promise<void>;
|
|
784
|
+
}
|
|
785
|
+
/** 传输装配选项。 */
|
|
786
|
+
interface AssembleOb11TransportsOptions {
|
|
787
|
+
/** OB11 配置。 */
|
|
788
|
+
config: OB11Config;
|
|
789
|
+
/** 事件广播(正向上报传输注册到它)。 */
|
|
790
|
+
broadcaster: EventBroadcaster;
|
|
791
|
+
/** 请求分发(adapter.handleRequest,HTTP/WS 共用)。 */
|
|
792
|
+
handleRequest: (req: unknown, respond: (res: unknown) => void) => void;
|
|
793
|
+
}
|
|
794
|
+
/** 按配置装配 OB11 传输。 */
|
|
795
|
+
declare function assembleOb11Transports(opts: AssembleOb11TransportsOptions): Ob11TransportSet;
|
|
796
|
+
//#endregion
|
|
797
|
+
export { type AssembleOb11TransportsOptions, type AtAllRemainInfo, type CqCode, type CurrentTalkative, type FriendInfo, type GroupHonorInfo, type GroupInfo, type GroupMemberInfo, type HonorMember, type LoginInfo, MessageUnique, NapukettoOneBot11Adapter, type OB11BaseEvent, type OB11Config, type OB11Event, type OB11FriendRequestEvent, type OB11GroupMessageEvent, type OB11GroupRequestEvent, type OB11HeartbeatMetaEvent, type OB11LifecycleMetaEvent, type OB11Message, type OB11MessageEvent, type OB11MessageInfo, type OB11MessageSegment, type OB11MetaEvent, type OB11NoticeEvent, type OB11PostType, type OB11PrivateMessageEvent, type OB11RequestEvent, type OB11Return, type OB11Status, type Ob11ActionDeps, type Ob11TransportSet, type OneBot11AdapterOptions, OneBotApi, type OneBotApiOptions, type OneBotSystemOptions, type Sender, type Sex, type StrangerInfo, type VersionInfo, assembleOb11Transports, canonicalToCqMessage, canonicalToSegments, cqMessageToCanonical, cqMessageToSegments, createOb11ActionRegistry, encodeCqCode, escapeCqParam, escapeCqText, ob11ConfigSchema, ob11ErrorCodeMap, parseCqMessage, segmentsToCanonical, segmentsToCqMessage, serializeCqParts, unescapeCqText };
|
|
798
|
+
//# sourceMappingURL=index.d.mts.map
|