@zhin.js/adapter-icqq 1.1.16 → 1.1.18
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 +72 -0
- package/README.md +44 -3
- package/adapters/icqq/index.js +10 -2
- package/adapters/icqq/index.ts +10 -2
- package/agents/icqq/members.js +16 -0
- package/agents/icqq/members.ts +17 -0
- package/agents/icqq/skills/icqq-group-admin/tools/essence/index.js +1 -1
- package/agents/icqq/skills/icqq-group-admin/tools/essence/index.ts +1 -1
- package/agents/icqq/skills/icqq-group-admin/tools/group_invite/index.js +2 -2
- package/agents/icqq/skills/icqq-group-admin/tools/group_invite/index.ts +2 -2
- package/agents/icqq/skills/icqq-group-admin/tools/group_leave/index.js +1 -0
- package/agents/icqq/skills/icqq-group-admin/tools/group_leave/index.ts +1 -0
- package/agents/icqq/skills/icqq-group-admin/tools/recall_member_message/index.js +2 -1
- package/agents/icqq/skills/icqq-group-admin/tools/recall_member_message/index.ts +2 -1
- package/agents/icqq/skills/icqq-group-admin/tools/set_anonymous/index.js +2 -2
- package/agents/icqq/skills/icqq-group-admin/tools/set_anonymous/index.ts +2 -2
- package/agents/icqq/skills/icqq-group-admin/tools/set_mute/index.js +4 -4
- package/agents/icqq/skills/icqq-group-admin/tools/set_mute/index.ts +4 -4
- package/agents/icqq/skills/icqq-group-admin/tools/set_title/index.js +4 -4
- package/agents/icqq/skills/icqq-group-admin/tools/set_title/index.ts +4 -4
- package/agents/icqq/skills/icqq-group-directory/tools/group_member_info/index.js +16 -6
- package/agents/icqq/skills/icqq-group-directory/tools/group_member_info/index.ts +16 -5
- package/agents/icqq/skills/icqq-messages/tools/forward_messages/index.js +1 -1
- package/agents/icqq/skills/icqq-messages/tools/forward_messages/index.ts +1 -1
- package/agents/icqq/skills/icqq-messages/tools/quote_reply/index.js +1 -1
- package/agents/icqq/skills/icqq-messages/tools/quote_reply/index.ts +1 -1
- package/agents/icqq/skills/icqq-messages/tools/recall_own_message/index.js +1 -1
- package/agents/icqq/skills/icqq-messages/tools/recall_own_message/index.ts +1 -1
- package/agents/icqq/system.md +3 -3
- package/commands/icqq/login/code/index.js +28 -0
- package/commands/icqq/login/code/index.ts +30 -0
- package/commands/icqq/login/confirm/index.js +20 -0
- package/commands/icqq/login/confirm/index.ts +21 -0
- package/commands/icqq/login/definition.js +65 -0
- package/commands/icqq/login/definition.ts +72 -0
- package/commands/icqq/login/qr/index.js +53 -0
- package/commands/icqq/login/qr/index.ts +55 -0
- package/commands/icqq/login/retry/index.js +21 -0
- package/commands/icqq/login/retry/index.ts +23 -0
- package/commands/icqq/login/status/index.js +31 -0
- package/commands/icqq/login/status/index.ts +34 -0
- package/lib/console-spec.d.ts +17 -0
- package/lib/console-spec.js +11 -0
- package/lib/console.d.ts +8 -0
- package/lib/console.js +16 -0
- package/lib/endpoint.d.ts +9 -2
- package/lib/endpoint.js +200 -45
- package/lib/group-moderation.js +7 -2
- package/lib/group-scene.d.ts +11 -0
- package/lib/group-scene.js +71 -0
- package/lib/icqq-inbound.d.ts +2 -0
- package/lib/icqq-inbound.js +3 -0
- package/lib/icqq-inbox.d.ts +5 -0
- package/lib/icqq-inbox.js +14 -0
- package/lib/icqq-login-control.d.ts +18 -0
- package/lib/icqq-login-control.js +8 -0
- package/lib/index.d.ts +1 -1
- package/lib/index.js +1 -1
- package/lib/protocol.d.ts +12 -0
- package/lib/protocol.js +28 -11
- package/package.json +17 -9
- package/pages/index/index.js +15 -0
- package/pages/index/index.ts +16 -0
- package/plugin.js +6 -1
- package/schema.json +174 -0
- package/src/console-spec.ts +17 -0
- package/src/console.ts +21 -0
- package/src/endpoint.ts +199 -49
- package/src/group-moderation.ts +7 -2
- package/src/group-scene.ts +76 -0
- package/src/icqq-inbound.ts +5 -0
- package/src/icqq-inbox.ts +15 -0
- package/src/icqq-login-control.ts +30 -0
- package/src/index.ts +2 -0
- package/src/protocol.ts +38 -10
package/lib/protocol.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { isMediaRef } from '@zhin.js/im-contract';
|
|
2
|
+
import { resolveAdapterNotifyTarget } from 'zhin.js/adapter';
|
|
2
3
|
import { resolveIcqqMediaFile } from "./cq-message.js";
|
|
3
4
|
export { resolveIcqqInboundMessageId } from "./icqq-inbound.js";
|
|
4
5
|
/**
|
|
@@ -190,6 +191,7 @@ export function resolveIcqqConfig(config) {
|
|
|
190
191
|
const autoServer = config.autoServer ?? true;
|
|
191
192
|
const qqnt = config.qqnt;
|
|
192
193
|
const ntLogin = config.ntLogin;
|
|
194
|
+
const notify = resolveAdapterNotifyTarget(config.notify);
|
|
193
195
|
return {
|
|
194
196
|
context: 'icqq',
|
|
195
197
|
id,
|
|
@@ -206,6 +208,7 @@ export function resolveIcqqConfig(config) {
|
|
|
206
208
|
...(autoServer != null ? { autoServer } : {}),
|
|
207
209
|
...(qqnt != null ? { qqnt } : {}),
|
|
208
210
|
...(ntLogin != null ? { ntLogin } : {}),
|
|
211
|
+
...(notify ? { notify } : {}),
|
|
209
212
|
};
|
|
210
213
|
}
|
|
211
214
|
/**
|
|
@@ -232,7 +235,8 @@ export function icqqInboundConversation(endpointKey, input) {
|
|
|
232
235
|
parent: { kind: 'channel', id: input.guildId },
|
|
233
236
|
};
|
|
234
237
|
}
|
|
235
|
-
|
|
238
|
+
const name = input.channelType === 'group' ? input.name?.trim() : undefined;
|
|
239
|
+
return { endpoint, kind: input.channelType, id: input.channelId, ...(name ? { name } : {}) };
|
|
236
240
|
}
|
|
237
241
|
/**
|
|
238
242
|
* 出站:从 ConversationRef 派生 action 路由。
|
|
@@ -325,22 +329,34 @@ export function formatOutboundBody(payload) {
|
|
|
325
329
|
* quote or whitespace are dropped: a standalone element cannot carry the quote.
|
|
326
330
|
*/
|
|
327
331
|
export function formatOutboundMessages(payload) {
|
|
332
|
+
return formatOutboundMessageParts(payload).map(part => part.message);
|
|
333
|
+
}
|
|
334
|
+
export function formatOutboundMessageParts(payload) {
|
|
328
335
|
if (!Array.isArray(payload)) {
|
|
329
|
-
|
|
336
|
+
if (isWireSegment(payload))
|
|
337
|
+
return formatOutboundMessageParts([payload]);
|
|
338
|
+
const message = formatOutboundBody(payload);
|
|
339
|
+
return [{ message, ...(typeof payload === 'string' && message !== payload ? {} : { sourceIndices: [0] }) }];
|
|
330
340
|
}
|
|
331
341
|
const groups = [[]];
|
|
332
|
-
for (const
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
342
|
+
for (const [sourceIndex, source] of payload.entries()) {
|
|
343
|
+
for (const element of formatOutboundElements([source])) {
|
|
344
|
+
const item = { element, sourceIndex };
|
|
345
|
+
if (isStandaloneElement(element))
|
|
346
|
+
groups.push([item], []);
|
|
347
|
+
else
|
|
348
|
+
groups.at(-1).push(item);
|
|
349
|
+
}
|
|
337
350
|
}
|
|
338
|
-
const messages = groups.filter(group => group.some(element => typeof element === 'string'
|
|
351
|
+
const messages = groups.filter(group => group.some(({ element }) => typeof element === 'string'
|
|
339
352
|
? element.trim() !== ''
|
|
340
353
|
: element.type !== 'reply' && element.type !== 'quote'));
|
|
341
354
|
if (messages.length === 0)
|
|
342
|
-
return ['\u200b'];
|
|
343
|
-
return messages.map(group =>
|
|
355
|
+
return [{ message: '\u200b', sourceIndices: [] }];
|
|
356
|
+
return messages.map(group => ({
|
|
357
|
+
message: group.length === 1 ? group[0].element : group.map(item => item.element),
|
|
358
|
+
sourceIndices: [...new Set(group.map(item => item.sourceIndex))],
|
|
359
|
+
}));
|
|
344
360
|
}
|
|
345
361
|
function isStandaloneElement(element) {
|
|
346
362
|
return typeof element !== 'string' && ICQQ_STANDALONE_ELEMENTS.has(element.type);
|
|
@@ -362,7 +378,8 @@ function formatOutboundElements(payload) {
|
|
|
362
378
|
if (!Number.isSafeInteger(qq) || qq <= 0) {
|
|
363
379
|
throw new TypeError(`Invalid ICQQ mention target: ${String(target ?? '')}`);
|
|
364
380
|
}
|
|
365
|
-
|
|
381
|
+
const name = typeof item.data?.name === 'string' ? item.data.name.trim() : '';
|
|
382
|
+
return name ? { type: 'at', qq, text: name.startsWith('@') ? name : `@${name}` } : { type: 'at', qq };
|
|
366
383
|
}
|
|
367
384
|
case 'image': {
|
|
368
385
|
const arg = resolveIcqqMediaFile(normalizeIcqqImageData(item.data));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zhin.js/adapter-icqq",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.18",
|
|
4
4
|
"description": "Zhin.js ICQQ adapter — direct connection to @icqqjs/icqq",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./lib/index.js",
|
|
@@ -33,24 +33,27 @@
|
|
|
33
33
|
"directory": "plugins/adapters/icqq"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@zhin.js/adapter": "1.1.
|
|
36
|
+
"@zhin.js/adapter": "1.1.25",
|
|
37
37
|
"@zhin.js/agent-feature": "1.1.10",
|
|
38
|
-
"@zhin.js/
|
|
38
|
+
"@zhin.js/client": "1.1.21",
|
|
39
|
+
"@zhin.js/console-contract": "1.1.3",
|
|
40
|
+
"@zhin.js/core": "1.1.53",
|
|
39
41
|
"@zhin.js/feature-kit": "1.1.9",
|
|
40
|
-
"@zhin.js/im-contract": "1.1.
|
|
42
|
+
"@zhin.js/im-contract": "1.1.9",
|
|
41
43
|
"@zhin.js/logger": "1.1.2",
|
|
44
|
+
"@zhin.js/page": "1.1.10",
|
|
42
45
|
"@zhin.js/permission": "1.1.9",
|
|
43
46
|
"@zhin.js/skill": "1.1.10",
|
|
44
|
-
"@zhin.js/tool": "1.1.
|
|
47
|
+
"@zhin.js/tool": "1.1.12"
|
|
45
48
|
},
|
|
46
49
|
"peerDependencies": {
|
|
47
50
|
"@icqqjs/icqq": "^1.12.2",
|
|
48
51
|
"zod": "^4.0.0",
|
|
49
|
-
"@zhin.js/adapter": "^1.1.
|
|
52
|
+
"@zhin.js/adapter": "^1.1.25",
|
|
50
53
|
"@zhin.js/command": "^1.1.11",
|
|
51
|
-
"@zhin.js/core": "^1.1.
|
|
54
|
+
"@zhin.js/core": "^1.1.53",
|
|
52
55
|
"@zhin.js/prompt-section": "^1.1.9",
|
|
53
|
-
"zhin.js": "^1.1.
|
|
56
|
+
"zhin.js": "^1.1.18"
|
|
54
57
|
},
|
|
55
58
|
"peerDependenciesMeta": {
|
|
56
59
|
"@icqqjs/icqq": {
|
|
@@ -76,11 +79,12 @@
|
|
|
76
79
|
"vitest": "^4.1.10",
|
|
77
80
|
"zod": "^4.4.3",
|
|
78
81
|
"@zhin.js/prompt-section": "1.1.9",
|
|
79
|
-
"zhin.js": "1.1.
|
|
82
|
+
"zhin.js": "1.1.18"
|
|
80
83
|
},
|
|
81
84
|
"files": [
|
|
82
85
|
"adapters",
|
|
83
86
|
"commands",
|
|
87
|
+
"pages",
|
|
84
88
|
"plugin.js",
|
|
85
89
|
"schema.json",
|
|
86
90
|
"src",
|
|
@@ -124,6 +128,10 @@
|
|
|
124
128
|
{
|
|
125
129
|
"package": "@zhin.js/agent-feature",
|
|
126
130
|
"api": "^1.0.0"
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
"package": "@zhin.js/page",
|
|
134
|
+
"api": "^1.0.0"
|
|
127
135
|
}
|
|
128
136
|
],
|
|
129
137
|
"plugins": []
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// Generated by build-plugin-runtime-entries.mjs. Do not edit.
|
|
2
|
+
import { definePage } from '@zhin.js/console-contract';
|
|
3
|
+
import { createAdapterConsolePage } from '@zhin.js/client';
|
|
4
|
+
export const meta = definePage({
|
|
5
|
+
title: 'ICQQ',
|
|
6
|
+
titleI18n: { en: 'ICQQ' },
|
|
7
|
+
icon: 'MessageCircle',
|
|
8
|
+
order: 64,
|
|
9
|
+
requiredPermissions: ['icqq:read'],
|
|
10
|
+
});
|
|
11
|
+
/**
|
|
12
|
+
* Convention page: `pages/index/index.ts` → `/icqq`(插件路径)。
|
|
13
|
+
* 连接状态、连接测试、endpoint 增删;登录待办来自 LoginAssist(ICQQ 等)。
|
|
14
|
+
*/
|
|
15
|
+
export default createAdapterConsolePage('icqq');
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { definePage } from '@zhin.js/console-contract';
|
|
2
|
+
import { createAdapterConsolePage } from '@zhin.js/client';
|
|
3
|
+
|
|
4
|
+
export const meta = definePage({
|
|
5
|
+
title: 'ICQQ',
|
|
6
|
+
titleI18n: { en: 'ICQQ' },
|
|
7
|
+
icon: 'MessageCircle',
|
|
8
|
+
order: 64,
|
|
9
|
+
requiredPermissions: ['icqq:read'],
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Convention page: `pages/index/index.ts` → `/icqq`(插件路径)。
|
|
14
|
+
* 连接状态、连接测试、endpoint 增删;登录待办来自 LoginAssist(ICQQ 等)。
|
|
15
|
+
*/
|
|
16
|
+
export default createAdapterConsolePage('icqq');
|
package/plugin.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
// Generated by build-plugin-runtime-entries.mjs. Do not edit.
|
|
2
2
|
import { createEndpointRuntimeState } from 'zhin.js/adapter';
|
|
3
|
-
import { definePlugin } from 'zhin.js';
|
|
3
|
+
import { definePlugin, pluginConsoleRpcToken } from 'zhin.js';
|
|
4
4
|
import { permissionHostToken, createSceneRolePlatformChecker } from '@zhin.js/permission';
|
|
5
5
|
import { icqqRuntimeStateToken } from "./lib/icqq-runtime-state.js";
|
|
6
|
+
import { icqqLoginControlToken } from "./lib/icqq-login-control.js";
|
|
7
|
+
import { createIcqqConsoleRpc } from "./lib/console.js";
|
|
6
8
|
export default definePlugin({
|
|
7
9
|
name: 'icqq',
|
|
8
10
|
metadata: {
|
|
@@ -11,6 +13,9 @@ export default definePlugin({
|
|
|
11
13
|
setup(context) {
|
|
12
14
|
// 运行中 endpoint 注册表(icqq endpoint list 的"运行中"数据源)
|
|
13
15
|
context.resources.provide(icqqRuntimeStateToken, createEndpointRuntimeState());
|
|
16
|
+
// 掉线恢复命令用:当前 generation 每个 UIN 的登录控制面
|
|
17
|
+
context.resources.provide(icqqLoginControlToken, new Map());
|
|
18
|
+
context.resources.provide(pluginConsoleRpcToken, createIcqqConsoleRpc(context.resources, () => context.config.get()));
|
|
14
19
|
const disposePlatform = context.resources.has(permissionHostToken)
|
|
15
20
|
? context.resources.use(permissionHostToken).registerPlatform('icqq', createSceneRolePlatformChecker())
|
|
16
21
|
: undefined;
|
package/schema.json
CHANGED
|
@@ -346,6 +346,93 @@
|
|
|
346
346
|
"description": "Command prefix for this endpoint."
|
|
347
347
|
}
|
|
348
348
|
}
|
|
349
|
+
},
|
|
350
|
+
"notify": {
|
|
351
|
+
"type": "object",
|
|
352
|
+
"additionalProperties": false,
|
|
353
|
+
"description": "掉线/登录失败时通过另一个适配器实例给 master 发通知(adapter/endpoint/kind/id 指向实际会话)",
|
|
354
|
+
"x-i18n": {
|
|
355
|
+
"en": {
|
|
356
|
+
"description": "Send outage/login notices to the master through another adapter instance (adapter/endpoint/kind/id identify the actual conversation)."
|
|
357
|
+
}
|
|
358
|
+
},
|
|
359
|
+
"properties": {
|
|
360
|
+
"adapter": {
|
|
361
|
+
"type": "string",
|
|
362
|
+
"description": "通知使用的适配器类型,如 qq / icqq",
|
|
363
|
+
"x-i18n": {
|
|
364
|
+
"en": {
|
|
365
|
+
"description": "Adapter type used for the notice, such as qq or icqq."
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
},
|
|
369
|
+
"endpoint": {
|
|
370
|
+
"type": "string",
|
|
371
|
+
"description": "该适配器的 endpoint id",
|
|
372
|
+
"x-i18n": {
|
|
373
|
+
"en": {
|
|
374
|
+
"description": "Endpoint id of that adapter."
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
},
|
|
378
|
+
"kind": {
|
|
379
|
+
"type": "string",
|
|
380
|
+
"enum": [
|
|
381
|
+
"private",
|
|
382
|
+
"group",
|
|
383
|
+
"channel"
|
|
384
|
+
],
|
|
385
|
+
"default": "private",
|
|
386
|
+
"description": "会话类型,默认 private",
|
|
387
|
+
"x-i18n": {
|
|
388
|
+
"en": {
|
|
389
|
+
"description": "Conversation kind; defaults to private."
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
},
|
|
393
|
+
"id": {
|
|
394
|
+
"type": [
|
|
395
|
+
"string",
|
|
396
|
+
"number"
|
|
397
|
+
],
|
|
398
|
+
"description": "master 在该平台上的会话 id(QQ 官方为 openid,ICQQ 为 QQ 号)",
|
|
399
|
+
"x-i18n": {
|
|
400
|
+
"en": {
|
|
401
|
+
"description": "Master conversation id on that platform (openid for QQ official, QQ number for ICQQ)."
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
},
|
|
405
|
+
"parent": {
|
|
406
|
+
"type": "object",
|
|
407
|
+
"additionalProperties": false,
|
|
408
|
+
"properties": {
|
|
409
|
+
"kind": {
|
|
410
|
+
"type": "string",
|
|
411
|
+
"enum": [
|
|
412
|
+
"private",
|
|
413
|
+
"group",
|
|
414
|
+
"channel"
|
|
415
|
+
]
|
|
416
|
+
},
|
|
417
|
+
"id": {
|
|
418
|
+
"type": [
|
|
419
|
+
"string",
|
|
420
|
+
"number"
|
|
421
|
+
]
|
|
422
|
+
}
|
|
423
|
+
},
|
|
424
|
+
"required": [
|
|
425
|
+
"kind",
|
|
426
|
+
"id"
|
|
427
|
+
],
|
|
428
|
+
"description": "可选的父频道/群容器"
|
|
429
|
+
}
|
|
430
|
+
},
|
|
431
|
+
"required": [
|
|
432
|
+
"adapter",
|
|
433
|
+
"endpoint",
|
|
434
|
+
"id"
|
|
435
|
+
]
|
|
349
436
|
}
|
|
350
437
|
},
|
|
351
438
|
"required": [
|
|
@@ -367,6 +454,93 @@
|
|
|
367
454
|
"description": "Command prefix, empty by default. Each endpoints[i] can override it."
|
|
368
455
|
}
|
|
369
456
|
}
|
|
457
|
+
},
|
|
458
|
+
"notify": {
|
|
459
|
+
"type": "object",
|
|
460
|
+
"additionalProperties": false,
|
|
461
|
+
"description": "掉线/登录失败时通过另一个适配器实例给 master 发通知(adapter/endpoint/kind/id 指向实际会话)",
|
|
462
|
+
"x-i18n": {
|
|
463
|
+
"en": {
|
|
464
|
+
"description": "Send outage/login notices to the master through another adapter instance (adapter/endpoint/kind/id identify the actual conversation)."
|
|
465
|
+
}
|
|
466
|
+
},
|
|
467
|
+
"properties": {
|
|
468
|
+
"adapter": {
|
|
469
|
+
"type": "string",
|
|
470
|
+
"description": "通知使用的适配器类型,如 qq / icqq",
|
|
471
|
+
"x-i18n": {
|
|
472
|
+
"en": {
|
|
473
|
+
"description": "Adapter type used for the notice, such as qq or icqq."
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
},
|
|
477
|
+
"endpoint": {
|
|
478
|
+
"type": "string",
|
|
479
|
+
"description": "该适配器的 endpoint id",
|
|
480
|
+
"x-i18n": {
|
|
481
|
+
"en": {
|
|
482
|
+
"description": "Endpoint id of that adapter."
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
},
|
|
486
|
+
"kind": {
|
|
487
|
+
"type": "string",
|
|
488
|
+
"enum": [
|
|
489
|
+
"private",
|
|
490
|
+
"group",
|
|
491
|
+
"channel"
|
|
492
|
+
],
|
|
493
|
+
"default": "private",
|
|
494
|
+
"description": "会话类型,默认 private",
|
|
495
|
+
"x-i18n": {
|
|
496
|
+
"en": {
|
|
497
|
+
"description": "Conversation kind; defaults to private."
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
},
|
|
501
|
+
"id": {
|
|
502
|
+
"type": [
|
|
503
|
+
"string",
|
|
504
|
+
"number"
|
|
505
|
+
],
|
|
506
|
+
"description": "master 在该平台上的会话 id(QQ 官方为 openid,ICQQ 为 QQ 号)",
|
|
507
|
+
"x-i18n": {
|
|
508
|
+
"en": {
|
|
509
|
+
"description": "Master conversation id on that platform (openid for QQ official, QQ number for ICQQ)."
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
},
|
|
513
|
+
"parent": {
|
|
514
|
+
"type": "object",
|
|
515
|
+
"additionalProperties": false,
|
|
516
|
+
"properties": {
|
|
517
|
+
"kind": {
|
|
518
|
+
"type": "string",
|
|
519
|
+
"enum": [
|
|
520
|
+
"private",
|
|
521
|
+
"group",
|
|
522
|
+
"channel"
|
|
523
|
+
]
|
|
524
|
+
},
|
|
525
|
+
"id": {
|
|
526
|
+
"type": [
|
|
527
|
+
"string",
|
|
528
|
+
"number"
|
|
529
|
+
]
|
|
530
|
+
}
|
|
531
|
+
},
|
|
532
|
+
"required": [
|
|
533
|
+
"kind",
|
|
534
|
+
"id"
|
|
535
|
+
],
|
|
536
|
+
"description": "可选的父频道/群容器"
|
|
537
|
+
}
|
|
538
|
+
},
|
|
539
|
+
"required": [
|
|
540
|
+
"adapter",
|
|
541
|
+
"endpoint",
|
|
542
|
+
"id"
|
|
543
|
+
]
|
|
370
544
|
}
|
|
371
545
|
},
|
|
372
546
|
"required": [
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ICQQ Console 页面元数据(浏览器与服务端共享;不要在这里 import 服务端代码)。
|
|
3
|
+
*/
|
|
4
|
+
import type { AdapterConsoleField } from 'zhin.js/adapter';
|
|
5
|
+
|
|
6
|
+
export const icqqConsoleSpec = {
|
|
7
|
+
adapterKey: 'icqq',
|
|
8
|
+
adapterDisplayName: 'ICQQ',
|
|
9
|
+
fields: [
|
|
10
|
+
] as readonly AdapterConsoleField[],
|
|
11
|
+
docsUrl: 'https://zhin.js.org/adapters/icqq',
|
|
12
|
+
readPermission: 'icqq:read',
|
|
13
|
+
writePermission: 'icqq:write',
|
|
14
|
+
idPattern: /^\d+$/,
|
|
15
|
+
idHint: 'ICQQ endpoint id 是 QQ 号(纯数字)',
|
|
16
|
+
idHintI18n: { en: 'ICQQ endpoint ID is the QQ number (digits only)' },
|
|
17
|
+
} as const;
|
package/src/console.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ICQQ Console RPC:运行状态 + endpoint 增删(原 `icqq endpoint` 聊天命令)。
|
|
3
|
+
*
|
|
4
|
+
* 页面绑定 `pages/index`,读取 / 写入分别要求 `<adapter>:read` / `<adapter>:write`。
|
|
5
|
+
*/
|
|
6
|
+
import { createAdapterConsoleRpc, type AdapterConsoleResources } from 'zhin.js/adapter';
|
|
7
|
+
import type { PluginConsoleRpc } from 'zhin.js';
|
|
8
|
+
import { icqqRuntimeStateToken } from './icqq-runtime-state.js';
|
|
9
|
+
import { icqqConsoleSpec } from './console-spec.js';
|
|
10
|
+
|
|
11
|
+
export function createIcqqConsoleRpc(
|
|
12
|
+
resources: AdapterConsoleResources,
|
|
13
|
+
getConfig: () => unknown,
|
|
14
|
+
): PluginConsoleRpc {
|
|
15
|
+
const state = resources.use(icqqRuntimeStateToken);
|
|
16
|
+
return createAdapterConsoleRpc({
|
|
17
|
+
...icqqConsoleSpec,
|
|
18
|
+
running: () => state.endpoints.values(),
|
|
19
|
+
getConfig,
|
|
20
|
+
}, resources);
|
|
21
|
+
}
|