mioku-plugin-mc 3.0.1 → 4.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/index.ts +6 -6
- package/package.json +3 -5
- package/play/actions/registry.ts +1 -1
- package/play/context.ts +2 -2
- package/play/index.ts +3 -3
- package/play/missions/registry.ts +1 -1
- package/play/session.ts +2 -2
package/index.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { definePlugin, type
|
|
1
|
+
import { definePlugin, type MiokuContext } from "mioku";
|
|
2
2
|
import { getService, Services } from "mioku";
|
|
3
3
|
import { createConfigHandler } from "./utils/config-handler";
|
|
4
4
|
import { createPlayConfigHandler } from "./play/config";
|
|
@@ -24,7 +24,7 @@ export default definePlugin({
|
|
|
24
24
|
version: "1.0.0",
|
|
25
25
|
description: "Minecraft服务器与QQ群消息互通插件",
|
|
26
26
|
|
|
27
|
-
async setup(ctx:
|
|
27
|
+
async setup(ctx: MiokuContext) {
|
|
28
28
|
const configService = getService(ctx, Services.Config);
|
|
29
29
|
|
|
30
30
|
const configHandler = createConfigHandler(configService);
|
|
@@ -153,7 +153,7 @@ export default definePlugin({
|
|
|
153
153
|
});
|
|
154
154
|
|
|
155
155
|
async function handleMcEvent(
|
|
156
|
-
ctx:
|
|
156
|
+
ctx: MiokuContext,
|
|
157
157
|
event: McEvent,
|
|
158
158
|
config: McConfig,
|
|
159
159
|
configHandler: ReturnType<typeof createConfigHandler>,
|
|
@@ -174,12 +174,12 @@ async function handleMcEvent(
|
|
|
174
174
|
const groups = groupList ? [groupList] : [];
|
|
175
175
|
|
|
176
176
|
for (const botId of bots) {
|
|
177
|
-
const bot = ctx.pickBot(
|
|
177
|
+
const bot = ctx.pickBot(botId);
|
|
178
178
|
if (!bot) continue;
|
|
179
179
|
|
|
180
180
|
for (const groupId of groups) {
|
|
181
181
|
try {
|
|
182
|
-
await bot.
|
|
182
|
+
await bot.sendMessage({ type: "group", group_id: groupId}, messageText);
|
|
183
183
|
} catch (err) {
|
|
184
184
|
ctx.logger.error(`[MC] 发送消息到群 ${groupId} 失败: ${err}`);
|
|
185
185
|
}
|
|
@@ -188,7 +188,7 @@ async function handleMcEvent(
|
|
|
188
188
|
}
|
|
189
189
|
|
|
190
190
|
async function forwardToMc(
|
|
191
|
-
ctx:
|
|
191
|
+
ctx: MiokuContext,
|
|
192
192
|
event: any,
|
|
193
193
|
config: McConfig,
|
|
194
194
|
configHandler: ReturnType<typeof createConfigHandler>,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mioku-plugin-mc",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0",
|
|
4
4
|
"description": "Minecraft与QQ群消息互通插件,支持服务器状态监控与RCON命令",
|
|
5
5
|
"main": "index.ts",
|
|
6
6
|
"type": "module",
|
|
@@ -71,11 +71,9 @@
|
|
|
71
71
|
"zod": "^3.24.1"
|
|
72
72
|
},
|
|
73
73
|
"peerDependencies": {
|
|
74
|
-
"mioku": "^0.
|
|
75
|
-
"mioki": "^0.16.0"
|
|
74
|
+
"mioku": "^1.0.0"
|
|
76
75
|
},
|
|
77
76
|
"devDependencies": {
|
|
78
|
-
"mioku": "workspace:*"
|
|
79
|
-
"mioki": "^0.16.0"
|
|
77
|
+
"mioku": "workspace:*"
|
|
80
78
|
}
|
|
81
79
|
}
|
package/play/actions/registry.ts
CHANGED
package/play/context.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { MiokuContext } from "mioku";
|
|
2
2
|
import type { AIService, AIInstance, ConfigService } from "mioku";
|
|
3
3
|
import type { PlayConfig } from "./types";
|
|
4
4
|
import type { ConfigHandler } from "../utils/config-handler";
|
|
@@ -6,7 +6,7 @@ import type { WorkSubroutine, WorkTerminator } from "./ai/work-subroutine";
|
|
|
6
6
|
import type { PlaySession } from "./session";
|
|
7
7
|
|
|
8
8
|
export interface PlayPluginContext {
|
|
9
|
-
ctx:
|
|
9
|
+
ctx: MiokuContext;
|
|
10
10
|
config: PlayConfig;
|
|
11
11
|
aiService: AIService | undefined;
|
|
12
12
|
configService: ConfigService | undefined;
|
package/play/index.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { MiokuContext } from "mioku";
|
|
2
2
|
import type { AIService, AIInstance, ConfigService } from "mioku";
|
|
3
3
|
import type { ConfigHandler } from "../utils/config-handler";
|
|
4
4
|
import type { PlayPluginContext } from "./context";
|
|
@@ -17,7 +17,7 @@ import { SelfDefenseBehavior } from "./behavior/catalog/defend";
|
|
|
17
17
|
import type { GroupBinding, PlayServerConfig } from "./types";
|
|
18
18
|
|
|
19
19
|
export interface PlayManagerOptions {
|
|
20
|
-
ctx:
|
|
20
|
+
ctx: MiokuContext;
|
|
21
21
|
aiService: AIService | undefined;
|
|
22
22
|
configService: ConfigService | undefined;
|
|
23
23
|
playConfigHandler: PlayConfigHandler;
|
|
@@ -36,7 +36,7 @@ export interface PlayExitResult {
|
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
export class PlayManager {
|
|
39
|
-
private readonly ctx:
|
|
39
|
+
private readonly ctx: MiokuContext;
|
|
40
40
|
private readonly aiService: AIService | undefined;
|
|
41
41
|
private readonly configService: ConfigService | undefined;
|
|
42
42
|
private readonly playConfigHandler: PlayConfigHandler;
|
package/play/session.ts
CHANGED
|
@@ -242,7 +242,7 @@ export class PlaySession {
|
|
|
242
242
|
const bot = ctx.ctx.pickBot(this.binding.botSelfId);
|
|
243
243
|
if (!bot) return;
|
|
244
244
|
try {
|
|
245
|
-
await bot.
|
|
245
|
+
await bot.sendMessage({ type: "group", group_id: this.binding.groupId}, message);
|
|
246
246
|
} catch (err) {
|
|
247
247
|
ctx.ctx.logger.error(`[MC/play] 发送 QQ 通知失败: ${err}`);
|
|
248
248
|
}
|
|
@@ -264,7 +264,7 @@ export class PlaySession {
|
|
|
264
264
|
const bot = ctx.ctx.pickBot(this.binding.botSelfId);
|
|
265
265
|
if (!bot) return false;
|
|
266
266
|
try {
|
|
267
|
-
await bot.
|
|
267
|
+
await bot.sendMessage({ type: "group", group_id: this.binding.groupId}, message);
|
|
268
268
|
return true;
|
|
269
269
|
} catch (err) {
|
|
270
270
|
ctx.ctx.logger.error(`[MC/play] 发送 QQ 消息失败: ${err}`);
|