koishi-plugin-cocoyyy-console 1.0.16-beta.6 → 1.0.16-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 +17 -9
  2. package/package.json +1 -1
package/lib/index.js CHANGED
@@ -1463,7 +1463,12 @@ async function callOpenRouter(api_url, api_key, api_model = "gpt-4o-mini", messa
1463
1463
  const err = error;
1464
1464
  const status = err.response?.status;
1465
1465
  const detail = err.response?.data?.error || err.response?.data?.message || err.message;
1466
- logger.error("[callOpenRouter Error]: OpenRouter 请求失败" + error);
1466
+ logger.error("[callOpenRouter Error]: OpenRouter 请求失败", {
1467
+ status,
1468
+ detail,
1469
+ url: err.config?.url,
1470
+ payload: err.config?.data
1471
+ });
1467
1472
  const errorMessage = `test error${status ? `(${status})` : ""}: ${detail}`;
1468
1473
  return { err: errorMessage, resp: null };
1469
1474
  }
@@ -1493,9 +1498,12 @@ __name(extractImageAndText, "extractImageAndText");
1493
1498
  async function checkShitOrNot(session, parttern_msg, config) {
1494
1499
  chatHistory = [];
1495
1500
  chatHistory.push({ role: "user", content: [{ type: "text", text: parttern_msg }] });
1501
+ if (dev_mode) {
1502
+ logger.info("[checkShitOrNot Info]: chatHistory", { chatHistory });
1503
+ }
1496
1504
  const { err, resp } = await callOpenRouter(config.api_url, config.api_key, config.api_model, chatHistory);
1497
1505
  if (err != null) {
1498
- logger.error("[callOpenRouter Error]: " + err);
1506
+ logger.error("[callOpenRouter Error1]: " + err);
1499
1507
  return null;
1500
1508
  }
1501
1509
  chatHistory.push({ role: "assistant", content: [{ type: "text", text: resp }] });
@@ -1510,12 +1518,12 @@ async function checkShitOrNot(session, parttern_msg, config) {
1510
1518
  ...imageUrls.map((url) => ({ type: "image_url", image_url: { url } }))
1511
1519
  ];
1512
1520
  chatHistory.push({ role: "user", content: targetContent });
1513
- const secondCall = await callOpenRouter(config.api_url, config.api_key, config.api_model, chatHistory);
1514
- if (secondCall.err != null) {
1515
- logger.error("[callOpenRouter Error]: " + secondCall.err);
1521
+ const { err: err2, resp: resp2 } = await callOpenRouter(config.api_url, config.api_key, config.api_model, chatHistory);
1522
+ if (err2 != null) {
1523
+ logger.error("[callOpenRouter Error2]: " + err2);
1516
1524
  return null;
1517
1525
  }
1518
- return secondCall.resp;
1526
+ return resp2;
1519
1527
  }
1520
1528
  __name(checkShitOrNot, "checkShitOrNot");
1521
1529
 
@@ -1571,12 +1579,12 @@ son判断模式列表:
1571
1579
  });
1572
1580
  ctx.command("son <参数>", "判定是否为史").action(async ({ session }, ...args) => {
1573
1581
  if (!dev_mode) {
1574
- if (!is_at_bot_quote(session)) return "请提供正确格式,如:1 [引用消息] @bot son [判断模式]";
1582
+ if (!is_at_bot_quote(session)) return "请提供正确格式1,如: [引用消息] @bot son [判断模式]";
1575
1583
  } else {
1576
- if (!session.quote) return "请提供正确格式,如:2 [引用消息] @bot son [判断模式]";
1584
+ if (!session.quote) return "请提供正确格式2,如: [引用消息] @bot son [判断模式]";
1577
1585
  }
1578
1586
  const parttern = args?.[0];
1579
- if (!parttern) return "请提供正确格式,如:3 [引用消息] @bot son [判断模式]";
1587
+ if (!parttern) return "请提供正确格式3,如: [引用消息] @bot son [判断模式]";
1580
1588
  if (!local_config) return "未加载配置文件,请查看日志";
1581
1589
  const parttern_msg = local_config.shit_or_not?.prompts[parttern];
1582
1590
  if (!parttern_msg) return "未找到判断模式,请查看日志";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "koishi-plugin-cocoyyy-console",
3
3
  "description": "自用koishi插件,功能包含复读,记录黑历史,*人等",
4
- "version": "1.0.16-beta.6",
4
+ "version": "1.0.16-beta.8",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
7
7
  "contributors": [