koishi-plugin-cocoyyy-console 1.1.2-beta.1 → 1.1.2-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.
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 import_koishi13 = require("koishi");
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("[callOpenRouter Error 2]: " + err2);
1613
+ logger.error("[checkShitOrNot Error]: " + err2);
1590
1614
  return null;
1591
1615
  }
1592
1616
  return resp2;
@@ -1661,8 +1685,71 @@ function is_at_bot_quote(session) {
1661
1685
  }
1662
1686
  __name(is_at_bot_quote, "is_at_bot_quote");
1663
1687
 
1664
- // src/services/kuro_func/kuro_service.ts
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, ...args) {
1692
+ try {
1693
+ const r18 = keywords?.[0];
1694
+ let tags = keywords;
1695
+ const params = new URLSearchParams();
1696
+ params.append("ai", "0");
1697
+ const random = new import_koishi12.Random(() => Math.random());
1698
+ let level = random.int(1, 4);
1699
+ if (r18.toLowerCase() === "r18") {
1700
+ params.append("r18", "1");
1701
+ level = random.int(4, 7);
1702
+ tags = keywords?.slice(1);
1703
+ }
1704
+ if (args[0]) {
1705
+ params.append("num", args[0].toString());
1706
+ }
1707
+ params.append("level", level.toString());
1708
+ tags.forEach((tag) => params.append("tag", tag));
1709
+ const res = await import_axios2.default.get("https://lolisuki.cn/api/setu/v1", {
1710
+ params,
1711
+ paramsSerializer: /* @__PURE__ */ __name((p) => p.toString(), "paramsSerializer")
1712
+ });
1713
+ if (res.data?.data?.length > 0) {
1714
+ let author = res.data?.data[0].author;
1715
+ let url = res.data?.data[0].urls.regular;
1716
+ return {
1717
+ result: "作者: " + author + "\n" + import_koishi12.h.image(url),
1718
+ error: null
1719
+ };
1720
+ }
1721
+ logger.error(`[randomHImg Error]: 获取${r18 ? "r-18" : "非r-18"}图片返回为空,请求url: https://lolisuki.cn/api/setu/v1?level=` + level.toString() + "&tag=" + tags.join("&tag="));
1722
+ return {
1723
+ result: null,
1724
+ error: "未获取到图片,请使用其他标签尝试"
1725
+ };
1726
+ } catch (err) {
1727
+ return {
1728
+ result: null,
1729
+ error: err?.message ?? "获取图片请求错误"
1730
+ };
1731
+ }
1732
+ }
1733
+ __name(randomHImg, "randomHImg");
1734
+
1735
+ // src/services/himg_func/himg_commands.ts
1736
+ function registerHImgCommands(ctx) {
1737
+ ctx.command("setu <参数>", "随机一个涩图").action(async ({ session }, ...args) => {
1738
+ if (!dev_mode) {
1739
+ if (!is_at_bot(session)) return;
1740
+ }
1741
+ const tag = args;
1742
+ if (!tag) return "请提供正确格式,如:@bot setu [是否r-18] [标签1] [标签2]";
1743
+ let exec = await randomHImg(tag);
1744
+ if (!exec.result)
1745
+ return `获取图片失败:${exec.error}`;
1746
+ return exec.result;
1747
+ });
1748
+ }
1749
+ __name(registerHImgCommands, "registerHImgCommands");
1750
+
1751
+ // src/services/kuro_func/kuro_service.ts
1752
+ var import_axios3 = __toESM(require("axios"));
1666
1753
  var import_qs = __toESM(require("qs"));
1667
1754
 
1668
1755
  // src/models/kuro_user.ts
@@ -1795,7 +1882,7 @@ var CONSTANTS = {
1795
1882
  "source": "ios"
1796
1883
  }
1797
1884
  };
1798
- var wavesApi = import_axios2.default.create();
1885
+ var wavesApi = import_axios3.default.create();
1799
1886
  wavesApi.interceptors.request.use(
1800
1887
  async (config) => {
1801
1888
  if (config.url.startsWith("/")) {
@@ -2070,7 +2157,7 @@ function registerKuroCommands(ctx, connected) {
2070
2157
  __name(registerKuroCommands, "registerKuroCommands");
2071
2158
 
2072
2159
  // src/services/game_func/game_command.ts
2073
- var import_koishi12 = require("koishi");
2160
+ var import_koishi13 = require("koishi");
2074
2161
 
2075
2162
  // src/services/game_func/game_service.ts
2076
2163
  var is_gaming = false;
@@ -2259,7 +2346,7 @@ async function situationPuzzleMiddleware(session, ai_config) {
2259
2346
  return checkResp(resp2);
2260
2347
  }
2261
2348
  const resp = await questSituationPuzzle(text, ai_config);
2262
- return (0, import_koishi12.h)("at", { id: userId }) + " " + checkResp(resp);
2349
+ return (0, import_koishi13.h)("at", { id: userId }) + " " + checkResp(resp);
2263
2350
  } finally {
2264
2351
  is_thinking = false;
2265
2352
  }
@@ -2276,7 +2363,7 @@ __name(checkResp, "checkResp");
2276
2363
  // src/index.ts
2277
2364
  var name = "cocoyyy-console";
2278
2365
  var dev_mode;
2279
- var Config = import_koishi13.Schema.object({
2366
+ var Config = import_koishi14.Schema.object({
2280
2367
  function_config: FunctionConfigSchema.description("功能开关配置"),
2281
2368
  ai_config: AiAPIConfigSchema.description("AI API配置"),
2282
2369
  mysql_config: MysqlConfigSchema.description("MySQL 数据库配置"),
@@ -2284,9 +2371,9 @@ var Config = import_koishi13.Schema.object({
2284
2371
  repeat_config: RepeatConfigSchema.description("复读配置"),
2285
2372
  son_config: ShitOrNotConfigSchema.description("SON配置"),
2286
2373
  game_config: GameConfigSchema.description("游戏配置"),
2287
- test: import_koishi13.Schema.string().description("测试")
2374
+ test: import_koishi14.Schema.string().description("测试")
2288
2375
  });
2289
- var logger = new import_koishi13.Logger(name);
2376
+ var logger = new import_koishi14.Logger(name);
2290
2377
  var savePath = null;
2291
2378
  async function apply(ctx, config) {
2292
2379
  ctx = ctx.guild();
@@ -2308,6 +2395,8 @@ async function apply(ctx, config) {
2308
2395
  registerRepeatMiddleware(ctx, config?.repeat_config);
2309
2396
  if (config.function_config.son_flag)
2310
2397
  registerShitOrNotCommands(ctx, config?.ai_config, config?.son_config);
2398
+ if (config.function_config.setu_flag)
2399
+ registerHImgCommands(ctx);
2311
2400
  if (config.function_config.game_flag) {
2312
2401
  registerGameCommands(ctx, config?.game_config, config?.ai_config);
2313
2402
  registerGameMiddleware(ctx, config?.ai_config);
@@ -0,0 +1,3 @@
1
+ import { Context } from 'koishi';
2
+ declare function registerHImgCommands(ctx: Context): void;
3
+ export { registerHImgCommands };
@@ -0,0 +1,6 @@
1
+ type RandomHImgResp = {
2
+ result: string;
3
+ error: string | null;
4
+ };
5
+ declare function randomHImg(keywords: string[], ...args: any[]): Promise<RandomHImgResp>;
6
+ export { randomHImg };
@@ -6,6 +6,7 @@ interface FunctionConfig {
6
6
  repeat_flag: boolean;
7
7
  rbq_flag: boolean;
8
8
  son_flag: boolean;
9
+ setu_flag: boolean;
9
10
  game_flag: boolean;
10
11
  kuro_flag: boolean;
11
12
  }
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.2-beta.1",
4
+ "version": "1.1.2-beta.3",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
7
7
  "contributors": [