koishi-plugin-cocoyyy-console 1.1.0-beta.3 → 1.1.0-beta.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/index.js CHANGED
@@ -1530,7 +1530,6 @@ async function callOpenRouter(api_url, api_key, api_model = "gpt-4o-mini", messa
1530
1530
  } else {
1531
1531
  err = "OpenRouter 返回了未知格式,请检查日志";
1532
1532
  }
1533
- logger.error("[callOpenRouter Info]: " + responseText + ", err: " + err);
1534
1533
  return { err, resp: responseText };
1535
1534
  } catch (error) {
1536
1535
  const err = error;
@@ -2078,17 +2077,13 @@ __name(registerKuroCommands, "registerKuroCommands");
2078
2077
 
2079
2078
  // src/services/game_func/game_service.ts
2080
2079
  var is_gaming = false;
2080
+ var is_thinking = false;
2081
2081
  var chatHistory2 = [];
2082
2082
  async function startSituationPuzzle(config) {
2083
2083
  if (is_gaming)
2084
2084
  return "海龟汤正在进行中,请先结束游戏";
2085
2085
  chatHistory2 = [];
2086
- const prompt_start = `你是一个海龟汤游戏主持人,现在开始游戏。
2087
- 请生成一个海龟汤谜题,要求如下:
2088
- 1. 谜题是中文问句且内容简洁,包含一个看似矛盾或难以理解的情境
2089
- 2. 谜题长度不超过100字
2090
- 3. 谜题答案需要符合逻辑但出人意料
2091
- `;
2086
+ const prompt_start = local_config2?.game?.situation_puzzle;
2092
2087
  chatHistory2.push({ role: "system", content: [{ type: "text", text: prompt_start }] });
2093
2088
  const { err, resp } = await callOpenRouter(config.api_url, config.api_key, config.api_model, chatHistory2);
2094
2089
  if (err != null) {
@@ -2102,12 +2097,15 @@ async function startSituationPuzzle(config) {
2102
2097
  __name(startSituationPuzzle, "startSituationPuzzle");
2103
2098
  async function questSituationPuzzle(content, config) {
2104
2099
  chatHistory2.push({ role: "user", content: [{ type: "text", text: content }] });
2100
+ is_thinking = true;
2105
2101
  const { err, resp } = await callOpenRouter(config.api_url, config.api_key, config.api_model, chatHistory2);
2102
+ is_thinking = false;
2106
2103
  if (err != null || err != "") {
2107
2104
  logger.error("[questSituationPuzzle Error]: " + err);
2108
2105
  return null;
2109
2106
  }
2110
2107
  chatHistory2.push({ role: "assistant", content: [{ type: "text", text: resp }] });
2108
+ return resp;
2111
2109
  }
2112
2110
  __name(questSituationPuzzle, "questSituationPuzzle");
2113
2111
  async function endSituationPuzzle(config) {
@@ -2135,12 +2133,12 @@ function registerGameCommands(ctx, game_config, ai_config) {
2135
2133
  if (game_config?.config_path) {
2136
2134
  local_config2 = loadYamlConfig(game_config.config_path);
2137
2135
  if (local_config2) {
2138
- logger.info("[loadYamlConfig Info]: SON 成功加载配置文件");
2136
+ logger.info("[loadYamlConfig Info]: Game 成功加载配置文件");
2139
2137
  } else {
2140
- logger.error("[loadYamlConfig Error]: SON 配置文件加载失败,将使用默认配置");
2138
+ logger.error("[loadYamlConfig Error]: Game 配置文件加载失败,将使用默认配置");
2141
2139
  }
2142
2140
  } else {
2143
- logger.error("[loadYamlConfig Error]: 未配置 SON 配置文件路径");
2141
+ logger.error("[loadYamlConfig Error]: 未配置 Game 配置文件路径");
2144
2142
  }
2145
2143
  ctx.command("gamelist", "查看所有游戏").action(async ({ session }) => {
2146
2144
  return `[所有命令都需要@bot]
@@ -2178,6 +2176,7 @@ function registerGameMiddleware(ctx, ai_config) {
2178
2176
  const { content, uid, userId } = session;
2179
2177
  if (ctx.bots[uid]) return next();
2180
2178
  if (!is_at_bot(session)) return next();
2179
+ if (is_thinking) return "正在思考,请耐心等待...";
2181
2180
  const withoutTags = content.replace(/<[^>]+>/g, " ");
2182
2181
  const text = withoutTags.replace(/\s+/g, " ").trim();
2183
2182
  logger.info("[game middleware Info]: " + text);
@@ -1,6 +1,7 @@
1
1
  import { Context } from 'koishi';
2
2
  import { GameConfig } from '../../utils/configs/game_config';
3
3
  import { AiAPIConfig } from '../../utils/config';
4
+ declare let local_config: any;
4
5
  declare function registerGameCommands(ctx: Context, game_config: GameConfig, ai_config: AiAPIConfig): void;
5
6
  declare function registerGameMiddleware(ctx: Context, ai_config: AiAPIConfig): void;
6
- export { registerGameCommands, registerGameMiddleware, };
7
+ export { local_config, registerGameCommands, registerGameMiddleware, };
@@ -1,6 +1,7 @@
1
1
  import { AiAPIConfig } from "../../utils/config";
2
2
  declare let is_gaming: boolean;
3
+ declare let is_thinking: boolean;
3
4
  declare function startSituationPuzzle(config: AiAPIConfig): Promise<string>;
4
- declare function questSituationPuzzle(content: string, config: AiAPIConfig): Promise<any>;
5
+ declare function questSituationPuzzle(content: string, config: AiAPIConfig): Promise<string>;
5
6
  declare function endSituationPuzzle(config: AiAPIConfig): Promise<string>;
6
- export { is_gaming, startSituationPuzzle, questSituationPuzzle, endSituationPuzzle };
7
+ export { is_gaming, is_thinking, startSituationPuzzle, questSituationPuzzle, endSituationPuzzle };
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.3",
4
+ "version": "1.1.0-beta.4",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
7
7
  "contributors": [