koishi-plugin-cocoyyy-console 1.1.2-beta.1 → 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",
|
|
@@ -1586,7 +1610,7 @@ async function checkShitOrNot(session, parttern_msg, config) {
|
|
|
1586
1610
|
chatHistory.push({ role: "user", content: targetContent });
|
|
1587
1611
|
const { err: err2, resp: resp2 } = await callOpenRouter(config.api_url, config.api_key, config.api_model, chatHistory);
|
|
1588
1612
|
if (err2 != null) {
|
|
1589
|
-
logger.error("[
|
|
1613
|
+
logger.error("[checkShitOrNot Error]: " + err2);
|
|
1590
1614
|
return null;
|
|
1591
1615
|
}
|
|
1592
1616
|
return resp2;
|
|
@@ -1661,8 +1685,66 @@ function is_at_bot_quote(session) {
|
|
|
1661
1685
|
}
|
|
1662
1686
|
__name(is_at_bot_quote, "is_at_bot_quote");
|
|
1663
1687
|
|
|
1664
|
-
// src/services/
|
|
1688
|
+
// src/services/himg_func/himg_service.ts
|
|
1665
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"));
|
|
1666
1748
|
var import_qs = __toESM(require("qs"));
|
|
1667
1749
|
|
|
1668
1750
|
// src/models/kuro_user.ts
|
|
@@ -1795,7 +1877,7 @@ var CONSTANTS = {
|
|
|
1795
1877
|
"source": "ios"
|
|
1796
1878
|
}
|
|
1797
1879
|
};
|
|
1798
|
-
var wavesApi =
|
|
1880
|
+
var wavesApi = import_axios3.default.create();
|
|
1799
1881
|
wavesApi.interceptors.request.use(
|
|
1800
1882
|
async (config) => {
|
|
1801
1883
|
if (config.url.startsWith("/")) {
|
|
@@ -2070,7 +2152,7 @@ function registerKuroCommands(ctx, connected) {
|
|
|
2070
2152
|
__name(registerKuroCommands, "registerKuroCommands");
|
|
2071
2153
|
|
|
2072
2154
|
// src/services/game_func/game_command.ts
|
|
2073
|
-
var
|
|
2155
|
+
var import_koishi13 = require("koishi");
|
|
2074
2156
|
|
|
2075
2157
|
// src/services/game_func/game_service.ts
|
|
2076
2158
|
var is_gaming = false;
|
|
@@ -2259,7 +2341,7 @@ async function situationPuzzleMiddleware(session, ai_config) {
|
|
|
2259
2341
|
return checkResp(resp2);
|
|
2260
2342
|
}
|
|
2261
2343
|
const resp = await questSituationPuzzle(text, ai_config);
|
|
2262
|
-
return (0,
|
|
2344
|
+
return (0, import_koishi13.h)("at", { id: userId }) + " " + checkResp(resp);
|
|
2263
2345
|
} finally {
|
|
2264
2346
|
is_thinking = false;
|
|
2265
2347
|
}
|
|
@@ -2276,7 +2358,7 @@ __name(checkResp, "checkResp");
|
|
|
2276
2358
|
// src/index.ts
|
|
2277
2359
|
var name = "cocoyyy-console";
|
|
2278
2360
|
var dev_mode;
|
|
2279
|
-
var Config =
|
|
2361
|
+
var Config = import_koishi14.Schema.object({
|
|
2280
2362
|
function_config: FunctionConfigSchema.description("功能开关配置"),
|
|
2281
2363
|
ai_config: AiAPIConfigSchema.description("AI API配置"),
|
|
2282
2364
|
mysql_config: MysqlConfigSchema.description("MySQL 数据库配置"),
|
|
@@ -2284,9 +2366,9 @@ var Config = import_koishi13.Schema.object({
|
|
|
2284
2366
|
repeat_config: RepeatConfigSchema.description("复读配置"),
|
|
2285
2367
|
son_config: ShitOrNotConfigSchema.description("SON配置"),
|
|
2286
2368
|
game_config: GameConfigSchema.description("游戏配置"),
|
|
2287
|
-
test:
|
|
2369
|
+
test: import_koishi14.Schema.string().description("测试")
|
|
2288
2370
|
});
|
|
2289
|
-
var logger = new
|
|
2371
|
+
var logger = new import_koishi14.Logger(name);
|
|
2290
2372
|
var savePath = null;
|
|
2291
2373
|
async function apply(ctx, config) {
|
|
2292
2374
|
ctx = ctx.guild();
|
|
@@ -2308,6 +2390,8 @@ async function apply(ctx, config) {
|
|
|
2308
2390
|
registerRepeatMiddleware(ctx, config?.repeat_config);
|
|
2309
2391
|
if (config.function_config.son_flag)
|
|
2310
2392
|
registerShitOrNotCommands(ctx, config?.ai_config, config?.son_config);
|
|
2393
|
+
if (config.function_config.setu_flag)
|
|
2394
|
+
registerHImgCommands(ctx);
|
|
2311
2395
|
if (config.function_config.game_flag) {
|
|
2312
2396
|
registerGameCommands(ctx, config?.game_config, config?.ai_config);
|
|
2313
2397
|
registerGameMiddleware(ctx, config?.ai_config);
|