mioku-plugin-admin 2.3.4 → 2.3.5

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.
@@ -1,5 +1,5 @@
1
- import type { AIService } from "mioku";
2
1
  import type { MiokiContext } from "mioki";
2
+ import { getService, Services } from "mioku";
3
3
 
4
4
  function normalizeErrorMessage(error: unknown): string {
5
5
  if (error instanceof Error && error.message) {
@@ -33,7 +33,7 @@ export async function replyAdminErrorNotice(options: {
33
33
  );
34
34
  }
35
35
 
36
- const aiService = options.ctx.services?.ai as AIService | undefined;
36
+ const aiService = getService(options.ctx, Services.AI);
37
37
  const chatRuntime = aiService?.getChatRuntime();
38
38
  if (chatRuntime) {
39
39
  try {
package/index.ts CHANGED
@@ -1,6 +1,12 @@
1
1
  import { definePlugin, type MiokiContext } from "mioki";
2
- import type { AIService, ConfigService } from "mioku";
3
- import { setPluginRuntimeState, resetPluginRuntimeState } from "mioku";
2
+ import {
3
+ setPluginRuntimeState,
4
+ resetPluginRuntimeState,
5
+ getService,
6
+ Services,
7
+ } from "mioku";
8
+ import groupAdminSkill from "./skills/group";
9
+ import personalSkill from "./skills/personal";
4
10
  import { DEFAULT_CONFIG, normalizeConfig, type AdminConfig } from "./config";
5
11
  import {
6
12
  DEFAULT_VERIFY_CONFIG,
@@ -25,8 +31,8 @@ export default definePlugin({
25
31
  description: "管理插件,提供事件通知与群管/个人管理指令",
26
32
 
27
33
  async setup(ctx: MiokiContext) {
28
- const configService = ctx.services?.config as ConfigService | undefined;
29
- const aiService = ctx.services?.ai as AIService | undefined;
34
+ const configService = getService(ctx, Services.Config);
35
+ const aiService = getService(ctx, Services.AI);
30
36
 
31
37
  let config: AdminConfig = { ...DEFAULT_CONFIG };
32
38
  let verifyConfig: VerifyConfig = { ...DEFAULT_VERIFY_CONFIG };
@@ -53,6 +59,11 @@ export default definePlugin({
53
59
 
54
60
  setPluginRuntimeState("admin", { ctx });
55
61
 
62
+ if (aiService) {
63
+ aiService.registerSkill(groupAdminSkill);
64
+ aiService.registerSkill(personalSkill);
65
+ }
66
+
56
67
  const getConfig = () => config;
57
68
  const getVerifyConfig = () => verifyConfig;
58
69
  const getWelcomeEnabled = () => config.welcome.enabled;
@@ -101,6 +112,10 @@ export default definePlugin({
101
112
  return () => {
102
113
  disposeWelcome();
103
114
  verifyController.dispose();
115
+ if (aiService) {
116
+ aiService.removeSkill("admin_group");
117
+ aiService.removeSkill("admin_personal");
118
+ }
104
119
  resetPluginRuntimeState("admin");
105
120
  ctx.logger.info("管理插件已卸载");
106
121
  };
package/notify/welcome.ts CHANGED
@@ -260,8 +260,8 @@ export function registerWelcomeHandler(
260
260
  const batches = getBatchMap();
261
261
 
262
262
  const dispose = ctx.handle(
263
- "notice.group.increase" as any,
264
- async (event: any) => {
263
+ "notice.group.increase",
264
+ async (event) => {
265
265
  const cfg = getConfig();
266
266
  const selfId = Number(event?.self_id || ctx.self_id);
267
267
  const groupId = Number(event?.group_id || 0);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mioku-plugin-admin",
3
- "version": "2.3.4",
3
+ "version": "2.3.5",
4
4
  "description": "管理插件,提供事件通知与群管/个人管理指令",
5
5
  "main": "index.ts",
6
6
  "type": "module",
@@ -22,7 +22,7 @@ const personalSkill: AISkill = {
22
22
  name: "admin_personal",
23
23
  description:
24
24
  "Bot个人账号与消息管理统一入口:修改Bot资料、发送消息、获取列表、管理关系",
25
- permission: "owner",
25
+ permission: "master",
26
26
  tools: [
27
27
  {
28
28
  name: "manage_personal",
package/verify/index.ts CHANGED
@@ -311,8 +311,8 @@ export function createVerifyController(
311
311
  }
312
312
 
313
313
  const messageDispose = ctx.handle(
314
- "message.group" as any,
315
- async (event: any) => {
314
+ "message.group",
315
+ async (event) => {
316
316
  try {
317
317
  await onGroupMessage(event);
318
318
  } catch (err) {
@@ -322,8 +322,8 @@ export function createVerifyController(
322
322
  );
323
323
 
324
324
  const reactionDispose = ctx.handle(
325
- "notice.group.reaction" as any,
326
- async (event: any) => {
325
+ "notice.group.reaction",
326
+ async (event) => {
327
327
  try {
328
328
  await onGroupReaction(event);
329
329
  } catch (err) {
@@ -333,8 +333,8 @@ export function createVerifyController(
333
333
  );
334
334
 
335
335
  const decreaseDispose = ctx.handle(
336
- "notice.group.decrease" as any,
337
- async (event: any) => {
336
+ "notice.group.decrease",
337
+ async (event) => {
338
338
  const selfId = Number(event?.self_id || 0);
339
339
  const groupId = Number(event?.group_id || 0);
340
340
  const userId = Number(event?.user_id || 0);
package/skills.ts DELETED
@@ -1,7 +0,0 @@
1
- import type { AISkill } from "mioku";
2
- import groupAdminSkill from "./skills/group";
3
- import personalSkill from "./skills/personal";
4
-
5
- const adminSkills: AISkill[] = [groupAdminSkill, personalSkill];
6
-
7
- export default adminSkills;