koishi-plugin-cocoyyy-console 1.1.2-beta.2 → 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
@@ -1688,16 +1688,21 @@ __name(is_at_bot_quote, "is_at_bot_quote");
1688
1688
  // src/services/himg_func/himg_service.ts
1689
1689
  var import_axios2 = __toESM(require("axios"));
1690
1690
  var import_koishi12 = require("koishi");
1691
- async function randomHImg(keywords) {
1691
+ async function randomHImg(keywords, ...args) {
1692
1692
  try {
1693
1693
  const r18 = keywords?.[0];
1694
- const tags = keywords?.slice(1);
1694
+ let tags = keywords;
1695
1695
  const params = new URLSearchParams();
1696
+ params.append("ai", "0");
1696
1697
  const random = new import_koishi12.Random(() => Math.random());
1697
1698
  let level = random.int(1, 4);
1698
- if (r18) {
1699
+ if (r18.toLowerCase() === "r18") {
1699
1700
  params.append("r18", "1");
1700
1701
  level = random.int(4, 7);
1702
+ tags = keywords?.slice(1);
1703
+ }
1704
+ if (args[0]) {
1705
+ params.append("num", args[0].toString());
1701
1706
  }
1702
1707
  params.append("level", level.toString());
1703
1708
  tags.forEach((tag) => params.append("tag", tag));
@@ -1705,7 +1710,7 @@ async function randomHImg(keywords) {
1705
1710
  params,
1706
1711
  paramsSerializer: /* @__PURE__ */ __name((p) => p.toString(), "paramsSerializer")
1707
1712
  });
1708
- if (res.data) {
1713
+ if (res.data?.data?.length > 0) {
1709
1714
  let author = res.data?.data[0].author;
1710
1715
  let url = res.data?.data[0].urls.regular;
1711
1716
  return {
@@ -1716,7 +1721,7 @@ async function randomHImg(keywords) {
1716
1721
  logger.error(`[randomHImg Error]: 获取${r18 ? "r-18" : "非r-18"}图片返回为空,请求url: https://lolisuki.cn/api/setu/v1?level=` + level.toString() + "&tag=" + tags.join("&tag="));
1717
1722
  return {
1718
1723
  result: null,
1719
- error: "获取图片返回为空"
1724
+ error: "未获取到图片,请使用其他标签尝试"
1720
1725
  };
1721
1726
  } catch (err) {
1722
1727
  return {
@@ -2,5 +2,5 @@ type RandomHImgResp = {
2
2
  result: string;
3
3
  error: string | null;
4
4
  };
5
- declare function randomHImg(keywords: string[]): Promise<RandomHImgResp>;
5
+ declare function randomHImg(keywords: string[], ...args: any[]): Promise<RandomHImgResp>;
6
6
  export { randomHImg };
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.2",
4
+ "version": "1.1.2-beta.3",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
7
7
  "contributors": [