koishi-plugin-cocoyyy-console 1.1.2-beta.0 → 1.1.2-beta.2
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
|
@@ -38,7 +38,7 @@ __export(src_exports, {
|
|
|
38
38
|
savePath: () => savePath
|
|
39
39
|
});
|
|
40
40
|
module.exports = __toCommonJS(src_exports);
|
|
41
|
-
var
|
|
41
|
+
var import_koishi14 = require("koishi");
|
|
42
42
|
|
|
43
43
|
// src/utils/configs/function_config.ts
|
|
44
44
|
var import_koishi = require("koishi");
|
|
@@ -49,6 +49,7 @@ var FunctionConfigSchema = import_koishi.Schema.object({
|
|
|
49
49
|
repeat_flag: import_koishi.Schema.boolean().default(true).description("复读功能是否启用"),
|
|
50
50
|
rbq_flag: import_koishi.Schema.boolean().default(true).description("*人功能是否启用"),
|
|
51
51
|
son_flag: import_koishi.Schema.boolean().default(true).description("鉴别史消息功能是否启用"),
|
|
52
|
+
setu_flag: import_koishi.Schema.boolean().default(true).description("随机涩图功能是否启用"),
|
|
52
53
|
game_flag: import_koishi.Schema.boolean().default(true).description("游戏功能是否启用"),
|
|
53
54
|
kuro_flag: import_koishi.Schema.boolean().default(true).description("鸣潮功能是否启用")
|
|
54
55
|
});
|
|
@@ -342,6 +343,11 @@ var menuList = [
|
|
|
342
343
|
description: "shit_or_not功能,用于鉴别史消息",
|
|
343
344
|
command: "无"
|
|
344
345
|
},
|
|
346
|
+
{
|
|
347
|
+
name: "setu",
|
|
348
|
+
description: "随机涩图功能,用于获取涩图",
|
|
349
|
+
command: "无"
|
|
350
|
+
},
|
|
345
351
|
{
|
|
346
352
|
name: "game",
|
|
347
353
|
description: "游戏功能,用于游玩游戏",
|
|
@@ -374,6 +380,10 @@ function getMenuList(command = null, functionConfig) {
|
|
|
374
380
|
if (!functionConfig.son_flag)
|
|
375
381
|
return "son功能已关闭";
|
|
376
382
|
return getSonFuncMenu(command);
|
|
383
|
+
case "setu":
|
|
384
|
+
if (!functionConfig.setu_flag)
|
|
385
|
+
return "son功能已关闭";
|
|
386
|
+
return getSetuFuncMenu(command);
|
|
377
387
|
case "game":
|
|
378
388
|
if (!functionConfig.game_flag)
|
|
379
389
|
return "游戏功能已关闭";
|
|
@@ -487,6 +497,20 @@ son功能菜单:
|
|
|
487
497
|
输入对应指令使用son功能,如果遇到问题请联系开发人员。`;
|
|
488
498
|
}
|
|
489
499
|
__name(getSonFuncMenu, "getSonFuncMenu");
|
|
500
|
+
var setuFuncMenuList = [
|
|
501
|
+
{
|
|
502
|
+
name: "setu",
|
|
503
|
+
description: "随机一个涩图",
|
|
504
|
+
command: "setu [是否r-18] [标签1] [标签2]"
|
|
505
|
+
}
|
|
506
|
+
];
|
|
507
|
+
function getSetuFuncMenu(command = null) {
|
|
508
|
+
return `[所有命令都需要@bot]
|
|
509
|
+
setu功能菜单:
|
|
510
|
+
${setuFuncMenuList.map((item) => item.command + ": " + item.description).join("\n ")}
|
|
511
|
+
输入对应指令使用setu功能,如果遇到问题请联系开发人员。`;
|
|
512
|
+
}
|
|
513
|
+
__name(getSetuFuncMenu, "getSetuFuncMenu");
|
|
490
514
|
var gameFuncMenuList = [
|
|
491
515
|
{
|
|
492
516
|
name: "gamelist",
|
|
@@ -1571,12 +1595,6 @@ __name(extractImageAndText, "extractImageAndText");
|
|
|
1571
1595
|
async function checkShitOrNot(session, parttern_msg, config) {
|
|
1572
1596
|
chatHistory = [];
|
|
1573
1597
|
chatHistory.push({ role: "system", content: [{ type: "text", text: parttern_msg }] });
|
|
1574
|
-
const { err, resp } = await callOpenRouter(config.api_url, config.api_key, config.api_model, chatHistory);
|
|
1575
|
-
if (err != null) {
|
|
1576
|
-
logger.error("[callOpenRouter Error 1]: " + err);
|
|
1577
|
-
return null;
|
|
1578
|
-
}
|
|
1579
|
-
chatHistory.push({ role: "assistant", content: [{ type: "text", text: resp }] });
|
|
1580
1598
|
const quoteContent = session.quote.content;
|
|
1581
1599
|
logger.info("[checkShitOrNot Info]: 引用消息内容: " + quoteContent);
|
|
1582
1600
|
const { imageUrls, text } = extractImageAndText(quoteContent);
|
|
@@ -1592,7 +1610,7 @@ async function checkShitOrNot(session, parttern_msg, config) {
|
|
|
1592
1610
|
chatHistory.push({ role: "user", content: targetContent });
|
|
1593
1611
|
const { err: err2, resp: resp2 } = await callOpenRouter(config.api_url, config.api_key, config.api_model, chatHistory);
|
|
1594
1612
|
if (err2 != null) {
|
|
1595
|
-
logger.error("[
|
|
1613
|
+
logger.error("[checkShitOrNot Error]: " + err2);
|
|
1596
1614
|
return null;
|
|
1597
1615
|
}
|
|
1598
1616
|
return resp2;
|
|
@@ -1627,8 +1645,6 @@ son判断模式列表:
|
|
|
1627
1645
|
ctx.command("son <参数>", "判定是否为史").action(async ({ session }, ...args) => {
|
|
1628
1646
|
if (!dev_mode) {
|
|
1629
1647
|
if (!is_at_bot_quote(session)) return "请提供正确格式,如: [引用消息] @bot son [判断模式]";
|
|
1630
|
-
} else {
|
|
1631
|
-
if (!session.quote) return "请引用消息后使用功能";
|
|
1632
1648
|
}
|
|
1633
1649
|
if (think_flag) return "请等待思考结果";
|
|
1634
1650
|
const parttern = args?.[0];
|
|
@@ -1669,8 +1685,66 @@ function is_at_bot_quote(session) {
|
|
|
1669
1685
|
}
|
|
1670
1686
|
__name(is_at_bot_quote, "is_at_bot_quote");
|
|
1671
1687
|
|
|
1672
|
-
// src/services/
|
|
1688
|
+
// src/services/himg_func/himg_service.ts
|
|
1673
1689
|
var import_axios2 = __toESM(require("axios"));
|
|
1690
|
+
var import_koishi12 = require("koishi");
|
|
1691
|
+
async function randomHImg(keywords) {
|
|
1692
|
+
try {
|
|
1693
|
+
const r18 = keywords?.[0];
|
|
1694
|
+
const tags = keywords?.slice(1);
|
|
1695
|
+
const params = new URLSearchParams();
|
|
1696
|
+
const random = new import_koishi12.Random(() => Math.random());
|
|
1697
|
+
let level = random.int(1, 4);
|
|
1698
|
+
if (r18) {
|
|
1699
|
+
params.append("r18", "1");
|
|
1700
|
+
level = random.int(4, 7);
|
|
1701
|
+
}
|
|
1702
|
+
params.append("level", level.toString());
|
|
1703
|
+
tags.forEach((tag) => params.append("tag", tag));
|
|
1704
|
+
const res = await import_axios2.default.get("https://lolisuki.cn/api/setu/v1", {
|
|
1705
|
+
params,
|
|
1706
|
+
paramsSerializer: /* @__PURE__ */ __name((p) => p.toString(), "paramsSerializer")
|
|
1707
|
+
});
|
|
1708
|
+
if (res.data) {
|
|
1709
|
+
let author = res.data?.data[0].author;
|
|
1710
|
+
let url = res.data?.data[0].urls.regular;
|
|
1711
|
+
return {
|
|
1712
|
+
result: "作者: " + author + "\n" + import_koishi12.h.image(url),
|
|
1713
|
+
error: null
|
|
1714
|
+
};
|
|
1715
|
+
}
|
|
1716
|
+
logger.error(`[randomHImg Error]: 获取${r18 ? "r-18" : "非r-18"}图片返回为空,请求url: https://lolisuki.cn/api/setu/v1?level=` + level.toString() + "&tag=" + tags.join("&tag="));
|
|
1717
|
+
return {
|
|
1718
|
+
result: null,
|
|
1719
|
+
error: "获取图片返回为空"
|
|
1720
|
+
};
|
|
1721
|
+
} catch (err) {
|
|
1722
|
+
return {
|
|
1723
|
+
result: null,
|
|
1724
|
+
error: err?.message ?? "获取图片请求错误"
|
|
1725
|
+
};
|
|
1726
|
+
}
|
|
1727
|
+
}
|
|
1728
|
+
__name(randomHImg, "randomHImg");
|
|
1729
|
+
|
|
1730
|
+
// src/services/himg_func/himg_commands.ts
|
|
1731
|
+
function registerHImgCommands(ctx) {
|
|
1732
|
+
ctx.command("setu <参数>", "随机一个涩图").action(async ({ session }, ...args) => {
|
|
1733
|
+
if (!dev_mode) {
|
|
1734
|
+
if (!is_at_bot(session)) return;
|
|
1735
|
+
}
|
|
1736
|
+
const tag = args;
|
|
1737
|
+
if (!tag) return "请提供正确格式,如:@bot setu [是否r-18] [标签1] [标签2]";
|
|
1738
|
+
let exec = await randomHImg(tag);
|
|
1739
|
+
if (!exec.result)
|
|
1740
|
+
return `获取图片失败:${exec.error}`;
|
|
1741
|
+
return exec.result;
|
|
1742
|
+
});
|
|
1743
|
+
}
|
|
1744
|
+
__name(registerHImgCommands, "registerHImgCommands");
|
|
1745
|
+
|
|
1746
|
+
// src/services/kuro_func/kuro_service.ts
|
|
1747
|
+
var import_axios3 = __toESM(require("axios"));
|
|
1674
1748
|
var import_qs = __toESM(require("qs"));
|
|
1675
1749
|
|
|
1676
1750
|
// src/models/kuro_user.ts
|
|
@@ -1803,7 +1877,7 @@ var CONSTANTS = {
|
|
|
1803
1877
|
"source": "ios"
|
|
1804
1878
|
}
|
|
1805
1879
|
};
|
|
1806
|
-
var wavesApi =
|
|
1880
|
+
var wavesApi = import_axios3.default.create();
|
|
1807
1881
|
wavesApi.interceptors.request.use(
|
|
1808
1882
|
async (config) => {
|
|
1809
1883
|
if (config.url.startsWith("/")) {
|
|
@@ -2078,7 +2152,7 @@ function registerKuroCommands(ctx, connected) {
|
|
|
2078
2152
|
__name(registerKuroCommands, "registerKuroCommands");
|
|
2079
2153
|
|
|
2080
2154
|
// src/services/game_func/game_command.ts
|
|
2081
|
-
var
|
|
2155
|
+
var import_koishi13 = require("koishi");
|
|
2082
2156
|
|
|
2083
2157
|
// src/services/game_func/game_service.ts
|
|
2084
2158
|
var is_gaming = false;
|
|
@@ -2267,7 +2341,7 @@ async function situationPuzzleMiddleware(session, ai_config) {
|
|
|
2267
2341
|
return checkResp(resp2);
|
|
2268
2342
|
}
|
|
2269
2343
|
const resp = await questSituationPuzzle(text, ai_config);
|
|
2270
|
-
return (0,
|
|
2344
|
+
return (0, import_koishi13.h)("at", { id: userId }) + " " + checkResp(resp);
|
|
2271
2345
|
} finally {
|
|
2272
2346
|
is_thinking = false;
|
|
2273
2347
|
}
|
|
@@ -2284,7 +2358,7 @@ __name(checkResp, "checkResp");
|
|
|
2284
2358
|
// src/index.ts
|
|
2285
2359
|
var name = "cocoyyy-console";
|
|
2286
2360
|
var dev_mode;
|
|
2287
|
-
var Config =
|
|
2361
|
+
var Config = import_koishi14.Schema.object({
|
|
2288
2362
|
function_config: FunctionConfigSchema.description("功能开关配置"),
|
|
2289
2363
|
ai_config: AiAPIConfigSchema.description("AI API配置"),
|
|
2290
2364
|
mysql_config: MysqlConfigSchema.description("MySQL 数据库配置"),
|
|
@@ -2292,9 +2366,9 @@ var Config = import_koishi13.Schema.object({
|
|
|
2292
2366
|
repeat_config: RepeatConfigSchema.description("复读配置"),
|
|
2293
2367
|
son_config: ShitOrNotConfigSchema.description("SON配置"),
|
|
2294
2368
|
game_config: GameConfigSchema.description("游戏配置"),
|
|
2295
|
-
test:
|
|
2369
|
+
test: import_koishi14.Schema.string().description("测试")
|
|
2296
2370
|
});
|
|
2297
|
-
var logger = new
|
|
2371
|
+
var logger = new import_koishi14.Logger(name);
|
|
2298
2372
|
var savePath = null;
|
|
2299
2373
|
async function apply(ctx, config) {
|
|
2300
2374
|
ctx = ctx.guild();
|
|
@@ -2316,6 +2390,8 @@ async function apply(ctx, config) {
|
|
|
2316
2390
|
registerRepeatMiddleware(ctx, config?.repeat_config);
|
|
2317
2391
|
if (config.function_config.son_flag)
|
|
2318
2392
|
registerShitOrNotCommands(ctx, config?.ai_config, config?.son_config);
|
|
2393
|
+
if (config.function_config.setu_flag)
|
|
2394
|
+
registerHImgCommands(ctx);
|
|
2319
2395
|
if (config.function_config.game_flag) {
|
|
2320
2396
|
registerGameCommands(ctx, config?.game_config, config?.ai_config);
|
|
2321
2397
|
registerGameMiddleware(ctx, config?.ai_config);
|