koishi-plugin-ai-puzzle 0.1.2 → 0.1.4
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/lib/batch.d.ts +2 -0
- package/lib/game.d.ts +0 -1
- package/lib/index.js +10 -16
- package/package.json +1 -1
package/lib/batch.d.ts
CHANGED
|
@@ -21,6 +21,8 @@ export declare class BatchManager {
|
|
|
21
21
|
getPendingNames(channelId: string): string[];
|
|
22
22
|
consumeReserve(channelId: string): PuzzleData | null;
|
|
23
23
|
clearReserve(channelId: string): void;
|
|
24
|
+
/** 清除频道所有批量相关数据(切换模板时调用) */
|
|
25
|
+
clearAll(channelId: string): void;
|
|
24
26
|
batchGenerate(channelId: string, count: number, keyword: string, onProgress?: (msg: string) => void): Promise<{
|
|
25
27
|
names: string[];
|
|
26
28
|
puzzles: PuzzleData[];
|
package/lib/game.d.ts
CHANGED
package/lib/index.js
CHANGED
|
@@ -36,7 +36,7 @@ var require_package = __commonJS({
|
|
|
36
36
|
module2.exports = {
|
|
37
37
|
name: "koishi-plugin-ai-puzzle",
|
|
38
38
|
description: "使用AI生成猜谜谜题,支持多模式游戏、模糊匹配、图片渲染",
|
|
39
|
-
version: "0.1.
|
|
39
|
+
version: "0.1.4",
|
|
40
40
|
main: "lib/index.js",
|
|
41
41
|
typings: "lib/index.d.ts",
|
|
42
42
|
files: [
|
|
@@ -768,6 +768,12 @@ var BatchManager = class {
|
|
|
768
768
|
clearReserve(channelId) {
|
|
769
769
|
this.reservePool.delete(channelId);
|
|
770
770
|
}
|
|
771
|
+
/** 清除频道所有批量相关数据(切换模板时调用) */
|
|
772
|
+
clearAll(channelId) {
|
|
773
|
+
this.reservePool.delete(channelId);
|
|
774
|
+
this.batchStatus.delete(channelId);
|
|
775
|
+
this.pendingNames.delete(channelId);
|
|
776
|
+
}
|
|
771
777
|
async batchGenerate(channelId, count, keyword, onProgress) {
|
|
772
778
|
const send = /* @__PURE__ */ __name((msg) => {
|
|
773
779
|
if (onProgress) onProgress(msg);
|
|
@@ -1038,35 +1044,23 @@ var GameOrchestrator = class {
|
|
|
1038
1044
|
state.preGenerated = null;
|
|
1039
1045
|
this.stateManager.saveModeConfig(channelId).catch(() => {
|
|
1040
1046
|
});
|
|
1047
|
+
this.batchManager.clearAll(channelId);
|
|
1041
1048
|
this.logger.info("[Game] switchTemplate: channel=%s, 模板=%s", channelId, keyword);
|
|
1042
|
-
if (state.preMode) {
|
|
1043
|
-
this.preGenerate(channelId).catch((e) => {
|
|
1044
|
-
this.logger.error("switchTemplate preGenerate failed:", e);
|
|
1045
|
-
});
|
|
1046
|
-
}
|
|
1047
1049
|
return `已切换提示词模板为:${keyword}`;
|
|
1048
1050
|
}
|
|
1049
1051
|
/** 切换模式(通用) */
|
|
1050
1052
|
switchMode(session, modeUpdate) {
|
|
1051
1053
|
const channelId = session.channelId;
|
|
1052
|
-
|
|
1053
|
-
const isPreModeOnly = keys.length === 1 && keys[0] === "preMode";
|
|
1054
|
-
if (!isPreModeOnly && !this.stateManager.isIdle(channelId)) {
|
|
1054
|
+
if (!this.stateManager.isIdle(channelId)) {
|
|
1055
1055
|
return "当前有谜题进行中,无法切换模式。";
|
|
1056
1056
|
}
|
|
1057
1057
|
const state = this.stateManager.getSync(channelId);
|
|
1058
|
-
const hadPreMode = state.preMode;
|
|
1059
1058
|
Object.assign(state, modeUpdate);
|
|
1060
1059
|
this.stateManager.saveModeConfig(channelId).catch(() => {
|
|
1061
1060
|
});
|
|
1062
|
-
if (!hadPreMode && state.preMode) {
|
|
1063
|
-
this.preGenerate(channelId).catch((e) => {
|
|
1064
|
-
this.logger.error("switchMode preGenerate failed:", e);
|
|
1065
|
-
});
|
|
1066
|
-
}
|
|
1067
1061
|
const modeStr = state.manualMode ? "手动" : `自动(间隔${state.autoInterval}s, 额外延迟${state.autoExtraDelay}s)`;
|
|
1068
1062
|
const guessStr = state.openMode ? "开放" : `限制(每谜题${state.restrictPuzzle}次, 每条线索${state.restrictClue}次)`;
|
|
1069
|
-
return `模式已更新。当前频道配置:${modeStr} | ${guessStr}
|
|
1063
|
+
return `模式已更新。当前频道配置:${modeStr} | ${guessStr}`;
|
|
1070
1064
|
}
|
|
1071
1065
|
/** 插件启动时扫描 DB,为所有 preMode=true 的频道触发预生成 */
|
|
1072
1066
|
async startupPreGenerate() {
|