koishi-plugin-cocoyyy-console 1.1.1-beta.1 → 1.1.2-beta.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/lib/index.js CHANGED
@@ -44,6 +44,7 @@ var import_koishi13 = require("koishi");
44
44
  var import_koishi = require("koishi");
45
45
  var FunctionConfigSchema = import_koishi.Schema.object({
46
46
  dev_mode: import_koishi.Schema.boolean().default(false).description("开发测试模式"),
47
+ reload_button: import_koishi.Schema.boolean().default(true).description("重载开关(用于重载无实际用途)"),
47
48
  tag_flag: import_koishi.Schema.boolean().default(true).description("标签功能是否启用"),
48
49
  repeat_flag: import_koishi.Schema.boolean().default(true).description("复读功能是否启用"),
49
50
  rbq_flag: import_koishi.Schema.boolean().default(true).description("*人功能是否启用"),
@@ -499,7 +500,7 @@ var gameFuncMenuList = [
499
500
  },
500
501
  {
501
502
  name: "endgame",
502
- description: "结束游戏",
503
+ description: "游戏进行时使用,结束游戏",
503
504
  command: "endgame"
504
505
  }
505
506
  ];
@@ -1583,7 +1584,7 @@ async function checkShitOrNot(session, parttern_msg, config) {
1583
1584
  logger.warn("[checkShitOrNot Warn]: 引用消息中未发现文本或图片");
1584
1585
  return "引用消息中未发现文本或图片";
1585
1586
  }
1586
- logger.info("[checkShitOrNot Info]: 提取图片 URL:\n" + imageUrls.join(",\n"));
1587
+ logger.info("[checkShitOrNot Info]: 提取图片 URL: " + imageUrls.join(", "));
1587
1588
  const targetContent = [
1588
1589
  ...text ? [{ type: "text", text }] : [],
1589
1590
  ...imageUrls.map((url) => ({ type: "image_url", image_url: { url } }))
@@ -2173,6 +2174,7 @@ __name(rerollSituationPuzzle, "rerollSituationPuzzle");
2173
2174
  // src/services/game_func/game_command.ts
2174
2175
  var local_config2 = null;
2175
2176
  var is_thinking = false;
2177
+ var now_game = null;
2176
2178
  var gameList = [
2177
2179
  {
2178
2180
  name: "AI海龟汤",
@@ -2181,7 +2183,6 @@ var gameList = [
2181
2183
  }
2182
2184
  ];
2183
2185
  var commandList = [
2184
- "endgame",
2185
2186
  "gamelist",
2186
2187
  "startgame"
2187
2188
  ];
@@ -2196,7 +2197,7 @@ function registerGameCommands(ctx, game_config, ai_config) {
2196
2197
  } else {
2197
2198
  logger.error("[loadYamlConfig Error]: 未配置 Game 配置文件路径");
2198
2199
  }
2199
- ctx.command("gamelist", "查看所有游戏").action(async ({ session }) => {
2200
+ ctx.command("gamelist", "查看所有游戏").action(async ({}) => {
2200
2201
  return `[所有命令都需要@bot]
2201
2202
  游戏列表:
2202
2203
  ${gameList.map((item) => item.command + ": " + item.name).join("\n ")}
@@ -2216,6 +2217,7 @@ function registerGameCommands(ctx, game_config, ai_config) {
2216
2217
  case gameList[0].command:
2217
2218
  await session.send("正在开始游戏...后续问答请参照格式:@bot [问题]\n需要刷新谜题时发送:@bot reroll");
2218
2219
  const resp = await startSituationPuzzle(ai_config);
2220
+ now_game = game;
2219
2221
  return checkResp(resp);
2220
2222
  default:
2221
2223
  return `游戏不存在,请输入gamelist查看所有游戏`;
@@ -2224,35 +2226,6 @@ function registerGameCommands(ctx, game_config, ai_config) {
2224
2226
  is_thinking = false;
2225
2227
  }
2226
2228
  });
2227
- ctx.command("endgame", "结束游戏").action(async ({ session }) => {
2228
- if (!dev_mode) {
2229
- if (!is_at_bot(session)) return;
2230
- }
2231
- if (!is_gaming) return "未开始游戏";
2232
- if (is_thinking) return "正在思考,请耐心等待...";
2233
- try {
2234
- is_thinking = true;
2235
- await session.send("正在结束游戏...");
2236
- const resp = await endSituationPuzzle(ai_config);
2237
- return checkResp(resp);
2238
- } finally {
2239
- is_thinking = false;
2240
- }
2241
- });
2242
- ctx.command("reroll", "重新生成新谜题").action(async ({ session }) => {
2243
- if (!dev_mode) {
2244
- if (!is_at_bot(session)) return;
2245
- }
2246
- if (!is_gaming) return "未开始游戏";
2247
- if (is_thinking) return "正在思考,请耐心等待...";
2248
- try {
2249
- is_thinking = true;
2250
- const resp = await rerollSituationPuzzle(ai_config);
2251
- return checkResp(resp);
2252
- } finally {
2253
- is_thinking = false;
2254
- }
2255
- });
2256
2229
  }
2257
2230
  __name(registerGameCommands, "registerGameCommands");
2258
2231
  function registerGameMiddleware(ctx, ai_config) {
@@ -2264,23 +2237,42 @@ function registerGameMiddleware(ctx, ai_config) {
2264
2237
  if (is_thinking) return "正在思考,请耐心等待...";
2265
2238
  const withoutTags = content.replace(/<[^>]+>/g, " ");
2266
2239
  const text = withoutTags.replace(/\s+/g, " ").trim();
2267
- commandList.forEach((element) => {
2268
- if (text.includes(element)) return next();
2269
- });
2270
- try {
2271
- is_thinking = true;
2272
- if (text.includes("reroll")) {
2273
- const resp2 = await rerollSituationPuzzle(ai_config);
2274
- return checkResp(resp2);
2275
- }
2276
- const resp = await questSituationPuzzle(text, ai_config);
2277
- return (0, import_koishi12.h)("at", { id: userId }) + " " + checkResp(resp);
2278
- } finally {
2279
- is_thinking = false;
2240
+ for (const command of commandList) {
2241
+ if (text.includes(command)) return "正在游戏中,请结束游戏后使用该命令";
2242
+ }
2243
+ switch (now_game) {
2244
+ case gameList[0].command:
2245
+ const resp = await situationPuzzleMiddleware(session, ai_config);
2246
+ return resp;
2247
+ default:
2248
+ return next();
2280
2249
  }
2281
2250
  });
2282
2251
  }
2283
2252
  __name(registerGameMiddleware, "registerGameMiddleware");
2253
+ async function situationPuzzleMiddleware(session, ai_config) {
2254
+ const { content, uid, userId } = session;
2255
+ const withoutTags = content.replace(/<[^>]+>/g, " ");
2256
+ const text = withoutTags.replace(/\s+/g, " ").trim();
2257
+ try {
2258
+ is_thinking = true;
2259
+ if (text.includes("reroll")) {
2260
+ const resp2 = await rerollSituationPuzzle(ai_config);
2261
+ return checkResp(resp2);
2262
+ }
2263
+ if (text.includes("endgame")) {
2264
+ await session.send("正在结束游戏...");
2265
+ const resp2 = await endSituationPuzzle(ai_config);
2266
+ now_game = null;
2267
+ return checkResp(resp2);
2268
+ }
2269
+ const resp = await questSituationPuzzle(text, ai_config);
2270
+ return (0, import_koishi12.h)("at", { id: userId }) + " " + checkResp(resp);
2271
+ } finally {
2272
+ is_thinking = false;
2273
+ }
2274
+ }
2275
+ __name(situationPuzzleMiddleware, "situationPuzzleMiddleware");
2284
2276
  function checkResp(resp) {
2285
2277
  if (!resp) {
2286
2278
  return "返回有误,请检查日志";
@@ -2,6 +2,7 @@ import { Context } from 'koishi';
2
2
  import { GameConfig } from '../../utils/configs/game_config';
3
3
  import { AiAPIConfig } from '../../utils/config';
4
4
  declare let local_config: any;
5
+ declare let now_game: any;
5
6
  declare function registerGameCommands(ctx: Context, game_config: GameConfig, ai_config: AiAPIConfig): void;
6
7
  declare function registerGameMiddleware(ctx: Context, ai_config: AiAPIConfig): void;
7
- export { local_config, registerGameCommands, registerGameMiddleware, };
8
+ export { local_config, now_game, registerGameCommands, registerGameMiddleware, };
@@ -1,6 +1,7 @@
1
1
  import { Schema } from 'koishi';
2
2
  interface FunctionConfig {
3
3
  dev_mode: boolean;
4
+ reload_button: boolean;
4
5
  tag_flag: boolean;
5
6
  repeat_flag: boolean;
6
7
  rbq_flag: boolean;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "koishi-plugin-cocoyyy-console",
3
3
  "description": "自用koishi插件,功能包含复读,记录黑历史,*人等",
4
- "version": "1.1.1-beta.1",
4
+ "version": "1.1.2-beta.0",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
7
7
  "contributors": [