@zhin.js/adapter-napcat 3.0.2 → 5.0.0
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/CHANGELOG.md +62 -0
- package/README.md +47 -98
- package/adapters/napcat.ts +39 -0
- package/agent/tools/ai_tts.ts +2 -2
- package/agent/tools/del_group_notice.ts +2 -2
- package/agent/tools/delete_essence_msg.ts +2 -2
- package/agent/tools/delete_friend.ts +2 -2
- package/agent/tools/download_file.ts +2 -2
- package/agent/tools/forward_single_msg.ts +2 -2
- package/agent/tools/get_ai_characters.ts +2 -2
- package/agent/tools/get_essence_list.ts +2 -2
- package/agent/tools/get_friend_msg_history.ts +2 -2
- package/agent/tools/get_group_file_url.ts +2 -2
- package/agent/tools/get_group_info_ex.ts +2 -2
- package/agent/tools/get_group_msg_history.ts +2 -2
- package/agent/tools/get_group_notice.ts +2 -2
- package/agent/tools/get_group_root_files.ts +2 -2
- package/agent/tools/get_group_shut_list.ts +2 -2
- package/agent/tools/get_mini_app_ark.ts +2 -2
- package/agent/tools/get_user_status.ts +2 -2
- package/agent/tools/group_sign.ts +2 -2
- package/agent/tools/mark_msg_as_read.ts +2 -2
- package/agent/tools/ocr_image.ts +2 -2
- package/agent/tools/send_forward_msg.ts +2 -2
- package/agent/tools/send_group_notice.ts +2 -2
- package/agent/tools/send_like.ts +2 -2
- package/agent/tools/send_poke.ts +2 -2
- package/agent/tools/set_avatar.ts +2 -2
- package/agent/tools/set_emoji_reaction.ts +2 -2
- package/agent/tools/set_essence_msg.ts +2 -2
- package/agent/tools/set_group_portrait.ts +2 -2
- package/agent/tools/set_online_status.ts +2 -2
- package/agent/tools/set_profile.ts +2 -2
- package/agent/tools/set_signature.ts +2 -2
- package/agent/tools/set_title.ts +2 -2
- package/agent/tools/translate.ts +2 -2
- package/agent/tools/upload_group_file.ts +2 -2
- package/lib/http-endpoint.d.ts +26 -0
- package/lib/http-endpoint.js +147 -0
- package/lib/index.d.ts +11 -0
- package/lib/index.js +10 -0
- package/lib/napcat-agent-deps.d.ts +51 -0
- package/lib/napcat-agent-deps.js +33 -0
- package/lib/napcat-inbound.d.ts +28 -0
- package/lib/{src/napcat-inbound.js → napcat-inbound.js} +28 -13
- package/lib/onebot-get-msg.d.ts +14 -0
- package/lib/{src/onebot-get-msg.js → onebot-get-msg.js} +0 -1
- package/lib/protocol.d.ts +151 -0
- package/lib/protocol.js +217 -0
- package/lib/webhook.d.ts +2 -0
- package/lib/webhook.js +14 -0
- package/lib/ws-endpoint.d.ts +61 -0
- package/lib/ws-endpoint.js +357 -0
- package/lib/ws-transport.d.ts +13 -0
- package/lib/ws-transport.js +75 -0
- package/lib/ws-types.d.ts +17 -0
- package/lib/ws-types.js +1 -0
- package/lib/wss-auth.d.ts +2 -0
- package/lib/wss-auth.js +16 -0
- package/lib/wss-endpoint.d.ts +25 -0
- package/lib/wss-endpoint.js +157 -0
- package/package.json +44 -33
- package/plugin.ts +13 -0
- package/schema.json +74 -0
- package/src/http-endpoint.ts +197 -0
- package/src/index.ts +66 -81
- package/src/napcat-agent-deps.ts +81 -15
- package/src/napcat-inbound.ts +34 -10
- package/src/onebot-get-msg.ts +8 -2
- package/src/protocol.ts +373 -0
- package/src/webhook.ts +16 -0
- package/src/ws-endpoint.ts +452 -0
- package/src/ws-transport.ts +105 -0
- package/src/ws-types.ts +20 -0
- package/src/wss-auth.ts +17 -0
- package/src/wss-endpoint.ts +205 -0
- package/client/NapCatManagement.tsx +0 -113
- package/client/index.tsx +0 -11
- package/client/tsconfig.json +0 -7
- package/client/utils/api.ts +0 -30
- package/dist/index.js +0 -27
- package/lib/agent/tools/ai_tts.js +0 -21
- package/lib/agent/tools/ai_tts.js.map +0 -1
- package/lib/agent/tools/del_group_notice.js +0 -22
- package/lib/agent/tools/del_group_notice.js.map +0 -1
- package/lib/agent/tools/delete_essence_msg.js +0 -21
- package/lib/agent/tools/delete_essence_msg.js.map +0 -1
- package/lib/agent/tools/delete_friend.js +0 -20
- package/lib/agent/tools/delete_friend.js.map +0 -1
- package/lib/agent/tools/download_file.js +0 -19
- package/lib/agent/tools/download_file.js.map +0 -1
- package/lib/agent/tools/forward_single_msg.js +0 -24
- package/lib/agent/tools/forward_single_msg.js.map +0 -1
- package/lib/agent/tools/get_ai_characters.js +0 -19
- package/lib/agent/tools/get_ai_characters.js.map +0 -1
- package/lib/agent/tools/get_essence_list.js +0 -19
- package/lib/agent/tools/get_essence_list.js.map +0 -1
- package/lib/agent/tools/get_friend_msg_history.js +0 -20
- package/lib/agent/tools/get_friend_msg_history.js.map +0 -1
- package/lib/agent/tools/get_group_file_url.js +0 -21
- package/lib/agent/tools/get_group_file_url.js.map +0 -1
- package/lib/agent/tools/get_group_info_ex.js +0 -19
- package/lib/agent/tools/get_group_info_ex.js.map +0 -1
- package/lib/agent/tools/get_group_msg_history.js +0 -21
- package/lib/agent/tools/get_group_msg_history.js.map +0 -1
- package/lib/agent/tools/get_group_notice.js +0 -19
- package/lib/agent/tools/get_group_notice.js.map +0 -1
- package/lib/agent/tools/get_group_root_files.js +0 -19
- package/lib/agent/tools/get_group_root_files.js.map +0 -1
- package/lib/agent/tools/get_group_shut_list.js +0 -19
- package/lib/agent/tools/get_group_shut_list.js.map +0 -1
- package/lib/agent/tools/get_mini_app_ark.js +0 -22
- package/lib/agent/tools/get_mini_app_ark.js.map +0 -1
- package/lib/agent/tools/get_user_status.js +0 -18
- package/lib/agent/tools/get_user_status.js.map +0 -1
- package/lib/agent/tools/group_sign.js +0 -20
- package/lib/agent/tools/group_sign.js.map +0 -1
- package/lib/agent/tools/mark_msg_as_read.js +0 -19
- package/lib/agent/tools/mark_msg_as_read.js.map +0 -1
- package/lib/agent/tools/ocr_image.js +0 -18
- package/lib/agent/tools/ocr_image.js.map +0 -1
- package/lib/agent/tools/send_forward_msg.js +0 -21
- package/lib/agent/tools/send_forward_msg.js.map +0 -1
- package/lib/agent/tools/send_group_notice.js +0 -23
- package/lib/agent/tools/send_group_notice.js.map +0 -1
- package/lib/agent/tools/send_like.js +0 -20
- package/lib/agent/tools/send_like.js.map +0 -1
- package/lib/agent/tools/send_poke.js +0 -20
- package/lib/agent/tools/send_poke.js.map +0 -1
- package/lib/agent/tools/set_avatar.js +0 -19
- package/lib/agent/tools/set_avatar.js.map +0 -1
- package/lib/agent/tools/set_emoji_reaction.js +0 -20
- package/lib/agent/tools/set_emoji_reaction.js.map +0 -1
- package/lib/agent/tools/set_essence_msg.js +0 -21
- package/lib/agent/tools/set_essence_msg.js.map +0 -1
- package/lib/agent/tools/set_group_portrait.js +0 -22
- package/lib/agent/tools/set_group_portrait.js.map +0 -1
- package/lib/agent/tools/set_online_status.js +0 -20
- package/lib/agent/tools/set_online_status.js.map +0 -1
- package/lib/agent/tools/set_profile.js +0 -23
- package/lib/agent/tools/set_profile.js.map +0 -1
- package/lib/agent/tools/set_signature.js +0 -19
- package/lib/agent/tools/set_signature.js.map +0 -1
- package/lib/agent/tools/set_title.js +0 -23
- package/lib/agent/tools/set_title.js.map +0 -1
- package/lib/agent/tools/translate.js +0 -18
- package/lib/agent/tools/translate.js.map +0 -1
- package/lib/agent/tools/upload_group_file.js +0 -23
- package/lib/agent/tools/upload_group_file.js.map +0 -1
- package/lib/src/adapter.js +0 -102
- package/lib/src/adapter.js.map +0 -1
- package/lib/src/agent-prompt.js +0 -106
- package/lib/src/agent-prompt.js.map +0 -1
- package/lib/src/endpoint-base.js +0 -315
- package/lib/src/endpoint-base.js.map +0 -1
- package/lib/src/endpoint-http.js +0 -106
- package/lib/src/endpoint-http.js.map +0 -1
- package/lib/src/endpoint-ws-client.js +0 -139
- package/lib/src/endpoint-ws-client.js.map +0 -1
- package/lib/src/endpoint-ws-server.js +0 -137
- package/lib/src/endpoint-ws-server.js.map +0 -1
- package/lib/src/index.js +0 -58
- package/lib/src/index.js.map +0 -1
- package/lib/src/napcat-agent-deps.js +0 -19
- package/lib/src/napcat-agent-deps.js.map +0 -1
- package/lib/src/napcat-inbound.js.map +0 -1
- package/lib/src/onebot-get-msg.js.map +0 -1
- package/lib/src/routes.js +0 -61
- package/lib/src/routes.js.map +0 -1
- package/lib/src/segment-mapper.js +0 -2
- package/lib/src/segment-mapper.js.map +0 -1
- package/lib/src/types.js +0 -6
- package/lib/src/types.js.map +0 -1
- package/plugin.yml +0 -3
- package/src/adapter.ts +0 -109
- package/src/agent-prompt.ts +0 -115
- package/src/endpoint-base.ts +0 -362
- package/src/endpoint-http.ts +0 -95
- package/src/endpoint-ws-client.ts +0 -137
- package/src/endpoint-ws-server.ts +0 -136
- package/src/routes.ts +0 -61
- package/src/segment-mapper.ts +0 -1
- package/src/types.ts +0 -266
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { defineTool } from '@zhin.js/agent/tools';
|
|
2
|
-
import { z } from 'zod';
|
|
3
|
-
import { getEndpoint } from '../../src/napcat-agent-deps.js';
|
|
4
|
-
export default defineTool({
|
|
5
|
-
description: '英译中翻译。',
|
|
6
|
-
inputSchema: z.object({
|
|
7
|
-
endpoint_id: z.string().describe('Endpoint 名称'),
|
|
8
|
-
text: z.string().describe('要翻译的英文文本'),
|
|
9
|
-
}),
|
|
10
|
-
platforms: ['napcat'],
|
|
11
|
-
tags: ['napcat', 'qq'],
|
|
12
|
-
keywords: ['翻译', 'translate', '英译中'],
|
|
13
|
-
async execute({ endpoint_id, text }) {
|
|
14
|
-
const endpoint = getEndpoint(endpoint_id);
|
|
15
|
-
return endpoint.translateEn2Zh(text);
|
|
16
|
-
},
|
|
17
|
-
});
|
|
18
|
-
//# sourceMappingURL=translate.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"translate.js","sourceRoot":"","sources":["../../../agent/tools/translate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAE7D,eAAe,UAAU,CAAwC;IAC/D,WAAW,EAAE,QAAQ;IACrB,WAAW,EAAE,CAAC,CAAC,MAAM,CAAC;QACpB,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,aAAa,CAAC;QAC/C,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,UAAU,CAAC;KACtC,CAAC;IACF,SAAS,EAAE,CAAC,QAAQ,CAAC;IACrB,IAAI,EAAE,CAAC,QAAQ,EAAE,IAAI,CAAC;IACtB,QAAQ,EAAE,CAAC,IAAI,EAAE,WAAW,EAAE,KAAK,CAAC;IACpC,KAAK,CAAC,OAAO,CAAC,EAAE,WAAW,EAAE,IAAI,EAAyC;QACxE,MAAM,QAAQ,GAAG,WAAW,CAAC,WAAW,CAAC,CAAC;QACxC,OAAO,QAAQ,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;IACzC,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { defineTool } from '@zhin.js/agent/tools';
|
|
2
|
-
import { z } from 'zod';
|
|
3
|
-
import { getEndpoint } from '../../src/napcat-agent-deps.js';
|
|
4
|
-
export default defineTool({
|
|
5
|
-
description: '上传文件到群。file 为本地路径或 URL。',
|
|
6
|
-
inputSchema: z.object({
|
|
7
|
-
endpoint_id: z.string().describe('Endpoint 名称'),
|
|
8
|
-
group_id: z.number().describe('群号'),
|
|
9
|
-
file: z.string().describe('文件路径或 URL'),
|
|
10
|
-
name: z.string().describe('文件名'),
|
|
11
|
-
folder: z.string().optional().describe('目标文件夹 ID(可选)'),
|
|
12
|
-
}),
|
|
13
|
-
platforms: ['napcat'],
|
|
14
|
-
tags: ['napcat', 'qq'],
|
|
15
|
-
keywords: ['上传文件', 'upload file', '群文件'],
|
|
16
|
-
scopes: ['group'],
|
|
17
|
-
async execute({ endpoint_id, group_id, file, name, folder }) {
|
|
18
|
-
const endpoint = getEndpoint(endpoint_id);
|
|
19
|
-
await endpoint.uploadGroupFile(group_id, file, name, folder);
|
|
20
|
-
return { success: true };
|
|
21
|
-
},
|
|
22
|
-
});
|
|
23
|
-
//# sourceMappingURL=upload_group_file.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"upload_group_file.js","sourceRoot":"","sources":["../../../agent/tools/upload_group_file.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAE7D,eAAe,UAAU,CAAyF;IAChH,WAAW,EAAE,yBAAyB;IACtC,WAAW,EAAE,CAAC,CAAC,MAAM,CAAC;QACpB,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,aAAa,CAAC;QAC/C,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC;QACnC,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,WAAW,CAAC;QACtC,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC;QAChC,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,cAAc,CAAC;KACvD,CAAC;IACF,SAAS,EAAE,CAAC,QAAQ,CAAC;IACrB,IAAI,EAAE,CAAC,QAAQ,EAAE,IAAI,CAAC;IACtB,QAAQ,EAAE,CAAC,MAAM,EAAE,aAAa,EAAE,KAAK,CAAC;IACxC,MAAM,EAAE,CAAC,OAAO,CAAC;IACjB,KAAK,CAAC,OAAO,CAAC,EAAE,WAAW,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAA0F;QACjJ,MAAM,QAAQ,GAAG,WAAW,CAAC,WAAW,CAAC,CAAC;QACxC,MAAM,QAAQ,CAAC,eAAe,CAAC,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;QAC7D,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;IAC7B,CAAC;CACF,CAAC,CAAC"}
|
package/lib/src/adapter.js
DELETED
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* NapCat 适配器:支持正向 WS / 反向 WS / HTTP
|
|
3
|
-
*/
|
|
4
|
-
import { Adapter, OUTBOUND_RICH_SEGMENT_POLICY_IM_FULL, ONEBOT_KEYBOARD_AI_OUTBOUND_EXTENSION } from 'zhin.js';
|
|
5
|
-
import { NapCatWsClient } from './endpoint-ws-client.js';
|
|
6
|
-
import { NapCatWsServer } from './endpoint-ws-server.js';
|
|
7
|
-
import { NapCatHttpEndpoint } from './endpoint-http.js';
|
|
8
|
-
export class NapCatAdapter extends Adapter {
|
|
9
|
-
static capabilities = ['inbound', 'outbound'];
|
|
10
|
-
static outboundRichSegmentPolicy = OUTBOUND_RICH_SEGMENT_POLICY_IM_FULL;
|
|
11
|
-
static interactivePolicy = 'text';
|
|
12
|
-
static aiOutboundCapabilities = {
|
|
13
|
-
mentions: true,
|
|
14
|
-
richSegments: ['qrcode', 'html', 'markdown', 'tts'],
|
|
15
|
-
interactive: 'text',
|
|
16
|
-
};
|
|
17
|
-
static aiOutboundExtensions = [ONEBOT_KEYBOARD_AI_OUTBOUND_EXTENSION];
|
|
18
|
-
#router;
|
|
19
|
-
constructor(plugin) {
|
|
20
|
-
super(plugin, 'napcat', []);
|
|
21
|
-
}
|
|
22
|
-
createEndpoint(config) {
|
|
23
|
-
const connection = config.connection ?? 'ws';
|
|
24
|
-
switch (connection) {
|
|
25
|
-
case 'ws':
|
|
26
|
-
return new NapCatWsClient(this, config);
|
|
27
|
-
case 'wss':
|
|
28
|
-
if (!this.#router)
|
|
29
|
-
throw new Error('NapCat connection: wss requires router. Enable @zhin.js/host-router first.');
|
|
30
|
-
return new NapCatWsServer(this, this.#router, config);
|
|
31
|
-
case 'http':
|
|
32
|
-
if (!this.#router)
|
|
33
|
-
throw new Error('NapCat connection: http requires router. Enable @zhin.js/host-router first.');
|
|
34
|
-
return new NapCatHttpEndpoint(this, this.#router, config);
|
|
35
|
-
default:
|
|
36
|
-
throw new Error(`Unknown NapCat connection: ${connection}`);
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
// ── 群管理接口(ISceneManagement 适配)──────────────────────────
|
|
40
|
-
async removeMember(endpointId, sceneId, userId) {
|
|
41
|
-
const endpoint = this.endpoints.get(endpointId);
|
|
42
|
-
if (!endpoint)
|
|
43
|
-
throw new Error(`Endpoint ${endpointId} not found`);
|
|
44
|
-
return endpoint.kickMember(Number(sceneId), Number(userId));
|
|
45
|
-
}
|
|
46
|
-
async muteMember(endpointId, sceneId, userId, duration = 600) {
|
|
47
|
-
const endpoint = this.endpoints.get(endpointId);
|
|
48
|
-
if (!endpoint)
|
|
49
|
-
throw new Error(`Endpoint ${endpointId} not found`);
|
|
50
|
-
return endpoint.muteMember(Number(sceneId), Number(userId), duration);
|
|
51
|
-
}
|
|
52
|
-
async setSceneMuted(endpointId, sceneId, enable = true) {
|
|
53
|
-
const endpoint = this.endpoints.get(endpointId);
|
|
54
|
-
if (!endpoint)
|
|
55
|
-
throw new Error(`Endpoint ${endpointId} not found`);
|
|
56
|
-
return endpoint.muteAll(Number(sceneId), enable);
|
|
57
|
-
}
|
|
58
|
-
async setModerator(endpointId, sceneId, userId, enable = true) {
|
|
59
|
-
const endpoint = this.endpoints.get(endpointId);
|
|
60
|
-
if (!endpoint)
|
|
61
|
-
throw new Error(`Endpoint ${endpointId} not found`);
|
|
62
|
-
return endpoint.setAdmin(Number(sceneId), Number(userId), enable);
|
|
63
|
-
}
|
|
64
|
-
async setMemberNickname(endpointId, sceneId, userId, nickname) {
|
|
65
|
-
const endpoint = this.endpoints.get(endpointId);
|
|
66
|
-
if (!endpoint)
|
|
67
|
-
throw new Error(`Endpoint ${endpointId} not found`);
|
|
68
|
-
return endpoint.setCard(Number(sceneId), Number(userId), nickname);
|
|
69
|
-
}
|
|
70
|
-
async renameScene(endpointId, sceneId, name) {
|
|
71
|
-
const endpoint = this.endpoints.get(endpointId);
|
|
72
|
-
if (!endpoint)
|
|
73
|
-
throw new Error(`Endpoint ${endpointId} not found`);
|
|
74
|
-
return endpoint.setGroupName(Number(sceneId), name);
|
|
75
|
-
}
|
|
76
|
-
async listMembers(endpointId, sceneId) {
|
|
77
|
-
const endpoint = this.endpoints.get(endpointId);
|
|
78
|
-
if (!endpoint)
|
|
79
|
-
throw new Error(`Endpoint ${endpointId} not found`);
|
|
80
|
-
const members = await endpoint.getMemberList(Number(sceneId));
|
|
81
|
-
return {
|
|
82
|
-
members: members.map((m) => ({
|
|
83
|
-
user_id: m.user_id, nickname: m.nickname, card: m.card, role: m.role, title: m.title,
|
|
84
|
-
})),
|
|
85
|
-
count: members.length,
|
|
86
|
-
};
|
|
87
|
-
}
|
|
88
|
-
async getSceneInfo(endpointId, sceneId) {
|
|
89
|
-
const endpoint = this.endpoints.get(endpointId);
|
|
90
|
-
if (!endpoint)
|
|
91
|
-
throw new Error(`Endpoint ${endpointId} not found`);
|
|
92
|
-
return endpoint.getGroupInfo(Number(sceneId));
|
|
93
|
-
}
|
|
94
|
-
async start() {
|
|
95
|
-
this.#router = this.plugin.inject('router');
|
|
96
|
-
this.plugin.useContext('router', (router) => {
|
|
97
|
-
this.#router = router;
|
|
98
|
-
});
|
|
99
|
-
await super.start();
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
//# sourceMappingURL=adapter.js.map
|
package/lib/src/adapter.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"adapter.js","sourceRoot":"","sources":["../../src/adapter.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAiB,OAAO,EAAU,oCAAoC,EAAE,qCAAqC,EAAE,MAAM,SAAS,CAAC;AAEtI,OAAO,EAAE,cAA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at\b|napcat_|mcp_napcat/i.test(text))
|
|
5
|
-
return true;
|
|
6
|
-
if (/戳一戳|poke|表情回应|emoji.*reaction/i.test(text))
|
|
7
|
-
return true;
|
|
8
|
-
if (/精华消息|essence|群公告|group.*notice/i.test(text))
|
|
9
|
-
return true;
|
|
10
|
-
if (/AI语音|ai.*record|tts|文字转语音/i.test(text))
|
|
11
|
-
return true;
|
|
12
|
-
if (/群文件|upload.*file|群签到|group.*sign/i.test(text))
|
|
13
|
-
return true;
|
|
14
|
-
if (/合并转发|forward.*msg|转发消息/i.test(text))
|
|
15
|
-
return true;
|
|
16
|
-
if (/点赞/.test(text) && /qq|好友|\d{5,}/i.test(text))
|
|
17
|
-
return true;
|
|
18
|
-
return false;
|
|
19
|
-
}
|
|
20
|
-
function selectNapCatDeferredTools(query, goal, deferredCatalog, maxTools) {
|
|
21
|
-
const pool = deferredCatalog.filter(t => !t.name.startsWith('mcp_filesystem') && !t.name.startsWith('mcp_memory_'));
|
|
22
|
-
const napcatTools = pool.filter(t => t.name.startsWith('napcat_'));
|
|
23
|
-
const pinned = [];
|
|
24
|
-
const preferOrder = [
|
|
25
|
-
'napcat_send_poke',
|
|
26
|
-
'napcat_set_emoji_reaction',
|
|
27
|
-
'napcat_send_like',
|
|
28
|
-
'napcat_set_essence_msg',
|
|
29
|
-
'napcat_send_group_notice',
|
|
30
|
-
'napcat_ai_tts',
|
|
31
|
-
];
|
|
32
|
-
for (const name of preferOrder) {
|
|
33
|
-
const t = napcatTools.find(x => x.name === name);
|
|
34
|
-
if (t)
|
|
35
|
-
pinned.push(t);
|
|
36
|
-
}
|
|
37
|
-
for (const t of napcatTools) {
|
|
38
|
-
if (pinned.length >= maxTools)
|
|
39
|
-
break;
|
|
40
|
-
if (!pinned.some(p => p.name === t.name))
|
|
41
|
-
pinned.push(t);
|
|
42
|
-
}
|
|
43
|
-
const extra = filterTools(query, pool, { maxTools, minScore: 0.08 })
|
|
44
|
-
.map((t) => ({ name: t.name, description: t.description }))
|
|
45
|
-
.filter(t => !pinned.some(p => p.name === t.name));
|
|
46
|
-
const merged = [...pinned];
|
|
47
|
-
for (const t of extra) {
|
|
48
|
-
if (merged.length >= maxTools)
|
|
49
|
-
break;
|
|
50
|
-
merged.push(t);
|
|
51
|
-
}
|
|
52
|
-
return merged.slice(0, maxTools);
|
|
53
|
-
}
|
|
54
|
-
const ORCHESTRATOR_NAPCAT = [
|
|
55
|
-
'On napcat/QQ: use run_deferred_task with tool_query "napcat_send_poke" or "napcat_set_emoji_reaction".',
|
|
56
|
-
'NapCat supports: poke, emoji reaction, forward msg, essence, group notice, AI TTS, OCR, group files.',
|
|
57
|
-
'Skip tool_search when the user clearly asks for QQ-specific features like poke, reaction, or group management.',
|
|
58
|
-
].join('\n');
|
|
59
|
-
const WORKER_NAPCAT = [
|
|
60
|
-
'- Use `napcat_send_poke` for poke/戳一戳.',
|
|
61
|
-
'- Use `napcat_set_emoji_reaction` for emoji reaction/表情回应.',
|
|
62
|
-
'- Use `napcat_send_like` for friend like/点赞.',
|
|
63
|
-
'- Use `napcat_ai_tts` for AI voice/AI语音.',
|
|
64
|
-
'- Use `napcat_set_essence_msg` / `napcat_delete_essence_msg` for essence messages.',
|
|
65
|
-
'- Use `napcat_send_group_notice` for group announcements.',
|
|
66
|
-
'- Do NOT use mcp_filesystem_* or explore node_modules for QQ tasks.',
|
|
67
|
-
].join('\n');
|
|
68
|
-
export function createNapCatAgentPromptContributor() {
|
|
69
|
-
return {
|
|
70
|
-
platform: 'napcat',
|
|
71
|
-
async buildSections(ctx) {
|
|
72
|
-
if (ctx.slot === 'orchestrator') {
|
|
73
|
-
return [{
|
|
74
|
-
id: 'platform.napcat.orchestrator',
|
|
75
|
-
title: '## napcat / QQ',
|
|
76
|
-
body: ORCHESTRATOR_NAPCAT,
|
|
77
|
-
priority: 50,
|
|
78
|
-
}];
|
|
79
|
-
}
|
|
80
|
-
if (ctx.slot === 'deferred_worker') {
|
|
81
|
-
const query = ctx.deferred?.toolQuery ?? ctx.deferred?.goal ?? '';
|
|
82
|
-
const goal = ctx.deferred?.goal ?? '';
|
|
83
|
-
if (!isNapCatDelegatedTask(query, goal))
|
|
84
|
-
return null;
|
|
85
|
-
return [{
|
|
86
|
-
id: 'platform.napcat.deferred_worker',
|
|
87
|
-
title: '## napcat / QQ(本任务)',
|
|
88
|
-
body: WORKER_NAPCAT,
|
|
89
|
-
priority: 50,
|
|
90
|
-
}];
|
|
91
|
-
}
|
|
92
|
-
return null;
|
|
93
|
-
},
|
|
94
|
-
matchesDeferredTask(ctx) {
|
|
95
|
-
const query = ctx.deferred?.toolQuery ?? ctx.deferred?.goal ?? ctx.userMessagePreview ?? '';
|
|
96
|
-
const goal = ctx.deferred?.goal ?? ctx.userMessagePreview ?? '';
|
|
97
|
-
return isNapCatDelegatedTask(query, goal);
|
|
98
|
-
},
|
|
99
|
-
selectDeferredTools(query, goal, catalog, maxTools) {
|
|
100
|
-
if (!isNapCatDelegatedTask(query, goal))
|
|
101
|
-
return null;
|
|
102
|
-
return selectNapCatDeferredTools(query, goal, catalog, maxTools);
|
|
103
|
-
},
|
|
104
|
-
};
|
|
105
|
-
}
|
|
106
|
-
//# sourceMappingURL=agent-prompt.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"agent-prompt.js","sourceRoot":"","sources":["../../src/agent-prompt.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,WAAW,EAAkB,MAAM,YAAY,CAAC;AAEzD,SAAS,qBAAqB,CAAC,KAAa,EAAE,IAAY;IACxD,MAAM,IAAI,GAAG,GAAG,KAAK,IAAI,IAAI,EAAE,CAAC;IAChC,IAAI,gCAAgC,CAAC,IAAI,CAAC,IAAI,CAAC;QAAE,OAAO,IAAI,CAAC;IAC7D,IAAI,gCAAgC,CAAC,IAAI,CAAC,IAAI,CAAC;QAAE,OAAO,IAAI,CAAC;IAC7D,IAAI,iCAAiC,CAAC,IAAI,CAAC,IAAI,CAAC;QAAE,OAAO,IAAI,CAAC;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,qBAAqB,CAAC,KAAK,EAAE,IAAI,CAAC;gBAAE,OAAO,IAAI,CAAC;YACrD,OAAO,yBAAyB,CAAC,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC;QACnE,CAAC;KACF,CAAC;AACJ,CAAC"}
|
package/lib/src/endpoint-base.js
DELETED
|
@@ -1,315 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* NapCat Endpoint 抽象基类
|
|
3
|
-
* 子类只需实现 callApi / $connect / $disconnect,其余 API 方法和事件处理全部复用。
|
|
4
|
-
*/
|
|
5
|
-
import { EventEmitter } from 'events';
|
|
6
|
-
import { Message, segment, expandInteractiveSegmentsInContent, mapNoticeParts, mapRequestParts, buildNotice, buildRequest, senderFromId, } from 'zhin.js';
|
|
7
|
-
import { parseOneBotGetMsgResponse } from './onebot-get-msg.js';
|
|
8
|
-
import { InboundMessageDeduper, isSelfMessage, normalizeMessage, resolveSideEventDedupeKey } from './napcat-inbound.js';
|
|
9
|
-
import { fromCanonicalSegments, toCanonicalSegments } from './segment-mapper.js';
|
|
10
|
-
export class NapCatEndpointBase extends EventEmitter {
|
|
11
|
-
adapter;
|
|
12
|
-
$config;
|
|
13
|
-
$connected = false;
|
|
14
|
-
inboundDeduper = new InboundMessageDeduper();
|
|
15
|
-
get logger() { return this.adapter.plugin.logger; }
|
|
16
|
-
get $id() { return this.$config.name; }
|
|
17
|
-
constructor(adapter, $config) {
|
|
18
|
-
super();
|
|
19
|
-
this.adapter = adapter;
|
|
20
|
-
this.$config = $config;
|
|
21
|
-
}
|
|
22
|
-
// ══════════════════════════════════════════════════════════════════
|
|
23
|
-
// 消息格式化
|
|
24
|
-
// ══════════════════════════════════════════════════════════════════
|
|
25
|
-
toWireSendContent(content) {
|
|
26
|
-
const items = (Array.isArray(content) ? content : [content]).map((item) => typeof item === 'string' ? { type: 'text', data: { text: item } } : item);
|
|
27
|
-
return fromCanonicalSegments(toCanonicalSegments(items));
|
|
28
|
-
}
|
|
29
|
-
$formatMessage(ev) {
|
|
30
|
-
const wire = normalizeMessage(ev.message);
|
|
31
|
-
const quoteId = Message.quoteIdFromContent(wire);
|
|
32
|
-
Message.alignReplySegments(wire, quoteId);
|
|
33
|
-
const content = toCanonicalSegments(wire);
|
|
34
|
-
const message = Message.from(ev, {
|
|
35
|
-
$id: ev.message_id.toString(),
|
|
36
|
-
$adapter: 'napcat',
|
|
37
|
-
$endpoint: this.$config.name,
|
|
38
|
-
$sender: {
|
|
39
|
-
id: ev.user_id.toString(),
|
|
40
|
-
name: ev.sender?.nickname || ev.user_id.toString(),
|
|
41
|
-
role: ev.sender?.role,
|
|
42
|
-
},
|
|
43
|
-
$channel: {
|
|
44
|
-
id: (ev.group_id || ev.user_id).toString(),
|
|
45
|
-
type: ev.group_id ? 'group' : 'private',
|
|
46
|
-
},
|
|
47
|
-
$content: content,
|
|
48
|
-
$quote_id: quoteId,
|
|
49
|
-
$raw: ev.raw_message,
|
|
50
|
-
$timestamp: ev.time,
|
|
51
|
-
$recall: async () => { await this.deleteMsg(ev.message_id); },
|
|
52
|
-
$reply: async (content, quote) => {
|
|
53
|
-
if (!Array.isArray(content))
|
|
54
|
-
content = [content];
|
|
55
|
-
if (quote)
|
|
56
|
-
content.unshift({ type: 'reply', data: { message_id: ev.message_id.toString() } });
|
|
57
|
-
return await this.adapter.sendMessage({
|
|
58
|
-
id: (ev.group_id || ev.user_id).toString(),
|
|
59
|
-
type: ev.group_id ? 'group' : 'private',
|
|
60
|
-
context: 'napcat',
|
|
61
|
-
endpoint: this.$config.name,
|
|
62
|
-
content,
|
|
63
|
-
});
|
|
64
|
-
},
|
|
65
|
-
});
|
|
66
|
-
return message;
|
|
67
|
-
}
|
|
68
|
-
async $sendMessage(options) {
|
|
69
|
-
const content = this.toWireSendContent(expandInteractiveSegmentsInContent(options.content));
|
|
70
|
-
const msg = { message: content };
|
|
71
|
-
if (options.type === 'group') {
|
|
72
|
-
const result = await this.callApi('send_group_msg', { group_id: parseInt(options.id), ...msg });
|
|
73
|
-
this.logger.debug(`${this.$id} send group(${options.id}):${segment.raw(options.content)}`);
|
|
74
|
-
return result.message_id.toString();
|
|
75
|
-
}
|
|
76
|
-
if (options.type === 'private') {
|
|
77
|
-
const result = await this.callApi('send_private_msg', { user_id: parseInt(options.id), ...msg });
|
|
78
|
-
this.logger.debug(`${this.$id} send private(${options.id}):${segment.raw(options.content)}`);
|
|
79
|
-
return result.message_id.toString();
|
|
80
|
-
}
|
|
81
|
-
throw new Error('Either group_id or user_id must be provided');
|
|
82
|
-
}
|
|
83
|
-
async $recallMessage(id) {
|
|
84
|
-
await this.deleteMsg(parseInt(id));
|
|
85
|
-
}
|
|
86
|
-
async $addReaction(messageId, emojiId) {
|
|
87
|
-
await this.setMsgEmojiLike(parseInt(messageId), emojiId);
|
|
88
|
-
return `reaction:${messageId}:${emojiId}`;
|
|
89
|
-
}
|
|
90
|
-
async $removeReaction(messageId, _reactionId) {
|
|
91
|
-
// NapCat 的 set_msg_emoji_like 是 toggle 行为,再调一次即取消
|
|
92
|
-
const parts = _reactionId.split(':');
|
|
93
|
-
const emojiId = parts[2] || parts[0];
|
|
94
|
-
await this.setMsgEmojiLike(parseInt(messageId), emojiId);
|
|
95
|
-
}
|
|
96
|
-
// ══════════════════════════════════════════════════════════════════
|
|
97
|
-
// 事件分发
|
|
98
|
-
// ══════════════════════════════════════════════════════════════════
|
|
99
|
-
dispatchEvent(event) {
|
|
100
|
-
switch (event.post_type) {
|
|
101
|
-
case 'message':
|
|
102
|
-
case 'message_sent':
|
|
103
|
-
return this.handleMessage(event);
|
|
104
|
-
case 'notice':
|
|
105
|
-
return this.handleNotice(event);
|
|
106
|
-
case 'request':
|
|
107
|
-
return this.handleRequest(event);
|
|
108
|
-
case 'meta_event':
|
|
109
|
-
return this.handleMeta(event);
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
handleMessage(ev) {
|
|
113
|
-
if (isSelfMessage(ev))
|
|
114
|
-
return;
|
|
115
|
-
const msgId = ev.message_id.toString();
|
|
116
|
-
if (!this.inboundDeduper.shouldProcess(msgId))
|
|
117
|
-
return;
|
|
118
|
-
ev.message = normalizeMessage(ev.message);
|
|
119
|
-
const message = this.$formatMessage(ev);
|
|
120
|
-
this.adapter.emit('message.receive', message);
|
|
121
|
-
this.logger.debug(`${this.$id} recv ${message.$channel.type}(${message.$channel.id}):${segment.raw(message.$content)}`);
|
|
122
|
-
}
|
|
123
|
-
handleNotice(event) {
|
|
124
|
-
const dedupeKey = resolveSideEventDedupeKey(event, 'notice');
|
|
125
|
-
if (!this.inboundDeduper.shouldProcess(dedupeKey))
|
|
126
|
-
return;
|
|
127
|
-
const isGroup = !!event.group_id;
|
|
128
|
-
const { scene_type, sub_type } = mapNoticeParts('napcat', event.notice_type ?? '', {
|
|
129
|
-
sub_type: event.sub_type,
|
|
130
|
-
is_group: isGroup,
|
|
131
|
-
});
|
|
132
|
-
const sceneId = String((event.group_id || event.user_id) ?? '');
|
|
133
|
-
const notice = buildNotice(event, {
|
|
134
|
-
$id: `${event.time}_${event.notice_type}_${event.group_id || event.user_id}`,
|
|
135
|
-
$adapter: 'napcat',
|
|
136
|
-
$endpoint: this.$config.name,
|
|
137
|
-
$type: 'notice',
|
|
138
|
-
$scene_id: sceneId,
|
|
139
|
-
$scene_type: scene_type,
|
|
140
|
-
$sub_type: sub_type,
|
|
141
|
-
$actor: senderFromId(event.operator_id),
|
|
142
|
-
$target: senderFromId(event.user_id),
|
|
143
|
-
$timestamp: (event.time || Math.floor(Date.now() / 1000)) * 1000,
|
|
144
|
-
});
|
|
145
|
-
this.adapter.emit('notice.receive', notice);
|
|
146
|
-
}
|
|
147
|
-
handleRequest(event) {
|
|
148
|
-
const dedupeKey = resolveSideEventDedupeKey(event, 'request');
|
|
149
|
-
if (!this.inboundDeduper.shouldProcess(dedupeKey))
|
|
150
|
-
return;
|
|
151
|
-
const { scene_type, sub_type } = mapRequestParts('napcat', event.request_type ?? '', event.sub_type);
|
|
152
|
-
const sceneId = String((event.group_id || event.user_id) ?? '');
|
|
153
|
-
const request = buildRequest(event, {
|
|
154
|
-
$id: event.flag || `${event.time}_${event.request_type}_${event.user_id}`,
|
|
155
|
-
$adapter: 'napcat',
|
|
156
|
-
$endpoint: this.$config.name,
|
|
157
|
-
$type: 'request',
|
|
158
|
-
$scene_id: sceneId,
|
|
159
|
-
$scene_type: scene_type,
|
|
160
|
-
$sub_type: sub_type,
|
|
161
|
-
$actor: senderFromId(event.user_id) ?? { id: '', name: '' },
|
|
162
|
-
$comment: event.comment,
|
|
163
|
-
$timestamp: (event.time || Math.floor(Date.now() / 1000)) * 1000,
|
|
164
|
-
$approve: async (remark) => {
|
|
165
|
-
await this.callApi(event.request_type === 'friend' ? 'set_friend_add_request' : 'set_group_add_request', { flag: event.flag, approve: true, remark });
|
|
166
|
-
},
|
|
167
|
-
$reject: async (reason) => {
|
|
168
|
-
await this.callApi(event.request_type === 'friend' ? 'set_friend_add_request' : 'set_group_add_request', { flag: event.flag, approve: false, reason });
|
|
169
|
-
},
|
|
170
|
-
});
|
|
171
|
-
this.adapter.emit('request.receive', request);
|
|
172
|
-
}
|
|
173
|
-
handleMeta(event) {
|
|
174
|
-
// subclass may override for lifecycle handling
|
|
175
|
-
}
|
|
176
|
-
// ══════════════════════════════════════════════════════════════════
|
|
177
|
-
// OneBot11 标准 API
|
|
178
|
-
// ══════════════════════════════════════════════════════════════════
|
|
179
|
-
async sendMsg(messageType, id, message) {
|
|
180
|
-
return this.callApi('send_msg', { message_type: messageType, [messageType === 'group' ? 'group_id' : 'user_id']: id, message });
|
|
181
|
-
}
|
|
182
|
-
async deleteMsg(messageId) { return this.callApi('delete_msg', { message_id: messageId }); }
|
|
183
|
-
async getMsg(messageId) { return this.callApi('get_msg', { message_id: messageId }); }
|
|
184
|
-
async $getMsg(messageId) {
|
|
185
|
-
const idParam = /^\d+$/.test(messageId) ? Number(messageId) : messageId;
|
|
186
|
-
const data = await this.callApi('get_msg', { message_id: idParam });
|
|
187
|
-
return parseOneBotGetMsgResponse(messageId, data);
|
|
188
|
-
}
|
|
189
|
-
async getForwardMsg(id) { return this.callApi('get_forward_msg', { id }); }
|
|
190
|
-
async sendLike(userId, times = 1) { return this.callApi('send_like', { user_id: userId, times }); }
|
|
191
|
-
// 群管理
|
|
192
|
-
async setGroupKick(groupId, userId, rejectAddRequest = false) { return this.callApi('set_group_kick', { group_id: groupId, user_id: userId, reject_add_request: rejectAddRequest }); }
|
|
193
|
-
async setGroupBan(groupId, userId, duration = 600) { return this.callApi('set_group_ban', { group_id: groupId, user_id: userId, duration }); }
|
|
194
|
-
async setGroupWholeBan(groupId, enable = true) { return this.callApi('set_group_whole_ban', { group_id: groupId, enable }); }
|
|
195
|
-
async setGroupAdmin(groupId, userId, enable = true) { return this.callApi('set_group_admin', { group_id: groupId, user_id: userId, enable }); }
|
|
196
|
-
async setGroupCard(groupId, userId, card) { return this.callApi('set_group_card', { group_id: groupId, user_id: userId, card }); }
|
|
197
|
-
async setGroupName(groupId, groupName) { return this.callApi('set_group_name', { group_id: groupId, group_name: groupName }); }
|
|
198
|
-
async setGroupLeave(groupId, isDismiss = false) { return this.callApi('set_group_leave', { group_id: groupId, is_dismiss: isDismiss }); }
|
|
199
|
-
async setGroupSpecialTitle(groupId, userId, specialTitle, duration = -1) { return this.callApi('set_group_special_title', { group_id: groupId, user_id: userId, special_title: specialTitle, duration }); }
|
|
200
|
-
// 好友/群请求
|
|
201
|
-
async setFriendAddRequest(flag, approve = true, remark) { return this.callApi('set_friend_add_request', { flag, approve, remark }); }
|
|
202
|
-
async setGroupAddRequest(flag, subType, approve = true, reason) { return this.callApi('set_group_add_request', { flag, sub_type: subType, approve, reason }); }
|
|
203
|
-
// 信息查询
|
|
204
|
-
async getLoginInfo() { return this.callApi('get_login_info'); }
|
|
205
|
-
async getStrangerInfo(userId, noCache = false) { return this.callApi('get_stranger_info', { user_id: userId, no_cache: noCache }); }
|
|
206
|
-
async getFriendList() { return this.callApi('get_friend_list'); }
|
|
207
|
-
async getGroupInfo(groupId, noCache = false) { return this.callApi('get_group_info', { group_id: groupId, no_cache: noCache }); }
|
|
208
|
-
async getGroupList() { return this.callApi('get_group_list'); }
|
|
209
|
-
async getGroupMemberInfo(groupId, userId, noCache = false) { return this.callApi('get_group_member_info', { group_id: groupId, user_id: userId, no_cache: noCache }); }
|
|
210
|
-
async getGroupMemberList(groupId) { return this.callApi('get_group_member_list', { group_id: groupId }); }
|
|
211
|
-
async getGroupHonorInfo(groupId, type) { return this.callApi('get_group_honor_info', { group_id: groupId, type }); }
|
|
212
|
-
// 凭证
|
|
213
|
-
async getCookies(domain) { return this.callApi('get_cookies', { domain }); }
|
|
214
|
-
async getCsrfToken() { return this.callApi('get_csrf_token'); }
|
|
215
|
-
async getCredentials(domain) { return this.callApi('get_credentials', { domain }); }
|
|
216
|
-
// 媒体
|
|
217
|
-
async getRecord(file, outFormat) { return this.callApi('get_record', { file, out_format: outFormat }); }
|
|
218
|
-
async getImage(file) { return this.callApi('get_image', { file }); }
|
|
219
|
-
async canSendImage() { return this.callApi('can_send_image'); }
|
|
220
|
-
async canSendRecord() { return this.callApi('can_send_record'); }
|
|
221
|
-
// 系统
|
|
222
|
-
async getStatus() { return this.callApi('get_status'); }
|
|
223
|
-
async getVersionInfo() { return this.callApi('get_version_info'); }
|
|
224
|
-
async cleanCache() { return this.callApi('clean_cache'); }
|
|
225
|
-
// ══════════════════════════════════════════════════════════════════
|
|
226
|
-
// go-cqhttp 扩展 API
|
|
227
|
-
// ══════════════════════════════════════════════════════════════════
|
|
228
|
-
async setQQProfile(nickname, company, email, college, personalNote) {
|
|
229
|
-
return this.callApi('set_qq_profile', { nickname, company, email, college, personal_note: personalNote });
|
|
230
|
-
}
|
|
231
|
-
async getOnlineClients(noCache = false) { return this.callApi('get_online_clients', { no_cache: noCache }); }
|
|
232
|
-
async deleteFriend(userId) { return this.callApi('delete_friend', { user_id: userId }); }
|
|
233
|
-
async markMsgAsRead(messageId) { return this.callApi('mark_msg_as_read', { message_id: messageId }); }
|
|
234
|
-
async sendGroupForwardMsg(groupId, messages) { return this.callApi('send_group_forward_msg', { group_id: groupId, messages }); }
|
|
235
|
-
async sendPrivateForwardMsg(userId, messages) { return this.callApi('send_private_forward_msg', { user_id: userId, messages }); }
|
|
236
|
-
async getGroupMsgHistory(groupId, messageSeq, count) { return this.callApi('get_group_msg_history', { group_id: groupId, message_seq: messageSeq, count }); }
|
|
237
|
-
async ocrImage(image) { return this.callApi('ocr_image', { image }); }
|
|
238
|
-
async getGroupSystemMsg() { return this.callApi('get_group_system_msg'); }
|
|
239
|
-
async getEssenceMsgList(groupId) { return this.callApi('get_essence_msg_list', { group_id: groupId }); }
|
|
240
|
-
async getGroupAtAllRemain(groupId) { return this.callApi('get_group_at_all_remain', { group_id: groupId }); }
|
|
241
|
-
async setGroupPortrait(groupId, file) { return this.callApi('set_group_portrait', { group_id: groupId, file }); }
|
|
242
|
-
async setEssenceMsg(messageId) { return this.callApi('set_essence_msg', { message_id: messageId }); }
|
|
243
|
-
async deleteEssenceMsg(messageId) { return this.callApi('delete_essence_msg', { message_id: messageId }); }
|
|
244
|
-
async sendGroupSign(groupId) { return this.callApi('send_group_sign', { group_id: groupId }); }
|
|
245
|
-
async sendGroupNotice(groupId, content, image) { return this.callApi('_send_group_notice', { group_id: groupId, content, image }); }
|
|
246
|
-
async getGroupNotice(groupId) { return this.callApi('_get_group_notice', { group_id: groupId }); }
|
|
247
|
-
async deleteGroupNotice(groupId, noticeId) { return this.callApi('_del_group_notice', { group_id: groupId, notice_id: noticeId }); }
|
|
248
|
-
async uploadGroupFile(groupId, file, name, folder) { return this.callApi('upload_group_file', { group_id: groupId, file, name, folder }); }
|
|
249
|
-
async deleteGroupFile(groupId, fileId, busid) { return this.callApi('delete_group_file', { group_id: groupId, file_id: fileId, busid }); }
|
|
250
|
-
async createGroupFileFolder(groupId, name, parentId = '/') { return this.callApi('create_group_file_folder', { group_id: groupId, name, parent_id: parentId }); }
|
|
251
|
-
async deleteGroupFolder(groupId, folderId) { return this.callApi('delete_group_folder', { group_id: groupId, folder_id: folderId }); }
|
|
252
|
-
async getGroupFileSystemInfo(groupId) { return this.callApi('get_group_file_system_info', { group_id: groupId }); }
|
|
253
|
-
async getGroupRootFiles(groupId) { return this.callApi('get_group_root_files', { group_id: groupId }); }
|
|
254
|
-
async getGroupFilesByFolder(groupId, folderId) { return this.callApi('get_group_files_by_folder', { group_id: groupId, folder_id: folderId }); }
|
|
255
|
-
async getGroupFileUrl(groupId, fileId, busid) { return this.callApi('get_group_file_url', { group_id: groupId, file_id: fileId, busid }); }
|
|
256
|
-
async uploadPrivateFile(userId, file, name) { return this.callApi('upload_private_file', { user_id: userId, file, name }); }
|
|
257
|
-
async downloadFile(url, threadCount = 1, headers) { return this.callApi('download_file', { url, thread_count: threadCount, headers }); }
|
|
258
|
-
async checkUrlSafely(url) { return this.callApi('check_url_safely', { url }); }
|
|
259
|
-
// ══════════════════════════════════════════════════════════════════
|
|
260
|
-
// NapCat 独有 API
|
|
261
|
-
// ══════════════════════════════════════════════════════════════════
|
|
262
|
-
async setGroupSign(groupId) { return this.callApi('set_group_sign', { group_id: groupId }); }
|
|
263
|
-
async arkSharePeer(userId) { return this.callApi('ArkSharePeer', { user_id: userId }); }
|
|
264
|
-
async arkShareGroup(groupId) { return this.callApi('ArkShareGroup', { group_id: groupId }); }
|
|
265
|
-
async getRobotUinRange() { return this.callApi('get_robot_uin_range'); }
|
|
266
|
-
async setOnlineStatus(status, extStatus) { return this.callApi('set_online_status', { status, ext_status: extStatus }); }
|
|
267
|
-
async getFriendsWithCategory() { return this.callApi('get_friends_with_category'); }
|
|
268
|
-
async setQQAvatar(file) { return this.callApi('set_qq_avatar', { file }); }
|
|
269
|
-
async getFile(fileId) { return this.callApi('get_file', { file_id: fileId }); }
|
|
270
|
-
async forwardFriendSingleMsg(userId, messageId) { return this.callApi('forward_friend_single_msg', { user_id: userId, message_id: messageId }); }
|
|
271
|
-
async forwardGroupSingleMsg(groupId, messageId) { return this.callApi('forward_group_single_msg', { group_id: groupId, message_id: messageId }); }
|
|
272
|
-
async translateEn2Zh(sourceText) { return this.callApi('translate_en2zh', { source_text: sourceText }); }
|
|
273
|
-
async setMsgEmojiLike(messageId, emojiId) { return this.callApi('set_msg_emoji_like', { message_id: messageId, emoji_id: emojiId }); }
|
|
274
|
-
async sendForwardMsg(messageType, id, messages) {
|
|
275
|
-
return this.callApi('send_forward_msg', { message_type: messageType, [messageType === 'group' ? 'group_id' : 'user_id']: id, messages });
|
|
276
|
-
}
|
|
277
|
-
async markPrivateMsgAsRead(userId) { return this.callApi('mark_private_msg_as_read', { user_id: userId }); }
|
|
278
|
-
async markGroupMsgAsRead(groupId) { return this.callApi('mark_group_msg_as_read', { group_id: groupId }); }
|
|
279
|
-
async getFriendMsgHistory(userId, messageSeq, count) { return this.callApi('get_friend_msg_history', { user_id: userId, message_seq: messageSeq, count }); }
|
|
280
|
-
async createCollection(briefContent, rawData) { return this.callApi('create_collection', { brief: briefContent, rawData }); }
|
|
281
|
-
async getCollectionList(page = 0, limit = 20) { return this.callApi('get_collection_list', { page, limit }); }
|
|
282
|
-
async setSelfLongnick(longnick) { return this.callApi('set_self_longnick', { longNick: longnick }); }
|
|
283
|
-
async getRecentContact(count = 10) { return this.callApi('get_recent_contact', { count }); }
|
|
284
|
-
async markAllAsRead() { return this.callApi('_mark_all_as_read'); }
|
|
285
|
-
async getProfileLike() { return this.callApi('get_profile_like'); }
|
|
286
|
-
async fetchCustomFace() { return this.callApi('fetch_custom_face'); }
|
|
287
|
-
async fetchEmojiLike(messageId, emojiId, emojiType) { return this.callApi('fetch_emoji_like', { message_id: messageId, emoji_id: emojiId, emoji_type: emojiType }); }
|
|
288
|
-
async setInputStatus(userId, eventType) { return this.callApi('set_input_status', { user_id: userId, event_type: eventType }); }
|
|
289
|
-
async getGroupInfoEx(groupId) { return this.callApi('get_group_info_ex', { group_id: groupId }); }
|
|
290
|
-
async getGroupIgnoreAddRequest(groupId) { return this.callApi('get_group_ignore_add_request', { group_id: groupId }); }
|
|
291
|
-
async friendPoke(userId) { return this.callApi('friend_poke', { user_id: userId }); }
|
|
292
|
-
async groupPoke(groupId, userId) { return this.callApi('group_poke', { group_id: groupId, user_id: userId }); }
|
|
293
|
-
async sendPoke(userId, groupId) { return this.callApi('send_poke', { user_id: userId, group_id: groupId }); }
|
|
294
|
-
async ncGetPacketStatus() { return this.callApi('nc_get_packet_status'); }
|
|
295
|
-
async ncGetUserStatus(userId) { return this.callApi('nc_get_user_status', { user_id: userId }); }
|
|
296
|
-
async ncGetRkey() { return this.callApi('nc_get_rkey'); }
|
|
297
|
-
async getGroupShutList(groupId) { return this.callApi('get_group_shut_list', { group_id: groupId }); }
|
|
298
|
-
async getMiniAppArk(type, title, desc, picUrl, jumpUrl) {
|
|
299
|
-
return this.callApi('get_mini_app_ark', { type, title, desc, picUrl, jumpUrl });
|
|
300
|
-
}
|
|
301
|
-
async getAiRecord(groupId, characterId, text) { return this.callApi('get_ai_record', { group_id: groupId, character: characterId, text }); }
|
|
302
|
-
async getAiCharacters(groupId) { return this.callApi('get_ai_characters', { group_id: groupId }); }
|
|
303
|
-
async sendGroupAiRecord(groupId, characterId, text) { return this.callApi('send_group_ai_record', { group_id: groupId, character: characterId, text }); }
|
|
304
|
-
// ══════════════════════════════════════════════════════════════════
|
|
305
|
-
// Adapter 群管理接口适配
|
|
306
|
-
// ══════════════════════════════════════════════════════════════════
|
|
307
|
-
async kickMember(groupId, userId, reject = false) { await this.setGroupKick(groupId, userId, reject); return true; }
|
|
308
|
-
async muteMember(groupId, userId, duration = 600) { await this.setGroupBan(groupId, userId, duration); return true; }
|
|
309
|
-
async muteAll(groupId, enable = true) { await this.setGroupWholeBan(groupId, enable); return true; }
|
|
310
|
-
async setAdmin(groupId, userId, enable = true) { await this.setGroupAdmin(groupId, userId, enable); return true; }
|
|
311
|
-
async setCard(groupId, userId, card) { await this.setGroupCard(groupId, userId, card); return true; }
|
|
312
|
-
async setTitle(groupId, userId, title, duration = -1) { await this.setGroupSpecialTitle(groupId, userId, title, duration); return true; }
|
|
313
|
-
async getMemberList(groupId) { return this.getGroupMemberList(groupId); }
|
|
314
|
-
}
|
|
315
|
-
//# sourceMappingURL=endpoint-base.js.map
|