koishi-plugin-cocoyyy-console 1.0.16-beta.5 → 1.0.16-beta.7
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 +25 -9
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -1463,7 +1463,7 @@ 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 请求失败" +
|
|
1466
|
+
logger.error("[callOpenRouter Error]: OpenRouter 请求失败" + detail);
|
|
1467
1467
|
const errorMessage = `test error${status ? `(${status})` : ""}: ${detail}`;
|
|
1468
1468
|
return { err: errorMessage, resp: null };
|
|
1469
1469
|
}
|
|
@@ -1495,7 +1495,7 @@ async function checkShitOrNot(session, parttern_msg, config) {
|
|
|
1495
1495
|
chatHistory.push({ role: "user", content: [{ type: "text", text: parttern_msg }] });
|
|
1496
1496
|
const { err, resp } = await callOpenRouter(config.api_url, config.api_key, config.api_model, chatHistory);
|
|
1497
1497
|
if (err != null) {
|
|
1498
|
-
logger.error("[callOpenRouter
|
|
1498
|
+
logger.error("[callOpenRouter Error1]: " + err);
|
|
1499
1499
|
return null;
|
|
1500
1500
|
}
|
|
1501
1501
|
chatHistory.push({ role: "assistant", content: [{ type: "text", text: resp }] });
|
|
@@ -1510,17 +1510,28 @@ async function checkShitOrNot(session, parttern_msg, config) {
|
|
|
1510
1510
|
...imageUrls.map((url) => ({ type: "image_url", image_url: { url } }))
|
|
1511
1511
|
];
|
|
1512
1512
|
chatHistory.push({ role: "user", content: targetContent });
|
|
1513
|
-
const
|
|
1514
|
-
if (
|
|
1515
|
-
logger.error("[callOpenRouter
|
|
1513
|
+
const { err: err2, resp: resp2 } = await callOpenRouter(config.api_url, config.api_key, config.api_model, chatHistory);
|
|
1514
|
+
if (err2 != null) {
|
|
1515
|
+
logger.error("[callOpenRouter Error2]: " + err2);
|
|
1516
1516
|
return null;
|
|
1517
1517
|
}
|
|
1518
|
-
return
|
|
1518
|
+
return resp2;
|
|
1519
1519
|
}
|
|
1520
1520
|
__name(checkShitOrNot, "checkShitOrNot");
|
|
1521
1521
|
|
|
1522
1522
|
// src/services/son_func/shit_or_not_command.ts
|
|
1523
1523
|
var local_config = null;
|
|
1524
|
+
var mode_intro = {
|
|
1525
|
+
"esu": "【图文】ohno妈咪饿素啊😨,恶俗慎用!🈲",
|
|
1526
|
+
"nov": "【图文】来段微小说📕",
|
|
1527
|
+
"lit": "【图文】文楠魅力时刻📕👨",
|
|
1528
|
+
"zhi": "【图文】分享你刚编的故事🤓",
|
|
1529
|
+
"boa": "【图文】《答案之书》🔮",
|
|
1530
|
+
"scp": "【图文】控制-收容-保护,献上你的异常👽",
|
|
1531
|
+
"phi": "【图文】我思,故我在🧠",
|
|
1532
|
+
"see": "【图像】让我康康怎么个事👀",
|
|
1533
|
+
"ccb": "【图像】压抑笑传之踩踩背🐘"
|
|
1534
|
+
};
|
|
1524
1535
|
function loadYamlConfig(configPath) {
|
|
1525
1536
|
if (!configPath) {
|
|
1526
1537
|
logger.error("[loadYamlConfig Error]: SON 配置文件路径未配置");
|
|
@@ -1553,14 +1564,19 @@ function registerShitOrNotCommands(ctx, config) {
|
|
|
1553
1564
|
} else {
|
|
1554
1565
|
logger.error("[loadYamlConfig Error]: 未配置 SON 配置文件路径");
|
|
1555
1566
|
}
|
|
1567
|
+
ctx.command("sonlist <参数>", "查看son判断模式列表").action(() => {
|
|
1568
|
+
return `[所有命令都需要@bot]
|
|
1569
|
+
son判断模式列表:
|
|
1570
|
+
${Object.keys(mode_intro).map((item) => item + ": " + mode_intro[item]).join("\n ")}`;
|
|
1571
|
+
});
|
|
1556
1572
|
ctx.command("son <参数>", "判定是否为史").action(async ({ session }, ...args) => {
|
|
1557
1573
|
if (!dev_mode) {
|
|
1558
|
-
if (!is_at_bot_quote(session)) return "
|
|
1574
|
+
if (!is_at_bot_quote(session)) return "请提供正确格式1,如: [引用消息] @bot son [判断模式]";
|
|
1559
1575
|
} else {
|
|
1560
|
-
if (!session.quote) return "
|
|
1576
|
+
if (!session.quote) return "请提供正确格式2,如: [引用消息] @bot son [判断模式]";
|
|
1561
1577
|
}
|
|
1562
1578
|
const parttern = args?.[0];
|
|
1563
|
-
if (!parttern) return "
|
|
1579
|
+
if (!parttern) return "请提供正确格式3,如: [引用消息] @bot son [判断模式]";
|
|
1564
1580
|
if (!local_config) return "未加载配置文件,请查看日志";
|
|
1565
1581
|
const parttern_msg = local_config.shit_or_not?.prompts[parttern];
|
|
1566
1582
|
if (!parttern_msg) return "未找到判断模式,请查看日志";
|