@zhin.js/adapter-onebot11 1.0.63 → 1.0.66
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 +31 -0
- package/lib/adapter.d.ts +0 -1
- package/lib/adapter.d.ts.map +1 -1
- package/lib/adapter.js +1 -31
- package/lib/adapter.js.map +1 -1
- package/lib/index.js +31 -2
- package/lib/index.js.map +1 -1
- package/package.json +5 -5
- package/skills/onebot11/SKILL.md +42 -3
- package/src/adapter.ts +0 -31
- package/src/index.ts +36 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,36 @@
|
|
|
1
1
|
# @zhin.js/adapter-onebot11
|
|
2
2
|
|
|
3
|
+
## 1.0.66
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 5073d4c: chore: chore: update TypeScript version to ^5.9.3 across all plugins and packages
|
|
8
|
+
feat: enhance ai-text-as-image output registration with off handler for cleanup
|
|
9
|
+
fix: remove unnecessary logging in ensureBuiltinFontsCached function
|
|
10
|
+
refactor: simplify action handlers in html-renderer tools
|
|
11
|
+
chore: add README files for queue-sandbox-poc and event-delivery packages
|
|
12
|
+
chore: adjust pnpm workspace configuration to exclude games directory
|
|
13
|
+
chore: update tsconfig to include plugins directory for TypeScript compilation
|
|
14
|
+
- Updated dependencies [5073d4c]
|
|
15
|
+
- zhin.js@1.0.60
|
|
16
|
+
- @zhin.js/http@1.0.55
|
|
17
|
+
|
|
18
|
+
## 1.0.65
|
|
19
|
+
|
|
20
|
+
### Patch Changes
|
|
21
|
+
|
|
22
|
+
- c212bf7: fix: 适配器优化
|
|
23
|
+
- Updated dependencies [c212bf7]
|
|
24
|
+
- zhin.js@1.0.59
|
|
25
|
+
- @zhin.js/http@1.0.54
|
|
26
|
+
|
|
27
|
+
## 1.0.64
|
|
28
|
+
|
|
29
|
+
### Patch Changes
|
|
30
|
+
|
|
31
|
+
- zhin.js@1.0.58
|
|
32
|
+
- @zhin.js/http@1.0.53
|
|
33
|
+
|
|
3
34
|
## 1.0.63
|
|
4
35
|
|
|
5
36
|
### Patch Changes
|
package/lib/adapter.d.ts
CHANGED
package/lib/adapter.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../src/adapter.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,OAAO,EACP,MAAM,
|
|
1
|
+
{"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../src/adapter.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,OAAO,EACP,MAAM,EACP,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,KAAK,EAGV,iBAAiB,EAClB,MAAM,YAAY,CAAC;AAEpB,MAAM,MAAM,WAAW,GAAG,gBAAgB,GAAG,gBAAgB,CAAC;AAE9D,qBAAa,eAAgB,SAAQ,OAAO,CAAC,WAAW,CAAC;;gBAG3C,MAAM,EAAE,MAAM;IAI1B,SAAS,CAAC,MAAM,EAAE,iBAAiB,GAAG,WAAW;IAe3C,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;IAMzD,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,SAAM;IAMzE,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,UAAO;IAMrD,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,UAAO;IAMtE,iBAAiB,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM;IAMlF,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM;IAMzD,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM;;;;;;;;;;IAgB1C,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM;IAM3C,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAS7B"}
|
package/lib/adapter.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Adapter,
|
|
1
|
+
import { Adapter, } from 'zhin.js';
|
|
2
2
|
import { OneBot11WsClient } from './bot-ws-client.js';
|
|
3
3
|
import { OneBot11WsServer } from './bot-ws-server.js';
|
|
4
4
|
export class OneBot11Adapter extends Adapter {
|
|
@@ -83,38 +83,8 @@ export class OneBot11Adapter extends Adapter {
|
|
|
83
83
|
this.plugin.useContext('router', (router) => {
|
|
84
84
|
this.#router = router;
|
|
85
85
|
});
|
|
86
|
-
this.registerOneBot11PlatformTools();
|
|
87
|
-
const groupTools = createGroupManagementTools(this, this.name);
|
|
88
|
-
groupTools.forEach((t) => this.addTool(t));
|
|
89
86
|
await super.start();
|
|
90
87
|
this.plugin.logger.info('OneBot11 适配器已启动');
|
|
91
88
|
}
|
|
92
|
-
registerOneBot11PlatformTools() {
|
|
93
|
-
this.addTool({
|
|
94
|
-
name: 'onebot11_set_title',
|
|
95
|
-
description: '设置群成员的专属头衔(需要群主权限)',
|
|
96
|
-
parameters: {
|
|
97
|
-
type: 'object',
|
|
98
|
-
properties: {
|
|
99
|
-
bot: { type: 'string', description: 'Bot 名称' },
|
|
100
|
-
group_id: { type: 'number', description: '群号' },
|
|
101
|
-
user_id: { type: 'number', description: '成员 QQ 号' },
|
|
102
|
-
title: { type: 'string', description: '头衔名称' },
|
|
103
|
-
},
|
|
104
|
-
required: ['bot', 'group_id', 'user_id', 'title'],
|
|
105
|
-
},
|
|
106
|
-
platforms: ['onebot11'],
|
|
107
|
-
scopes: ['group'],
|
|
108
|
-
permissionLevel: 'group_owner',
|
|
109
|
-
execute: async (args) => {
|
|
110
|
-
const { bot: botId, group_id, user_id, title } = args;
|
|
111
|
-
const bot = this.bots.get(botId);
|
|
112
|
-
if (!bot)
|
|
113
|
-
throw new Error(`Bot ${botId} 不存在`);
|
|
114
|
-
const success = await bot.setTitle(group_id, user_id, title);
|
|
115
|
-
return { success, message: success ? `已将 ${user_id} 的头衔设为 "${title}"` : '操作失败' };
|
|
116
|
-
},
|
|
117
|
-
});
|
|
118
|
-
}
|
|
119
89
|
}
|
|
120
90
|
//# sourceMappingURL=adapter.js.map
|
package/lib/adapter.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"adapter.js","sourceRoot":"","sources":["../src/adapter.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,OAAO,
|
|
1
|
+
{"version":3,"file":"adapter.js","sourceRoot":"","sources":["../src/adapter.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,OAAO,GAER,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAStD,MAAM,OAAO,eAAgB,SAAQ,OAAoB;IACvD,OAAO,CAAU;IAEjB,YAAY,MAAc;QACxB,KAAK,CAAC,MAAM,EAAE,UAAU,EAAE,EAAE,CAAC,CAAC;IAChC,CAAC;IAED,SAAS,CAAC,MAAyB;QACjC,MAAM,UAAU,GAAG,MAAM,CAAC,UAAU,IAAI,CAAE,MAA4B,CAAC,IAAI,KAAK,YAAY,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;QAC7G,QAAQ,UAAU,EAAE,CAAC;YACnB,KAAK,IAAI;gBACP,OAAO,IAAI,gBAAgB,CAAC,IAAI,EAAE,MAAgC,CAAC,CAAC;YACtE,KAAK,KAA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,MAAM,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;IAC7C,CAAC;CAEF"}
|
package/lib/index.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* OneBot11 适配器入口:单一适配器,支持正向 WS / 反向 WS(connection: ws | wss)
|
|
3
3
|
*/
|
|
4
|
-
import { usePlugin } from 'zhin.js';
|
|
4
|
+
import { usePlugin, createGroupManagementTools } from 'zhin.js';
|
|
5
5
|
import { OneBot11Adapter } from './adapter.js';
|
|
6
6
|
export * from './types.js';
|
|
7
7
|
export { OneBot11WsClient } from './bot-ws-client.js';
|
|
8
8
|
export { OneBot11WsServer } from './bot-ws-server.js';
|
|
9
9
|
export { OneBot11Adapter } from './adapter.js';
|
|
10
|
-
const { provide } = usePlugin();
|
|
10
|
+
const { provide, useContext } = usePlugin();
|
|
11
11
|
provide({
|
|
12
12
|
name: 'onebot11',
|
|
13
13
|
description: 'OneBot11 协议适配器(正向 WS / 反向 WS)',
|
|
@@ -20,4 +20,33 @@ provide({
|
|
|
20
20
|
await adapter.stop();
|
|
21
21
|
},
|
|
22
22
|
});
|
|
23
|
+
useContext('tool', 'onebot11', (toolService, onebot11) => {
|
|
24
|
+
const groupTools = createGroupManagementTools(onebot11, 'onebot11');
|
|
25
|
+
const disposers = groupTools.map(t => toolService.addTool(t, 'onebot11'));
|
|
26
|
+
// Platform-specific tool: set title
|
|
27
|
+
disposers.push(toolService.addTool({
|
|
28
|
+
name: 'onebot11_set_title',
|
|
29
|
+
description: '设置 QQ 群成员的专属头衔。只有群主才能设置。',
|
|
30
|
+
parameters: {
|
|
31
|
+
type: 'object',
|
|
32
|
+
properties: {
|
|
33
|
+
bot: { type: 'string', description: 'Bot 名称' },
|
|
34
|
+
group_id: { type: 'number', description: '目标群号' },
|
|
35
|
+
user_id: { type: 'number', description: '目标成员 QQ号' },
|
|
36
|
+
title: { type: 'string', description: '头衔文字' },
|
|
37
|
+
},
|
|
38
|
+
required: ['bot', 'group_id', 'user_id', 'title'],
|
|
39
|
+
},
|
|
40
|
+
platforms: ['onebot11'],
|
|
41
|
+
tags: ['onebot11'],
|
|
42
|
+
execute: async (args) => {
|
|
43
|
+
const bot = onebot11.bots.get(args.bot);
|
|
44
|
+
if (!bot)
|
|
45
|
+
throw new Error(`Bot ${args.bot} 不存在`);
|
|
46
|
+
const success = await bot.setTitle(args.group_id, args.user_id, args.title);
|
|
47
|
+
return { success, message: success ? `已将 ${args.user_id} 的头衔设为 "${args.title}"` : '设置失败' };
|
|
48
|
+
},
|
|
49
|
+
}, 'onebot11'));
|
|
50
|
+
return () => disposers.forEach(d => d());
|
|
51
|
+
});
|
|
23
52
|
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,SAAS,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,SAAS,EAAoD,0BAA0B,EAAoB,MAAM,SAAS,CAAC;AAEpI,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAE/C,cAAc,YAAY,CAAC;AAC3B,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,eAAe,EAAoB,MAAM,cAAc,CAAC;AAajE,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,GAAG,SAAS,EAAE,CAAC;AAC5C,OAAO,CAAC;IACN,IAAI,EAAE,UAAU;IAChB,WAAW,EAAE,+BAA+B;IAC5C,OAAO,EAAE,KAAK,EAAE,CAAS,EAAE,EAAE;QAC3B,MAAM,OAAO,GAAG,IAAI,eAAe,CAAC,CAAC,CAAC,CAAC;QACvC,MAAM,OAAO,C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,CAAC,CAAC;YACxC,IAAI,CAAC,GAAG;gBAAE,MAAM,IAAI,KAAK,CAAC,OAAO,IAAI,CAAC,GAAG,MAAM,CAAC,CAAC;YACjD,MAAM,OAAO,GAAG,MAAM,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;YAC5E,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,MAAM,IAAI,CAAC,OAAO,WAAW,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;QAC7F,CAAC;KACF,EAAE,UAAU,CAAC,CAAC,CAAC;IAEhB,OAAO,GAAG,EAAE,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;AAC3C,CAAC,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zhin.js/adapter-onebot11",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.66",
|
|
4
4
|
"description": "Zhin.js adapter for OneBot v11 protocol",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./lib/index.js",
|
|
@@ -48,12 +48,12 @@
|
|
|
48
48
|
"devDependencies": {
|
|
49
49
|
"@types/node": "^24.3.0",
|
|
50
50
|
"@types/ws": "^8.18.1",
|
|
51
|
-
"typescript": "^5.3
|
|
52
|
-
"zhin.js": "1.0.
|
|
51
|
+
"typescript": "^5.9.3",
|
|
52
|
+
"zhin.js": "1.0.60"
|
|
53
53
|
},
|
|
54
54
|
"peerDependencies": {
|
|
55
|
-
"zhin.js": "1.0.
|
|
56
|
-
"@zhin.js/http": "1.0.
|
|
55
|
+
"zhin.js": "1.0.60",
|
|
56
|
+
"@zhin.js/http": "1.0.55"
|
|
57
57
|
},
|
|
58
58
|
"peerDependenciesMeta": {
|
|
59
59
|
"@zhin.js/http": {
|
package/skills/onebot11/SKILL.md
CHANGED
|
@@ -1,18 +1,57 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: onebot11
|
|
3
|
-
|
|
3
|
+
platforms:
|
|
4
|
+
- onebot11
|
|
5
|
+
description: OneBot11 协议群管理:踢人、禁言、全员禁言、设管理员、改昵称/群名、头衔、查成员/群信息。仅有昵称时请先 list_members 获取 user_id。
|
|
4
6
|
keywords:
|
|
5
7
|
- onebot
|
|
6
8
|
- onebot11
|
|
7
9
|
- adapter:onebot11
|
|
8
10
|
- 群管理
|
|
11
|
+
- 头衔
|
|
9
12
|
- list_members
|
|
10
13
|
tags:
|
|
11
14
|
- group
|
|
12
15
|
- management
|
|
13
|
-
|
|
16
|
+
- im
|
|
17
|
+
tools:
|
|
18
|
+
# 平台特有工具
|
|
19
|
+
- onebot11_set_title
|
|
20
|
+
# 通用群管工具
|
|
21
|
+
- onebot11_kick_member
|
|
22
|
+
- onebot11_mute_member
|
|
23
|
+
- onebot11_mute_all
|
|
24
|
+
- onebot11_set_admin
|
|
25
|
+
- onebot11_set_nickname
|
|
26
|
+
- onebot11_set_group_name
|
|
27
|
+
- onebot11_list_members
|
|
28
|
+
- onebot11_get_group_info
|
|
14
29
|
---
|
|
15
30
|
|
|
31
|
+
## 工具概览
|
|
32
|
+
|
|
33
|
+
### 平台特有
|
|
34
|
+
|
|
35
|
+
| 工具 | 说明 | 权限 |
|
|
36
|
+
|------|------|------|
|
|
37
|
+
| `onebot11_set_title` | 设置群头衔 | group_owner |
|
|
38
|
+
|
|
39
|
+
### 通用群管
|
|
40
|
+
|
|
41
|
+
| 工具 | 说明 | 权限 |
|
|
42
|
+
|------|------|------|
|
|
43
|
+
| `onebot11_kick_member` | 踢出成员 | group_admin |
|
|
44
|
+
| `onebot11_mute_member` | 禁言成员(duration=0 解除) | group_admin |
|
|
45
|
+
| `onebot11_mute_all` | 全员禁言/解除 | group_admin |
|
|
46
|
+
| `onebot11_set_admin` | 设置/取消管理员 | group_owner |
|
|
47
|
+
| `onebot11_set_nickname` | 修改群昵称/名片 | group_admin |
|
|
48
|
+
| `onebot11_set_group_name` | 修改群名称 | group_admin |
|
|
49
|
+
| `onebot11_list_members` | 获取群成员列表 | user |
|
|
50
|
+
| `onebot11_get_group_info` | 获取群信息 | user |
|
|
51
|
+
|
|
16
52
|
## 执行规则
|
|
17
53
|
|
|
18
|
-
|
|
54
|
+
1. 仅有昵称时先 `onebot11_list_members` 获取用户 QQ 号
|
|
55
|
+
2. 禁言 duration 单位为秒,默认 600(10 分钟),设为 0 解除
|
|
56
|
+
3. 头衔设置需要群主权限
|
|
57
|
+
4. OneBot11 与 ICQQ 功能类似,但底层协议不同
|
package/src/adapter.ts
CHANGED
|
@@ -5,8 +5,6 @@ import type { Router } from '@zhin.js/http';
|
|
|
5
5
|
import {
|
|
6
6
|
Adapter,
|
|
7
7
|
Plugin,
|
|
8
|
-
createGroupManagementTools,
|
|
9
|
-
type IGroupManagement,
|
|
10
8
|
} from 'zhin.js';
|
|
11
9
|
import { OneBot11WsClient } from './bot-ws-client.js';
|
|
12
10
|
import { OneBot11WsServer } from './bot-ws-server.js';
|
|
@@ -103,37 +101,8 @@ export class OneBot11Adapter extends Adapter<OneBot11Bot> {
|
|
|
103
101
|
(this.plugin.useContext as (key: string, fn: (router: Router) => void) => void)('router', (router: Router) => {
|
|
104
102
|
this.#router = router;
|
|
105
103
|
});
|
|
106
|
-
this.registerOneBot11PlatformTools();
|
|
107
|
-
const groupTools = createGroupManagementTools(this as unknown as IGroupManagement, this.name);
|
|
108
|
-
groupTools.forEach((t) => this.addTool(t));
|
|
109
104
|
await super.start();
|
|
110
105
|
this.plugin.logger.info('OneBot11 适配器已启动');
|
|
111
106
|
}
|
|
112
107
|
|
|
113
|
-
private registerOneBot11PlatformTools(): void {
|
|
114
|
-
this.addTool({
|
|
115
|
-
name: 'onebot11_set_title',
|
|
116
|
-
description: '设置群成员的专属头衔(需要群主权限)',
|
|
117
|
-
parameters: {
|
|
118
|
-
type: 'object',
|
|
119
|
-
properties: {
|
|
120
|
-
bot: { type: 'string', description: 'Bot 名称' },
|
|
121
|
-
group_id: { type: 'number', description: '群号' },
|
|
122
|
-
user_id: { type: 'number', description: '成员 QQ 号' },
|
|
123
|
-
title: { type: 'string', description: '头衔名称' },
|
|
124
|
-
},
|
|
125
|
-
required: ['bot', 'group_id', 'user_id', 'title'],
|
|
126
|
-
},
|
|
127
|
-
platforms: ['onebot11'],
|
|
128
|
-
scopes: ['group'],
|
|
129
|
-
permissionLevel: 'group_owner',
|
|
130
|
-
execute: async (args) => {
|
|
131
|
-
const { bot: botId, group_id, user_id, title } = args;
|
|
132
|
-
const bot = this.bots.get(botId);
|
|
133
|
-
if (!bot) throw new Error(`Bot ${botId} 不存在`);
|
|
134
|
-
const success = await bot.setTitle(group_id, user_id, title);
|
|
135
|
-
return { success, message: success ? `已将 ${user_id} 的头衔设为 "${title}"` : '操作失败' };
|
|
136
|
-
},
|
|
137
|
-
});
|
|
138
|
-
}
|
|
139
108
|
}
|
package/src/index.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* OneBot11 适配器入口:单一适配器,支持正向 WS / 反向 WS(connection: ws | wss)
|
|
3
3
|
*/
|
|
4
|
-
import { usePlugin, type Plugin, type Context } from 'zhin.js';
|
|
4
|
+
import { usePlugin, type Plugin, type Context, type IGroupManagement, createGroupManagementTools, type ToolFeature } from 'zhin.js';
|
|
5
5
|
import type { Router } from '@zhin.js/http';
|
|
6
6
|
import { OneBot11Adapter } from './adapter.js';
|
|
7
7
|
|
|
@@ -21,7 +21,7 @@ declare module 'zhin.js' {
|
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
const { provide } = usePlugin();
|
|
24
|
+
const { provide, useContext } = usePlugin();
|
|
25
25
|
provide({
|
|
26
26
|
name: 'onebot11',
|
|
27
27
|
description: 'OneBot11 协议适配器(正向 WS / 反向 WS)',
|
|
@@ -34,3 +34,37 @@ provide({
|
|
|
34
34
|
await adapter.stop();
|
|
35
35
|
},
|
|
36
36
|
} as unknown as Context<'onebot11'>);
|
|
37
|
+
|
|
38
|
+
useContext('tool', 'onebot11', (toolService: ToolFeature, onebot11: OneBot11Adapter) => {
|
|
39
|
+
const groupTools = createGroupManagementTools(
|
|
40
|
+
onebot11 as unknown as IGroupManagement,
|
|
41
|
+
'onebot11',
|
|
42
|
+
);
|
|
43
|
+
const disposers: (() => void)[] = groupTools.map(t => toolService.addTool(t, 'onebot11'));
|
|
44
|
+
|
|
45
|
+
// Platform-specific tool: set title
|
|
46
|
+
disposers.push(toolService.addTool({
|
|
47
|
+
name: 'onebot11_set_title',
|
|
48
|
+
description: '设置 QQ 群成员的专属头衔。只有群主才能设置。',
|
|
49
|
+
parameters: {
|
|
50
|
+
type: 'object',
|
|
51
|
+
properties: {
|
|
52
|
+
bot: { type: 'string', description: 'Bot 名称' },
|
|
53
|
+
group_id: { type: 'number', description: '目标群号' },
|
|
54
|
+
user_id: { type: 'number', description: '目标成员 QQ号' },
|
|
55
|
+
title: { type: 'string', description: '头衔文字' },
|
|
56
|
+
},
|
|
57
|
+
required: ['bot', 'group_id', 'user_id', 'title'],
|
|
58
|
+
},
|
|
59
|
+
platforms: ['onebot11'],
|
|
60
|
+
tags: ['onebot11'],
|
|
61
|
+
execute: async (args: Record<string, any>) => {
|
|
62
|
+
const bot = onebot11.bots.get(args.bot);
|
|
63
|
+
if (!bot) throw new Error(`Bot ${args.bot} 不存在`);
|
|
64
|
+
const success = await bot.setTitle(args.group_id, args.user_id, args.title);
|
|
65
|
+
return { success, message: success ? `已将 ${args.user_id} 的头衔设为 "${args.title}"` : '设置失败' };
|
|
66
|
+
},
|
|
67
|
+
}, 'onebot11'));
|
|
68
|
+
|
|
69
|
+
return () => disposers.forEach(d => d());
|
|
70
|
+
});
|