koishi-plugin-cocoyyy-console 1.1.0-beta.2 → 1.1.0-beta.3

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 +7 -4
  2. package/package.json +1 -1
package/lib/index.js CHANGED
@@ -1519,7 +1519,7 @@ async function callOpenRouter(api_url, api_key, api_model = "gpt-4o-mini", messa
1519
1519
  let err = null;
1520
1520
  if (typeof reply === "string") {
1521
1521
  responseText = reply.trim();
1522
- if (!responseText) {
1522
+ if (responseText === "" || responseText === null) {
1523
1523
  err = "OpenRouter 返回空内容";
1524
1524
  }
1525
1525
  } else if (Array.isArray(reply)) {
@@ -1530,6 +1530,7 @@ 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);
1533
1534
  return { err, resp: responseText };
1534
1535
  } catch (error) {
1535
1536
  const err = error;
@@ -2102,7 +2103,7 @@ __name(startSituationPuzzle, "startSituationPuzzle");
2102
2103
  async function questSituationPuzzle(content, config) {
2103
2104
  chatHistory2.push({ role: "user", content: [{ type: "text", text: content }] });
2104
2105
  const { err, resp } = await callOpenRouter(config.api_url, config.api_key, config.api_model, chatHistory2);
2105
- if (err != null) {
2106
+ if (err != null || err != "") {
2106
2107
  logger.error("[questSituationPuzzle Error]: " + err);
2107
2108
  return null;
2108
2109
  }
@@ -2177,8 +2178,10 @@ function registerGameMiddleware(ctx, ai_config) {
2177
2178
  const { content, uid, userId } = session;
2178
2179
  if (ctx.bots[uid]) return next();
2179
2180
  if (!is_at_bot(session)) return next();
2180
- logger.info("[game middleware Info]: " + session.content);
2181
- const resp = await questSituationPuzzle(session.content, ai_config);
2181
+ const withoutTags = content.replace(/<[^>]+>/g, " ");
2182
+ const text = withoutTags.replace(/\s+/g, " ").trim();
2183
+ logger.info("[game middleware Info]: " + text);
2184
+ const resp = await questSituationPuzzle(text, ai_config);
2182
2185
  return checkResp(resp);
2183
2186
  });
2184
2187
  }
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.2",
4
+ "version": "1.1.0-beta.3",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
7
7
  "contributors": [