koishi-plugin-oni-wiki-qq 0.0.5 → 0.0.8

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.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { Context, Schema } from "koishi";
2
2
  export declare const name = "oni-wiki-qq";
3
3
  export declare const inject: string[];
4
- export declare const usage = "\n - 0.0.5 \u592A\u4E45\u6CA1\u5199\u5FD8\u8BB0build\u4E86...\n - 0.0.4 \u715E\u7B14\u817E\u8BAF\u4E0D\u7ED9\u53D1md\u4E86\u8279\n - 0.0.3 \u5C06\u94FE\u63A5\u6539\u4E3Amd\u53D1\u9001\u4EE5\u7ED5\u8FC7\u6C9F\u817E\u8BAF\u7684\u94FE\u63A5\u62E6\u622A\n - 0.0.2 \u57FA\u672C\u529F\u80FD\u5B8C\u6210\n - 0.0.1 \u521D\u59CB\u5316\uFF0C\u660E\u5929\u518D\u6162\u6162\u5199\u4E86\uFF08\n";
4
+ export declare const usage = "\n - 0.0.8 \u5BF9\u9009\u62E9\u7684\u5176\u4ED6\u9879\u8FDB\u884C\u5F31\u667A\u4E00\u6837\u7684\u5904\u7406,\u514D\u5F97 errlog \u90FD\u5FEB 13M \u4E86\n - 0.0.7 \u5BF9\u7F51\u5740\u8FDB\u884C\u7F16\u7801\u4EE5\u786E\u4FDD\u4E0D\u4F1A\u51FA\u73B0\u5947\u5947\u602A\u602A\u7684\u95EE\u9898\n - 0.0.6 \u7A7A\u7F51\u5740\u9519\u8BEF\u5904\u7406\n - 0.0.5 \u592A\u4E45\u6CA1\u5199\u5FD8\u8BB0build\u4E86...\n - 0.0.4 \u715E\u7B14\u817E\u8BAF\u4E0D\u7ED9\u53D1md\u4E86\u8279\n - 0.0.3 \u5C06\u94FE\u63A5\u6539\u4E3Amd\u53D1\u9001\u4EE5\u7ED5\u8FC7\u6C9F\u817E\u8BAF\u7684\u94FE\u63A5\u62E6\u622A\n - 0.0.2 \u57FA\u672C\u529F\u80FD\u5B8C\u6210\n - 0.0.1 \u521D\u59CB\u5316\uFF0C\u660E\u5929\u518D\u6162\u6162\u5199\u4E86\uFF08\n";
5
5
  export interface Config {
6
6
  api: string;
7
7
  imgPath: string;
package/lib/index.js CHANGED
@@ -43,6 +43,9 @@ var import_node_os = __toESM(require("node:os"));
43
43
  var name = "oni-wiki-qq";
44
44
  var inject = ["puppeteer"];
45
45
  var usage = `
46
+ - 0.0.8 对选择的其他项进行弱智一样的处理,免得 errlog 都快 13M 了
47
+ - 0.0.7 对网址进行编码以确保不会出现奇奇怪怪的问题
48
+ - 0.0.6 空网址错误处理
46
49
  - 0.0.5 太久没写忘记build了...
47
50
  - 0.0.4 煞笔腾讯不给发md了艹
48
51
  - 0.0.3 将链接改为md发送以绕过沟腾讯的链接拦截
@@ -56,8 +59,7 @@ var Config = import_koishi.Schema.object({
56
59
  });
57
60
  function apply(ctx, config) {
58
61
  const logger = ctx.logger;
59
- ctx.command("t <itemName>", "查询缺氧中文wiki").alias("/查wiki").option("delete", "-d 删除本地缓存", { authority: 2 }).action(async ({ session, options }, itemName = "电解器") => {
60
- logger.info(session.guildId);
62
+ ctx.command("x <itemName>", "查询缺氧中文wiki").alias("/查wiki").option("delete", "-d 删除本地缓存", { authority: 2 }).action(async ({ session, options }, itemName = "电解器") => {
61
63
  const filePath = config.imgPath + itemName.replace(/\//g, "-").replace(/:/g, "-").replace(/'/g, "-") + ".jpeg";
62
64
  const urlPath = config.urlPath + itemName.replace(/\//g, "-").replace(/:/g, "-").replace(/'/g, "-") + ".jpeg";
63
65
  if (options.delete) {
@@ -69,10 +71,11 @@ function apply(ctx, config) {
69
71
  }
70
72
  }
71
73
  if (checkFileExists(filePath)) {
72
- return (0, import_koishi.h)("img", { src: `${urlPath}` });
74
+ console.log(urlPath);
75
+ return (0, import_koishi.h)("img", { src: `${encodeURI(urlPath)}` });
73
76
  }
74
77
  session.send(`您查询的「${itemName}」进行中,请稍等...`);
75
- await (0, import_koishi.sleep)(2e3);
78
+ await (0, import_koishi.sleep)(500);
76
79
  const res = await getWiki(config.api);
77
80
  if (res.length == 0) {
78
81
  return `在Wiki里没找到或API查询超时或....`;
@@ -83,7 +86,7 @@ function apply(ctx, config) {
83
86
  if (title[0] === itemName) {
84
87
  let res2 = await screenShot(itemUrl[0]);
85
88
  if (res2) {
86
- return (0, import_koishi.h)("img", { src: `${urlPath}` });
89
+ return (0, import_koishi.h)("img", { src: `${encodeURI(urlPath)}` });
87
90
  } else {
88
91
  return `截图发生错误.请稍后重试..`;
89
92
  }
@@ -98,14 +101,29 @@ function apply(ctx, config) {
98
101
  const awlist = [1, 2, 3];
99
102
  const awser = +(await session.prompt(50 * 1e3))?.replace(/\s+/g, "")?.slice(-1) || NaN;
100
103
  if (awlist.includes(awser)) {
101
- let res2 = await screenShot(itemUrl[awser - 1]);
102
- if (res2) {
103
- return (0, import_koishi.h)("img", { src: `${urlPath}` });
104
- } else {
105
- return `截图发生错误.请稍后重试..`;
104
+ switch (awlist.includes(awser)) {
105
+ case (one == "萌新的骨头汤" && awser == 1):
106
+ return (0, import_koishi.h)("img", {
107
+ src: `${encodeURI(config.urlPath + one)}.jpeg`
108
+ });
109
+ case (two == "" && awser == 2):
110
+ return (0, import_koishi.h)("img", {
111
+ src: `${encodeURI(config.urlPath + two)}.jpeg`
112
+ });
113
+ case (three == "" && awser == 3):
114
+ return (0, import_koishi.h)("img", {
115
+ src: `${encodeURI(config.urlPath + three)}.jpeg`
116
+ });
117
+ default:
118
+ let res2 = await screenShot(itemUrl[awser - 1]);
119
+ if (res2) {
120
+ return (0, import_koishi.h)("img", { src: `${encodeURI(urlPath)}` });
121
+ } else {
122
+ return `截图发生错误.请稍后重试..`;
123
+ }
106
124
  }
107
125
  } else if (Number.isNaN(awser)) {
108
- return `您输入的选项有误,已完结本轮查询。如需,如有需要,请重新发起查询.`;
126
+ return `您输入的选项有误,已完结本轮查询,如有需要,请重新发起查询.`;
109
127
  }
110
128
  }
111
129
  async function getWiki(api) {
@@ -135,7 +153,7 @@ function apply(ctx, config) {
135
153
  await page.goto(url, {
136
154
  timeout: 0
137
155
  });
138
- await (0, import_koishi.sleep)(3e3);
156
+ await (0, import_koishi.sleep)(2e3);
139
157
  await page.addStyleTag({
140
158
  content: "#mw-content-text{padding: 40px}"
141
159
  });
@@ -146,7 +164,7 @@ function apply(ctx, config) {
146
164
  path: filePath
147
165
  }).then(() => {
148
166
  return true;
149
- }).catch((err) => {
167
+ }).catch(async (err) => {
150
168
  logger.error(err);
151
169
  return false;
152
170
  }).finally(async () => await page.close());
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "koishi-plugin-oni-wiki-qq",
3
3
  "description": "缺氧wiki查询",
4
- "version": "0.0.5",
4
+ "version": "0.0.8",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
7
7
  "files": [