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.
- package/commands/notice.ts +2 -2
- package/index.ts +19 -4
- package/notify/welcome.ts +2 -2
- package/package.json +1 -1
- package/skills/personal.ts +1 -1
- package/verify/index.ts +6 -6
- package/skills.ts +0 -7
package/commands/notice.ts
CHANGED
|
@@ -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.
|
|
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
|
|
3
|
-
|
|
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.
|
|
29
|
-
const aiService = ctx.
|
|
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"
|
|
264
|
-
async (event
|
|
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
package/skills/personal.ts
CHANGED
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"
|
|
315
|
-
async (event
|
|
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"
|
|
326
|
-
async (event
|
|
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"
|
|
337
|
-
async (event
|
|
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);
|