mioku-plugin-admin 1.0.0 → 2.0.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/commands/group.ts +45 -8
- package/commands/notice.ts +6 -1
- package/index.ts +2 -2
- package/package.json +13 -2
- package/skills/group.ts +1 -1
- package/skills/personal.ts +1 -1
- package/skills.ts +1 -1
package/commands/group.ts
CHANGED
|
@@ -25,8 +25,12 @@ export function registerGroupAdminCommands(ctx: MiokiContext) {
|
|
|
25
25
|
"我要头衔",
|
|
26
26
|
"踢",
|
|
27
27
|
"/踢",
|
|
28
|
+
"禁",
|
|
29
|
+
"/禁",
|
|
28
30
|
"禁言",
|
|
29
31
|
"/禁言",
|
|
32
|
+
"解",
|
|
33
|
+
"/解",
|
|
30
34
|
"解禁",
|
|
31
35
|
"/解禁",
|
|
32
36
|
"设管理",
|
|
@@ -126,11 +130,14 @@ export function registerGroupAdminCommands(ctx: MiokiContext) {
|
|
|
126
130
|
let targetUser: number | undefined = atUser;
|
|
127
131
|
let title: string;
|
|
128
132
|
|
|
133
|
+
const isSlashCommand = text.startsWith("/");
|
|
134
|
+
|
|
129
135
|
if (atUser) {
|
|
130
136
|
title = rest.replace(/@\d+\s*/, "").trim();
|
|
131
137
|
} else {
|
|
132
138
|
const parts = rest.split(/\s+/);
|
|
133
139
|
if (parts.length < 2) {
|
|
140
|
+
if (!isSlashCommand) return;
|
|
134
141
|
await replyAdminErrorNotice({
|
|
135
142
|
ctx,
|
|
136
143
|
event,
|
|
@@ -145,6 +152,7 @@ export function registerGroupAdminCommands(ctx: MiokiContext) {
|
|
|
145
152
|
}
|
|
146
153
|
|
|
147
154
|
if (!targetUser || !title) {
|
|
155
|
+
if (!isSlashCommand) return;
|
|
148
156
|
await replyAdminErrorNotice({
|
|
149
157
|
ctx,
|
|
150
158
|
event,
|
|
@@ -174,6 +182,11 @@ export function registerGroupAdminCommands(ctx: MiokiContext) {
|
|
|
174
182
|
if (text.startsWith("踢") || text.startsWith("/踢")) {
|
|
175
183
|
if (!(await ensureAdminPermission())) return;
|
|
176
184
|
const atUser = getAtUserId(event.message);
|
|
185
|
+
|
|
186
|
+
const isSlashCommand = text.startsWith("/");
|
|
187
|
+
if (!atUser && !isSlashCommand) {
|
|
188
|
+
return;
|
|
189
|
+
}
|
|
177
190
|
if (!atUser) {
|
|
178
191
|
await replyAdminErrorNotice({
|
|
179
192
|
ctx,
|
|
@@ -204,13 +217,23 @@ export function registerGroupAdminCommands(ctx: MiokiContext) {
|
|
|
204
217
|
}
|
|
205
218
|
|
|
206
219
|
if (
|
|
207
|
-
text
|
|
208
|
-
text
|
|
209
|
-
text
|
|
210
|
-
text
|
|
220
|
+
text === "禁" ||
|
|
221
|
+
text === "/禁" ||
|
|
222
|
+
text === "禁言" ||
|
|
223
|
+
text === "/禁言" ||
|
|
224
|
+
text.startsWith("禁 ") ||
|
|
225
|
+
text.startsWith("/禁 ") ||
|
|
226
|
+
text.startsWith("禁言 ") ||
|
|
227
|
+
text.startsWith("/禁言 ")
|
|
211
228
|
) {
|
|
212
229
|
if (!(await ensureAdminPermission())) return;
|
|
213
230
|
const atUser = getAtUserId(event.message);
|
|
231
|
+
|
|
232
|
+
// 不带 / 的命令必须有@才触发,否则静默忽略
|
|
233
|
+
const isSlashCommand = text.startsWith("/");
|
|
234
|
+
if (!atUser && !isSlashCommand) {
|
|
235
|
+
return; // 静默忽略,不走 chat runtime
|
|
236
|
+
}
|
|
214
237
|
if (!atUser) {
|
|
215
238
|
await replyAdminErrorNotice({
|
|
216
239
|
ctx,
|
|
@@ -241,13 +264,22 @@ export function registerGroupAdminCommands(ctx: MiokiContext) {
|
|
|
241
264
|
}
|
|
242
265
|
|
|
243
266
|
if (
|
|
244
|
-
text
|
|
245
|
-
text
|
|
246
|
-
text
|
|
247
|
-
text
|
|
267
|
+
text === "解" ||
|
|
268
|
+
text === "/解" ||
|
|
269
|
+
text === "解禁" ||
|
|
270
|
+
text === "/解禁" ||
|
|
271
|
+
text.startsWith("解 ") ||
|
|
272
|
+
text.startsWith("/解 ") ||
|
|
273
|
+
text.startsWith("解禁 ") ||
|
|
274
|
+
text.startsWith("/解禁 ")
|
|
248
275
|
) {
|
|
249
276
|
if (!(await ensureAdminPermission())) return;
|
|
250
277
|
const atUser = getAtUserId(event.message);
|
|
278
|
+
|
|
279
|
+
const isSlashCommand = text.startsWith("/");
|
|
280
|
+
if (!atUser && !isSlashCommand) {
|
|
281
|
+
return; // 静默忽略,不走 chat runtime
|
|
282
|
+
}
|
|
251
283
|
if (!atUser) {
|
|
252
284
|
await replyAdminErrorNotice({
|
|
253
285
|
ctx,
|
|
@@ -276,6 +308,11 @@ export function registerGroupAdminCommands(ctx: MiokiContext) {
|
|
|
276
308
|
if (text.startsWith("设管理") || text.startsWith("/设管理")) {
|
|
277
309
|
if (!(await ensureAdminPermission())) return;
|
|
278
310
|
const atUser = getAtUserId(event.message);
|
|
311
|
+
|
|
312
|
+
const isSlashCommand = text.startsWith("/");
|
|
313
|
+
if (!atUser && !isSlashCommand) {
|
|
314
|
+
return;
|
|
315
|
+
}
|
|
279
316
|
if (!atUser) {
|
|
280
317
|
await replyAdminErrorNotice({
|
|
281
318
|
ctx,
|
package/commands/notice.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AIService } from "
|
|
1
|
+
import type { AIService } from "mioku";
|
|
2
2
|
import type { MiokiContext } from "mioki";
|
|
3
3
|
|
|
4
4
|
function normalizeErrorMessage(error: unknown): string {
|
|
@@ -22,6 +22,11 @@ export async function replyAdminErrorNotice(options: {
|
|
|
22
22
|
fallbackMessage: string;
|
|
23
23
|
error?: unknown;
|
|
24
24
|
}): Promise<void> {
|
|
25
|
+
const text = options.ctx.text(options.event)?.trim() ?? "";
|
|
26
|
+
const hasSlashPrefix = text.startsWith("/");
|
|
27
|
+
if (!hasSlashPrefix) {
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
25
30
|
if (options.error != null) {
|
|
26
31
|
options.ctx.logger.error(
|
|
27
32
|
`[admin] ${options.instruction}\n执行错误: ${normalizeErrorMessage(options.error)}`,
|
package/index.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { definePlugin, type MiokiContext } from "mioki";
|
|
2
|
-
import type { ConfigService } from "
|
|
3
|
-
import { setPluginRuntimeState, resetPluginRuntimeState } from "
|
|
2
|
+
import type { ConfigService } from "mioku";
|
|
3
|
+
import { setPluginRuntimeState, resetPluginRuntimeState } from "mioku";
|
|
4
4
|
import { DEFAULT_CONFIG, normalizeConfig } from "./config";
|
|
5
5
|
import type { AdminConfig } from "./config";
|
|
6
6
|
import { registerNotificationHandlers } from "./notify";
|
package/package.json
CHANGED
|
@@ -1,13 +1,24 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mioku-plugin-admin",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "管理插件,提供事件通知与群管/个人管理指令",
|
|
5
5
|
"main": "index.ts",
|
|
6
|
-
"
|
|
6
|
+
"type": "module",
|
|
7
|
+
"keywords": [
|
|
8
|
+
"mioku"
|
|
9
|
+
],
|
|
7
10
|
"repository": {
|
|
8
11
|
"type": "git",
|
|
9
12
|
"url": "https://github.com/mioku-lab/mioku-plugin-admin.git"
|
|
10
13
|
},
|
|
14
|
+
"peerDependencies": {
|
|
15
|
+
"mioku": "^0.8.0",
|
|
16
|
+
"mioki": "^0.16.0"
|
|
17
|
+
},
|
|
18
|
+
"devDependencies": {
|
|
19
|
+
"mioku": "workspace:*",
|
|
20
|
+
"mioki": "^0.16.0"
|
|
21
|
+
},
|
|
11
22
|
"mioku": {
|
|
12
23
|
"services": [
|
|
13
24
|
"config",
|
package/skills/group.ts
CHANGED
package/skills/personal.ts
CHANGED
package/skills.ts
CHANGED