koishi-plugin-oni-wiki-qq 0.2.0 → 0.2.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.d.ts +1 -1
- package/lib/index.js +11 -11
- 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.2.0 \u5C1D\u8BD5\u6DFB\u52A0 MWN \u5E93\n - 0.1.0 \u6DFB\u52A0\u767B\u5F55\u548C\u70B9\u51FBcookies\u6309\u94AE,\u5220\u9664\u6CA1\u6CD5\u5224\u65AD\u7B54\u6848\u7684\u4EE3\u7801\n
|
|
4
|
+
export declare const usage = "\n - 0.2.2 \u5C1D\u8BD5\u79FB\u9664\u9876\u90E8\u5BFC\u822A\n - 0.2.1 \u4EA4\u6362\u56FE\u7247\u548C\u6D88\u606F\u4F4D\u7F6E\u4EE5\u4F7Fqq\u53D1\u9001\u65F6\u5728\u540C\u4E00\u6D88\u606F\u907F\u514D\u5237\u5C4F\n - 0.2.0 \u5C1D\u8BD5\u6DFB\u52A0 MWN \u5E93\n - 0.1.0 \u6DFB\u52A0\u767B\u5F55\u548C\u70B9\u51FBcookies\u6309\u94AE,\u5220\u9664\u6CA1\u6CD5\u5224\u65AD\u7B54\u6848\u7684\u4EE3\u7801\n";
|
|
5
5
|
export interface Config {
|
|
6
6
|
api: string;
|
|
7
7
|
imgPath: string;
|
package/lib/index.js
CHANGED
|
@@ -72,6 +72,7 @@ async function getWiki(itemName, config) {
|
|
|
72
72
|
redirects: "return",
|
|
73
73
|
format: "json"
|
|
74
74
|
}).then(async (res) => {
|
|
75
|
+
console.log(res);
|
|
75
76
|
if (res[1][0] == itemName) {
|
|
76
77
|
return res[3][0];
|
|
77
78
|
} else {
|
|
@@ -85,9 +86,10 @@ __name(getWiki, "getWiki");
|
|
|
85
86
|
var name = "oni-wiki-qq";
|
|
86
87
|
var inject = ["puppeteer"];
|
|
87
88
|
var usage = `
|
|
89
|
+
- 0.2.2 尝试移除顶部导航
|
|
90
|
+
- 0.2.1 交换图片和消息位置以使qq发送时在同一消息避免刷屏
|
|
88
91
|
- 0.2.0 尝试添加 MWN 库
|
|
89
92
|
- 0.1.0 添加登录和点击cookies按钮,删除没法判断答案的代码
|
|
90
|
-
- 0.0.9 尝试移除导航框,更新koishi依赖
|
|
91
93
|
`;
|
|
92
94
|
var Config = import_koishi.Schema.object({
|
|
93
95
|
api: import_koishi.Schema.string().default("https://oxygennotincluded.wiki.gg/zh/api.php").description("api地址"),
|
|
@@ -122,23 +124,21 @@ function apply(ctx, config) {
|
|
|
122
124
|
if (checkFileExists(filePath)) {
|
|
123
125
|
return (0, import_koishi.h)(
|
|
124
126
|
"p",
|
|
125
|
-
|
|
126
|
-
|
|
127
|
+
(0, import_koishi.h)("img", { src: `${encodeURI(urlPath)}` }),
|
|
128
|
+
`图片已保存至:${encodeURI(urlPath)}`
|
|
127
129
|
);
|
|
128
130
|
}
|
|
129
131
|
session.send(`您查询的「${itemName}」进行中,请稍等...`);
|
|
130
|
-
await (0, import_koishi.sleep)(500);
|
|
131
132
|
const res = await getWiki(itemName, config);
|
|
132
133
|
if (!res) {
|
|
133
134
|
return `在Wiki里没找到或API查询超时,如有需要,请按照游戏内名称重新发起查询....`;
|
|
134
135
|
}
|
|
135
136
|
let screenShotRes = await screenShot(res);
|
|
136
|
-
logger.info(`API返回的数据为: ${screenShotRes}`);
|
|
137
137
|
if (screenShotRes) {
|
|
138
138
|
return (0, import_koishi.h)(
|
|
139
139
|
"p",
|
|
140
|
-
|
|
141
|
-
|
|
140
|
+
(0, import_koishi.h)("img", { src: `${encodeURI(urlPath)}` }),
|
|
141
|
+
`图片已保存至:${encodeURI(urlPath)}`
|
|
142
142
|
);
|
|
143
143
|
} else {
|
|
144
144
|
return `截图发生错误.请稍后重试..`;
|
|
@@ -154,17 +154,17 @@ function apply(ctx, config) {
|
|
|
154
154
|
});
|
|
155
155
|
try {
|
|
156
156
|
await page.$eval(config.navSelector, (el) => el.remove());
|
|
157
|
+
await page.$eval("#mw-head", (el) => el.remove());
|
|
157
158
|
} catch (error) {
|
|
158
|
-
logger.error(error);
|
|
159
159
|
}
|
|
160
160
|
const selector = await page.$(config.contentSelector);
|
|
161
161
|
return await selector.screenshot({
|
|
162
162
|
type: "jpeg",
|
|
163
|
-
quality:
|
|
163
|
+
quality: 60,
|
|
164
164
|
path: filePath
|
|
165
165
|
}).then(() => {
|
|
166
166
|
return true;
|
|
167
|
-
}).catch(
|
|
167
|
+
}).catch((err) => {
|
|
168
168
|
logger.error(err);
|
|
169
169
|
return false;
|
|
170
170
|
}).finally(async () => await page.close());
|
|
@@ -207,7 +207,7 @@ function apply(ctx, config) {
|
|
|
207
207
|
await (0, import_koishi.sleep)(5e3);
|
|
208
208
|
session.send(
|
|
209
209
|
import_koishi.h.image(
|
|
210
|
-
await page.screenshot({ type: "jpeg", quality:
|
|
210
|
+
await page.screenshot({ type: "jpeg", quality: 75 }),
|
|
211
211
|
"jpeg/image"
|
|
212
212
|
)
|
|
213
213
|
);
|