@zhin.js/adapter-napcat 0.1.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/lib/types.d.ts ADDED
@@ -0,0 +1,275 @@
1
+ /**
2
+ * NapCat 适配器类型定义
3
+ * 覆盖 OneBot11 标准 + go-cqhttp 扩展 + NapCat 独有 API
4
+ */
5
+ export interface NapCatConfigBase {
6
+ context: 'napcat';
7
+ name: string;
8
+ access_token?: string;
9
+ }
10
+ /** 正向 WebSocket */
11
+ export interface NapCatWsClientConfig extends NapCatConfigBase {
12
+ connection: 'ws';
13
+ url: string;
14
+ reconnect_interval?: number;
15
+ heartbeat_interval?: number;
16
+ }
17
+ /** 反向 WebSocket */
18
+ export interface NapCatWsServerConfig extends NapCatConfigBase {
19
+ connection: 'wss';
20
+ path: string;
21
+ heartbeat_interval?: number;
22
+ }
23
+ /** HTTP API + POST 上报 */
24
+ export interface NapCatHttpConfig extends NapCatConfigBase {
25
+ connection: 'http';
26
+ /** NapCat HTTP API 地址,如 http://127.0.0.1:3000 */
27
+ http_url: string;
28
+ /** HTTP POST 事件上报接收路径,如 /napcat/post */
29
+ post_path: string;
30
+ /** 轮询间隔(ms),用于 HTTP 心跳检测,默认 30000 */
31
+ poll_interval?: number;
32
+ }
33
+ export type NapCatBotConfig = NapCatWsClientConfig | NapCatWsServerConfig | NapCatHttpConfig;
34
+ export interface ApiResponse<T = any> {
35
+ status: string;
36
+ retcode: number;
37
+ data: T;
38
+ echo?: string;
39
+ message?: string;
40
+ wording?: string;
41
+ }
42
+ export interface MessageSegment {
43
+ type: string;
44
+ data: Record<string, any>;
45
+ }
46
+ export interface NapCatEvent {
47
+ post_type: 'message' | 'message_sent' | 'notice' | 'request' | 'meta_event';
48
+ self_id: number;
49
+ time: number;
50
+ }
51
+ export interface NapCatMessageEvent extends NapCatEvent {
52
+ post_type: 'message' | 'message_sent';
53
+ message_type: 'private' | 'group';
54
+ sub_type: string;
55
+ message_id: number;
56
+ user_id: number;
57
+ group_id?: number;
58
+ message: MessageSegment[];
59
+ raw_message: string;
60
+ font: number;
61
+ sender: {
62
+ user_id: number;
63
+ nickname: string;
64
+ card?: string;
65
+ sex?: string;
66
+ age?: number;
67
+ area?: string;
68
+ level?: string;
69
+ role?: 'owner' | 'admin' | 'member';
70
+ title?: string;
71
+ };
72
+ }
73
+ export interface NapCatNoticeEvent extends NapCatEvent {
74
+ post_type: 'notice';
75
+ notice_type: string;
76
+ sub_type?: string;
77
+ group_id?: number;
78
+ user_id?: number;
79
+ operator_id?: number;
80
+ message_id?: number;
81
+ target_id?: number;
82
+ file?: {
83
+ id: string;
84
+ name: string;
85
+ size: number;
86
+ busid: number;
87
+ url?: string;
88
+ };
89
+ duration?: number;
90
+ sender_id?: number;
91
+ title?: string;
92
+ action?: string;
93
+ suffix?: string;
94
+ comment?: string;
95
+ flag?: string;
96
+ }
97
+ export interface NapCatRequestEvent extends NapCatEvent {
98
+ post_type: 'request';
99
+ request_type: 'friend' | 'group';
100
+ sub_type?: string;
101
+ user_id: number;
102
+ group_id?: number;
103
+ comment?: string;
104
+ flag: string;
105
+ }
106
+ export interface NapCatMetaEvent extends NapCatEvent {
107
+ post_type: 'meta_event';
108
+ meta_event_type: string;
109
+ sub_type?: string;
110
+ status?: any;
111
+ interval?: number;
112
+ }
113
+ export interface SenderInfo {
114
+ id: string;
115
+ name: string;
116
+ role?: 'owner' | 'admin' | 'member';
117
+ isOwner?: boolean;
118
+ isAdmin?: boolean;
119
+ card?: string;
120
+ title?: string;
121
+ }
122
+ export interface LoginInfo {
123
+ user_id: number;
124
+ nickname: string;
125
+ }
126
+ export interface StrangerInfo {
127
+ user_id: number;
128
+ nickname: string;
129
+ sex: string;
130
+ age: number;
131
+ qid?: string;
132
+ level?: number;
133
+ login_days?: number;
134
+ }
135
+ export interface FriendInfo {
136
+ user_id: number;
137
+ nickname: string;
138
+ remark: string;
139
+ }
140
+ export interface GroupInfo {
141
+ group_id: number;
142
+ group_name: string;
143
+ group_memo?: string;
144
+ group_create_time?: number;
145
+ group_level?: number;
146
+ member_count: number;
147
+ max_member_count: number;
148
+ }
149
+ export interface GroupMemberInfo {
150
+ group_id: number;
151
+ user_id: number;
152
+ nickname: string;
153
+ card: string;
154
+ sex: string;
155
+ age: number;
156
+ area: string;
157
+ join_time: number;
158
+ last_sent_time: number;
159
+ level: string;
160
+ role: 'owner' | 'admin' | 'member';
161
+ unfriendly: boolean;
162
+ title: string;
163
+ title_expire_time: number;
164
+ card_changeable: boolean;
165
+ shut_up_timestamp?: number;
166
+ }
167
+ export interface MessageInfo {
168
+ time: number;
169
+ message_type: string;
170
+ message_id: number;
171
+ real_id: number;
172
+ sender: {
173
+ user_id: number;
174
+ nickname: string;
175
+ card?: string;
176
+ };
177
+ message: MessageSegment[];
178
+ }
179
+ export interface ForwardMessage {
180
+ messages: Array<{
181
+ content: MessageSegment[];
182
+ sender: {
183
+ nickname: string;
184
+ user_id: number;
185
+ };
186
+ time: number;
187
+ }>;
188
+ }
189
+ export interface GroupHonorInfo {
190
+ group_id: number;
191
+ current_talkative?: {
192
+ user_id: number;
193
+ nickname: string;
194
+ avatar: string;
195
+ day_count: number;
196
+ };
197
+ talkative_list?: any[];
198
+ performer_list?: any[];
199
+ legend_list?: any[];
200
+ strong_newbie_list?: any[];
201
+ emotion_list?: any[];
202
+ }
203
+ export interface EssenceMessage {
204
+ sender_id: number;
205
+ sender_nick: string;
206
+ sender_time: number;
207
+ operator_id: number;
208
+ operator_nick: string;
209
+ operator_time: number;
210
+ message_id: number;
211
+ }
212
+ export interface GroupFileSystemInfo {
213
+ file_count: number;
214
+ limit_count: number;
215
+ used_space: number;
216
+ total_space: number;
217
+ }
218
+ export interface GroupFileInfo {
219
+ files: Array<{
220
+ group_id: number;
221
+ file_id: string;
222
+ file_name: string;
223
+ busid: number;
224
+ file_size: number;
225
+ upload_time: number;
226
+ dead_time: number;
227
+ modify_time: number;
228
+ download_times: number;
229
+ uploader: number;
230
+ uploader_name: string;
231
+ }>;
232
+ folders: Array<{
233
+ group_id: number;
234
+ folder_id: string;
235
+ folder_name: string;
236
+ create_time: number;
237
+ creator: number;
238
+ creator_name: string;
239
+ total_file_count: number;
240
+ }>;
241
+ }
242
+ export interface GroupNotice {
243
+ sender_id: number;
244
+ publish_time: number;
245
+ message: {
246
+ text: string;
247
+ images?: Array<{
248
+ id: string;
249
+ height: string;
250
+ width: string;
251
+ }>;
252
+ };
253
+ }
254
+ export interface VersionInfo {
255
+ app_name: string;
256
+ app_version: string;
257
+ protocol_version: string;
258
+ [key: string]: any;
259
+ }
260
+ export interface OnlineStatus {
261
+ status: number;
262
+ ext_status: number;
263
+ }
264
+ export interface AiCharacter {
265
+ character_id: string;
266
+ character_name: string;
267
+ preview_url?: string;
268
+ }
269
+ export interface CollectionItem {
270
+ id: string;
271
+ type: number;
272
+ content: string;
273
+ create_time: number;
274
+ }
275
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,QAAQ,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,mBAAmB;AACnB,MAAM,WAAW,oBAAqB,SAAQ,gBAAgB;IAC5D,UAAU,EAAE,IAAI,CAAC;IACjB,GAAG,EAAE,MAAM,CAAC;IACZ,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC7B;AAED,mBAAmB;AACnB,MAAM,WAAW,oBAAqB,SAAQ,gBAAgB;IAC5D,UAAU,EAAE,KAAK,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC7B;AAED,yBAAyB;AACzB,MAAM,WAAW,gBAAiB,SAAQ,gBAAgB;IACxD,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@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;GAGG"}
package/package.json ADDED
@@ -0,0 +1,73 @@
1
+ {
2
+ "name": "@zhin.js/adapter-napcat",
3
+ "version": "0.1.0",
4
+ "description": "Zhin.js adapter for NapCatQQ (OneBot11 superset with go-cqhttp & NapCat extensions)",
5
+ "type": "module",
6
+ "main": "./lib/index.js",
7
+ "types": "./lib/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./lib/index.d.ts",
11
+ "development": "./src/index.ts",
12
+ "import": "./lib/index.js"
13
+ }
14
+ },
15
+ "files": [
16
+ "src",
17
+ "lib",
18
+ "skills",
19
+ "plugin.yml",
20
+ "README.md",
21
+ "CHANGELOG.md"
22
+ ],
23
+ "keywords": [
24
+ "zhin",
25
+ "zhin.js",
26
+ "bot",
27
+ "adapter",
28
+ "napcat",
29
+ "napneko",
30
+ "onebot",
31
+ "onebot11",
32
+ "qq",
33
+ "chatbot"
34
+ ],
35
+ "author": {
36
+ "name": "lc-cn",
37
+ "email": "admin@liucl.cn",
38
+ "url": "https://github.com/lc-cn"
39
+ },
40
+ "license": "MIT",
41
+ "repository": {
42
+ "url": "git+https://github.com/zhinjs/zhin.git",
43
+ "type": "git",
44
+ "directory": "plugins/adapters/napcat"
45
+ },
46
+ "dependencies": {
47
+ "ws": "^8.20.0"
48
+ },
49
+ "devDependencies": {
50
+ "@types/node": "^25.6.0",
51
+ "@types/ws": "^8.18.1",
52
+ "typescript": "^6.0.3",
53
+ "zhin.js": "1.0.72",
54
+ "@zhin.js/cli": "1.0.68"
55
+ },
56
+ "peerDependencies": {
57
+ "@zhin.js/http": "1.0.65",
58
+ "zhin.js": "1.0.72"
59
+ },
60
+ "peerDependenciesMeta": {
61
+ "@zhin.js/http": {
62
+ "optional": true
63
+ }
64
+ },
65
+ "publishConfig": {
66
+ "access": "public",
67
+ "registry": "https://registry.npmjs.org"
68
+ },
69
+ "scripts": {
70
+ "build": "zhin build",
71
+ "clean": "rimraf lib"
72
+ }
73
+ }
package/plugin.yml ADDED
@@ -0,0 +1,3 @@
1
+ name: adapter-napcat
2
+ description: NapCatQQ 适配器:OneBot11 + go-cqhttp 扩展 + NapCat 独有 API(戳一戳、表情回应、AI语音、群文件、精华消息、群公告等)
3
+ version: 0.1.0
@@ -0,0 +1,141 @@
1
+ ---
2
+ name: napcat
3
+ platforms:
4
+ - napcat
5
+ description: >-
6
+ NapCatQQ 完整能力:群管理(踢人、禁言、管理员、群名片、头衔)、消息收发、
7
+ 戳一戳、表情回应、合并转发、群文件管理、精华消息、群公告、AI语音TTS、
8
+ 图片OCR、小程序卡片、消息历史、在线状态、个人资料修改等。
9
+ 仅有昵称时请先 napcat_list_members 获取 user_id。
10
+ keywords:
11
+ - napcat
12
+ - napneko
13
+ - onebot11
14
+ - adapter:napcat
15
+ - qq
16
+ - 群管理
17
+ - 头衔
18
+ - 戳一戳
19
+ - 表情回应
20
+ - 合并转发
21
+ - 群文件
22
+ - 精华消息
23
+ - 群公告
24
+ - AI语音
25
+ - OCR
26
+ - 小程序
27
+ - list_members
28
+ tags:
29
+ - group
30
+ - management
31
+ - im
32
+ - qq
33
+ - napcat
34
+ tools:
35
+ # 通用群管工具(IGroupManagement 自动生成)
36
+ - napcat_kick_member
37
+ - napcat_mute_member
38
+ - napcat_mute_all
39
+ - napcat_set_admin
40
+ - napcat_set_nickname
41
+ - napcat_set_group_name
42
+ - napcat_list_members
43
+ - napcat_get_group_info
44
+ # NapCat 扩展工具
45
+ - napcat_send_poke
46
+ - napcat_set_emoji_reaction
47
+ - napcat_send_forward_msg
48
+ - napcat_forward_single_msg
49
+ - napcat_send_like
50
+ - napcat_set_essence_msg
51
+ - napcat_delete_essence_msg
52
+ - napcat_get_essence_list
53
+ - napcat_send_group_notice
54
+ - napcat_get_group_notice
55
+ - napcat_del_group_notice
56
+ - napcat_upload_group_file
57
+ - napcat_get_group_file_url
58
+ - napcat_get_group_root_files
59
+ - napcat_get_group_shut_list
60
+ - napcat_set_group_portrait
61
+ - napcat_set_title
62
+ - napcat_group_sign
63
+ - napcat_ai_tts
64
+ - napcat_get_ai_characters
65
+ - napcat_ocr_image
66
+ - napcat_get_mini_app_ark
67
+ - napcat_get_group_msg_history
68
+ - napcat_get_friend_msg_history
69
+ - napcat_get_user_status
70
+ - napcat_get_group_info_ex
71
+ - napcat_set_profile
72
+ - napcat_set_avatar
73
+ - napcat_set_online_status
74
+ - napcat_set_signature
75
+ - napcat_translate
76
+ - napcat_mark_msg_as_read
77
+ - napcat_download_file
78
+ - napcat_delete_friend
79
+ ---
80
+
81
+ ## 工具概览
82
+
83
+ ### 通用群管(IGroupManagement 自动生成)
84
+
85
+ | 工具 | 说明 | 权限 |
86
+ |------|------|------|
87
+ | `napcat_kick_member` | 踢出成员 | group_admin |
88
+ | `napcat_mute_member` | 禁言成员(duration=0 解除) | group_admin |
89
+ | `napcat_mute_all` | 全员禁言/解除 | group_admin |
90
+ | `napcat_set_admin` | 设置/取消管理员 | group_owner |
91
+ | `napcat_set_nickname` | 修改群昵称/名片 | group_admin |
92
+ | `napcat_set_group_name` | 修改群名称 | group_admin |
93
+ | `napcat_list_members` | 获取群成员列表 | user |
94
+ | `napcat_get_group_info` | 获取群信息 | user |
95
+
96
+ ### NapCat 扩展
97
+
98
+ | 工具 | 说明 | 权限 |
99
+ |------|------|------|
100
+ | `napcat_send_poke` | 戳一戳 | user |
101
+ | `napcat_set_emoji_reaction` | 表情回应 | user |
102
+ | `napcat_send_forward_msg` | 合并转发 | user |
103
+ | `napcat_forward_single_msg` | 单条转发 | user |
104
+ | `napcat_send_like` | 好友点赞 | user |
105
+ | `napcat_set_essence_msg` | 设置精华消息 | group_admin |
106
+ | `napcat_delete_essence_msg` | 取消精华消息 | group_admin |
107
+ | `napcat_get_essence_list` | 精华消息列表 | user |
108
+ | `napcat_send_group_notice` | 发群公告 | group_admin |
109
+ | `napcat_get_group_notice` | 获取群公告 | user |
110
+ | `napcat_del_group_notice` | 删除群公告 | group_admin |
111
+ | `napcat_upload_group_file` | 上传群文件 | user |
112
+ | `napcat_get_group_file_url` | 获取文件链接 | user |
113
+ | `napcat_get_group_root_files` | 群文件列表 | user |
114
+ | `napcat_get_group_shut_list` | 禁言列表 | user |
115
+ | `napcat_set_group_portrait` | 设置群头像 | group_admin |
116
+ | `napcat_set_title` | 设置专属头衔 | group_owner |
117
+ | `napcat_group_sign` | 群签到/打卡 | user |
118
+ | `napcat_ai_tts` | AI 文字转语音 | user |
119
+ | `napcat_get_ai_characters` | AI 语音角色列表 | user |
120
+ | `napcat_ocr_image` | 图片 OCR | user |
121
+ | `napcat_get_mini_app_ark` | 小程序卡片签名 | user |
122
+ | `napcat_get_group_msg_history` | 群消息历史 | user |
123
+ | `napcat_get_friend_msg_history` | 私聊历史 | user |
124
+ | `napcat_get_user_status` | 用户在线状态 | user |
125
+ | `napcat_get_group_info_ex` | 群额外信息 | user |
126
+ | `napcat_set_profile` | 修改资料 | user |
127
+ | `napcat_set_avatar` | 修改头像 | user |
128
+ | `napcat_set_online_status` | 设置在线状态 | user |
129
+ | `napcat_set_signature` | 设置个性签名 | user |
130
+ | `napcat_translate` | 英译中翻译 | user |
131
+ | `napcat_mark_msg_as_read` | 标记已读 | user |
132
+ | `napcat_download_file` | 下载文件 | user |
133
+ | `napcat_delete_friend` | 删除好友 | group_admin |
134
+
135
+ ## 执行规则
136
+
137
+ 1. 仅有昵称时先 `napcat_list_members` 获取用户 QQ 号
138
+ 2. 禁言 duration 单位为秒,默认 600(10 分钟),设为 0 解除
139
+ 3. 头衔设置需要群主权限
140
+ 4. AI 语音发送前可先用 `napcat_get_ai_characters` 查询可用角色
141
+ 5. 合并转发的 messages 参数为 JSON 格式的 node 数组
package/src/adapter.ts ADDED
@@ -0,0 +1,100 @@
1
+ /**
2
+ * NapCat 适配器:支持正向 WS / 反向 WS / HTTP
3
+ */
4
+ import type { Router } from '@zhin.js/http';
5
+ import { Adapter, Plugin } from 'zhin.js';
6
+ import { NapCatWsClient } from './bot-ws-client.js';
7
+ import { NapCatWsServer } from './bot-ws-server.js';
8
+ import { NapCatHttpBot } from './bot-http.js';
9
+ import type { NapCatBotConfig, NapCatWsClientConfig, NapCatWsServerConfig, NapCatHttpConfig } from './types.js';
10
+
11
+ export type NapCatBot = NapCatWsClient | NapCatWsServer | NapCatHttpBot;
12
+
13
+ export class NapCatAdapter extends Adapter<NapCatBot> {
14
+ #router?: Router;
15
+
16
+ constructor(plugin: Plugin) {
17
+ super(plugin, 'napcat', []);
18
+ }
19
+
20
+ createBot(config: NapCatBotConfig): NapCatBot {
21
+ const connection = config.connection ?? 'ws';
22
+ switch (connection) {
23
+ case 'ws':
24
+ return new NapCatWsClient(this, config as NapCatWsClientConfig);
25
+ case 'wss':
26
+ if (!this.#router) throw new Error('NapCat connection: wss requires router. Enable @zhin.js/http first.');
27
+ return new NapCatWsServer(this, this.#router, config as NapCatWsServerConfig);
28
+ case 'http':
29
+ if (!this.#router) throw new Error('NapCat connection: http requires router. Enable @zhin.js/http first.');
30
+ return new NapCatHttpBot(this, this.#router, config as NapCatHttpConfig);
31
+ default:
32
+ throw new Error(`Unknown NapCat connection: ${connection}`);
33
+ }
34
+ }
35
+
36
+ // ── 群管理接口(IGroupManagement 适配)──────────────────────────
37
+
38
+ async kickMember(botId: string, sceneId: string, userId: string) {
39
+ const bot = this.bots.get(botId);
40
+ if (!bot) throw new Error(`Bot ${botId} not found`);
41
+ return bot.kickMember(Number(sceneId), Number(userId));
42
+ }
43
+
44
+ async muteMember(botId: string, sceneId: string, userId: string, duration = 600) {
45
+ const bot = this.bots.get(botId);
46
+ if (!bot) throw new Error(`Bot ${botId} not found`);
47
+ return bot.muteMember(Number(sceneId), Number(userId), duration);
48
+ }
49
+
50
+ async muteAll(botId: string, sceneId: string, enable = true) {
51
+ const bot = this.bots.get(botId);
52
+ if (!bot) throw new Error(`Bot ${botId} not found`);
53
+ return bot.muteAll(Number(sceneId), enable);
54
+ }
55
+
56
+ async setAdmin(botId: string, sceneId: string, userId: string, enable = true) {
57
+ const bot = this.bots.get(botId);
58
+ if (!bot) throw new Error(`Bot ${botId} not found`);
59
+ return bot.setAdmin(Number(sceneId), Number(userId), enable);
60
+ }
61
+
62
+ async setMemberNickname(botId: string, sceneId: string, userId: string, nickname: string) {
63
+ const bot = this.bots.get(botId);
64
+ if (!bot) throw new Error(`Bot ${botId} not found`);
65
+ return bot.setCard(Number(sceneId), Number(userId), nickname);
66
+ }
67
+
68
+ async setGroupName(botId: string, sceneId: string, name: string) {
69
+ const bot = this.bots.get(botId);
70
+ if (!bot) throw new Error(`Bot ${botId} not found`);
71
+ return bot.setGroupName(Number(sceneId), name);
72
+ }
73
+
74
+ async listMembers(botId: string, sceneId: string) {
75
+ const bot = this.bots.get(botId);
76
+ if (!bot) throw new Error(`Bot ${botId} not found`);
77
+ const members = await bot.getMemberList(Number(sceneId));
78
+ return {
79
+ members: members.map((m: any) => ({
80
+ user_id: m.user_id, nickname: m.nickname, card: m.card, role: m.role, title: m.title,
81
+ })),
82
+ count: members.length,
83
+ };
84
+ }
85
+
86
+ async getGroupInfo(botId: string, sceneId: string) {
87
+ const bot = this.bots.get(botId);
88
+ if (!bot) throw new Error(`Bot ${botId} not found`);
89
+ return bot.getGroupInfo(Number(sceneId));
90
+ }
91
+
92
+ async start(): Promise<void> {
93
+ this.#router = (this.plugin.inject as (key: string) => Router | undefined)('router');
94
+ (this.plugin.useContext as (key: string, fn: (router: Router) => void) => void)('router', (router: Router) => {
95
+ this.#router = router;
96
+ });
97
+ await super.start();
98
+ this.plugin.logger.info('NapCat adapter started');
99
+ }
100
+ }