koishi-plugin-oni-wiki-qq 0.0.7 → 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 +1 -1
- package/lib/index.js +25 -10
- package/package.json +1 -1
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.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";
|
|
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,7 @@ 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 了
|
|
46
47
|
- 0.0.7 对网址进行编码以确保不会出现奇奇怪怪的问题
|
|
47
48
|
- 0.0.6 空网址错误处理
|
|
48
49
|
- 0.0.5 太久没写忘记build了...
|
|
@@ -59,7 +60,6 @@ var Config = import_koishi.Schema.object({
|
|
|
59
60
|
function apply(ctx, config) {
|
|
60
61
|
const logger = ctx.logger;
|
|
61
62
|
ctx.command("x <itemName>", "查询缺氧中文wiki").alias("/查wiki").option("delete", "-d 删除本地缓存", { authority: 2 }).action(async ({ session, options }, itemName = "电解器") => {
|
|
62
|
-
logger.info(session.guildId);
|
|
63
63
|
const filePath = config.imgPath + itemName.replace(/\//g, "-").replace(/:/g, "-").replace(/'/g, "-") + ".jpeg";
|
|
64
64
|
const urlPath = config.urlPath + itemName.replace(/\//g, "-").replace(/:/g, "-").replace(/'/g, "-") + ".jpeg";
|
|
65
65
|
if (options.delete) {
|
|
@@ -75,7 +75,7 @@ function apply(ctx, config) {
|
|
|
75
75
|
return (0, import_koishi.h)("img", { src: `${encodeURI(urlPath)}` });
|
|
76
76
|
}
|
|
77
77
|
session.send(`您查询的「${itemName}」进行中,请稍等...`);
|
|
78
|
-
await (0, import_koishi.sleep)(
|
|
78
|
+
await (0, import_koishi.sleep)(500);
|
|
79
79
|
const res = await getWiki(config.api);
|
|
80
80
|
if (res.length == 0) {
|
|
81
81
|
return `在Wiki里没找到或API查询超时或....`;
|
|
@@ -101,14 +101,29 @@ function apply(ctx, config) {
|
|
|
101
101
|
const awlist = [1, 2, 3];
|
|
102
102
|
const awser = +(await session.prompt(50 * 1e3))?.replace(/\s+/g, "")?.slice(-1) || NaN;
|
|
103
103
|
if (awlist.includes(awser)) {
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
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
|
+
}
|
|
109
124
|
}
|
|
110
125
|
} else if (Number.isNaN(awser)) {
|
|
111
|
-
return
|
|
126
|
+
return `您输入的选项有误,已完结本轮查询,如有需要,请重新发起查询.`;
|
|
112
127
|
}
|
|
113
128
|
}
|
|
114
129
|
async function getWiki(api) {
|
|
@@ -138,7 +153,7 @@ function apply(ctx, config) {
|
|
|
138
153
|
await page.goto(url, {
|
|
139
154
|
timeout: 0
|
|
140
155
|
});
|
|
141
|
-
await (0, import_koishi.sleep)(
|
|
156
|
+
await (0, import_koishi.sleep)(2e3);
|
|
142
157
|
await page.addStyleTag({
|
|
143
158
|
content: "#mw-content-text{padding: 40px}"
|
|
144
159
|
});
|
|
@@ -149,7 +164,7 @@ function apply(ctx, config) {
|
|
|
149
164
|
path: filePath
|
|
150
165
|
}).then(() => {
|
|
151
166
|
return true;
|
|
152
|
-
}).catch((err) => {
|
|
167
|
+
}).catch(async (err) => {
|
|
153
168
|
logger.error(err);
|
|
154
169
|
return false;
|
|
155
170
|
}).finally(async () => await page.close());
|