koishi-plugin-cocoyyy-console 1.1.0-beta.6 → 1.1.0-beta.8

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.
Files changed (2) hide show
  1. package/lib/index.js +30 -13
  2. package/package.json +1 -1
package/lib/index.js CHANGED
@@ -2105,6 +2105,7 @@ async function startSituationPuzzle(config) {
2105
2105
  chatHistory2 = [];
2106
2106
  gameTimeout = null;
2107
2107
  }, GAME_TIMEOUT_MINUTES * 60 * 1e3);
2108
+ logger.info("[startSituationPuzzle Info]: ai api send message success");
2108
2109
  return resp;
2109
2110
  }
2110
2111
  __name(startSituationPuzzle, "startSituationPuzzle");
@@ -2123,6 +2124,7 @@ async function questSituationPuzzle(content, config) {
2123
2124
  logger.error("[questSituationPuzzle Error]: " + err);
2124
2125
  return null;
2125
2126
  }
2127
+ logger.info("[questSituationPuzzle Info]: ai api send message success");
2126
2128
  if (resp.includes("猜中了")) {
2127
2129
  is_gaming = false;
2128
2130
  chatPrompt = [];
@@ -2141,6 +2143,7 @@ async function endSituationPuzzle(config) {
2141
2143
  logger.error("[endSituationPuzzle Error]: " + err);
2142
2144
  return null;
2143
2145
  }
2146
+ logger.info("[endSituationPuzzle Info]: ai api send message success");
2144
2147
  return resp;
2145
2148
  }
2146
2149
  __name(endSituationPuzzle, "endSituationPuzzle");
@@ -2158,6 +2161,7 @@ async function rerollSituationPuzzle(config) {
2158
2161
  chatPrompt.push({ role: "system", content: [{ type: "text", text: prompt_start }] });
2159
2162
  chatPrompt.push({ role: "assistant", content: [{ type: "text", text: resp }] });
2160
2163
  is_gaming = true;
2164
+ logger.info("[rerollSituationPuzzle Info]: ai api send message success");
2161
2165
  return resp;
2162
2166
  }
2163
2167
  __name(rerollSituationPuzzle, "rerollSituationPuzzle");
@@ -2175,8 +2179,7 @@ var gameList = [
2175
2179
  var commandList = [
2176
2180
  "endgame",
2177
2181
  "gamelist",
2178
- "startgame",
2179
- "reroll"
2182
+ "startgame"
2180
2183
  ];
2181
2184
  function registerGameCommands(ctx, game_config, ai_config) {
2182
2185
  if (game_config?.config_path) {
@@ -2199,17 +2202,22 @@ function registerGameCommands(ctx, game_config, ai_config) {
2199
2202
  if (!dev_mode) {
2200
2203
  if (!is_at_bot(session)) return;
2201
2204
  }
2202
- if (is_gaming)
2203
- return "游戏正在进行中,请先结束游戏";
2205
+ if (is_gaming) return "游戏正在进行中,请先结束游戏";
2206
+ if (is_thinking) return "正在思考,请耐心等待...";
2204
2207
  const game = args?.[0];
2205
2208
  if (!game) return "请提供正确格式,如:@bot startgame [游戏]";
2206
- switch (game) {
2207
- case gameList[0].command:
2208
- await session.send("正在开始游戏...后续问答请参照格式:@bot [问题]");
2209
- const resp = await startSituationPuzzle(ai_config);
2210
- return checkResp(resp);
2211
- default:
2212
- return `游戏不存在,请输入gamelist查看所有游戏`;
2209
+ try {
2210
+ is_thinking = true;
2211
+ switch (game) {
2212
+ case gameList[0].command:
2213
+ await session.send("正在开始游戏...后续问答请参照格式:@bot [问题]\n需要刷新谜题时发送:@bot reroll");
2214
+ const resp = await startSituationPuzzle(ai_config);
2215
+ return checkResp(resp);
2216
+ default:
2217
+ return `游戏不存在,请输入gamelist查看所有游戏`;
2218
+ }
2219
+ } finally {
2220
+ is_thinking = false;
2213
2221
  }
2214
2222
  });
2215
2223
  ctx.command("endgame", "结束游戏").action(async ({ session }) => {
@@ -2252,8 +2260,17 @@ function registerGameMiddleware(ctx, ai_config) {
2252
2260
  commandList.forEach((element) => {
2253
2261
  if (text.includes(element)) return next();
2254
2262
  });
2255
- const resp = await questSituationPuzzle(text, ai_config);
2256
- return (0, import_koishi12.h)("at", { id: userId }) + " " + checkResp(resp);
2263
+ try {
2264
+ is_thinking = true;
2265
+ if (text.includes("reroll")) {
2266
+ const resp2 = await rerollSituationPuzzle(ai_config);
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
+ }
2257
2274
  });
2258
2275
  }
2259
2276
  __name(registerGameMiddleware, "registerGameMiddleware");
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.0-beta.6",
4
+ "version": "1.1.0-beta.8",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
7
7
  "contributors": [