koishi-plugin-booth-get 0.0.5 → 2.0.0
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 +10 -3
- package/package.json +2 -2
package/lib/index.js
CHANGED
|
@@ -31,14 +31,21 @@ var name = "booth-get";
|
|
|
31
31
|
var inject = ["puppeteer"];
|
|
32
32
|
var Config = import_koishi.Schema.object({
|
|
33
33
|
loadTimeout: import_koishi.Schema.natural().role("ms").description("加载页面的最长时间。当一个页面等待时间超过这个值时,如果此页面主体已经加载完成,则会发送一条提示消息“正在加载中,请稍等片刻”并继续等待加载;否则会直接提示“无法打开页面”并终止加载。").default(import_koishi.Time.second * 5),
|
|
34
|
-
idleTimeout: import_koishi.Schema.natural().role("ms").description("等待页面空闲的最长时间。当一个页面等待时间超过这个值时,将停止进一步的加载并立即发送截图。").default(import_koishi.Time.second * 30)
|
|
34
|
+
idleTimeout: import_koishi.Schema.natural().role("ms").description("等待页面空闲的最长时间。当一个页面等待时间超过这个值时,将停止进一步的加载并立即发送截图。").default(import_koishi.Time.second * 30),
|
|
35
|
+
proxyServer: import_koishi.Schema.string().description("自定义代理服务器地址。例如:http://127.0.0.1:1080").default(""),
|
|
35
36
|
}).description("booth-get");
|
|
36
37
|
function apply(ctx, config) {
|
|
37
38
|
const logger = ctx.logger("screenshot");
|
|
38
39
|
const { defaultViewport } = ctx.puppeteer.config;
|
|
39
|
-
const { loadTimeout, idleTimeout } = config;
|
|
40
|
+
const { loadTimeout, idleTimeout,proxyServer } = config;
|
|
40
41
|
const booth_url = "https://booth.pm/zh-cn/items/";
|
|
41
42
|
const maxSize = 1024 * 1024;
|
|
43
|
+
const launchOptions = { ...ctx.puppeteer.config.launchOptions };
|
|
44
|
+
|
|
45
|
+
if (proxyServer) {
|
|
46
|
+
launchOptions.args = launchOptions.args || [];
|
|
47
|
+
launchOptions.args.push(`--proxy-server=${proxyServer}`);
|
|
48
|
+
}
|
|
42
49
|
ctx.command("摊位 <id>").action(async ({ session }, id) => {
|
|
43
50
|
if (!id)
|
|
44
51
|
return "请输入ID";
|
|
@@ -48,7 +55,7 @@ function apply(ctx, config) {
|
|
|
48
55
|
if (typeof result === "string")
|
|
49
56
|
return result;
|
|
50
57
|
let loaded = false;
|
|
51
|
-
const page = await ctx.puppeteer.page();
|
|
58
|
+
const page = await ctx.puppeteer.page(launchOptions);
|
|
52
59
|
page.on("load", () => loaded = true);
|
|
53
60
|
try {
|
|
54
61
|
await new Promise((resolve, reject) => {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "koishi-plugin-booth-get",
|
|
3
3
|
"description": "通过url与名称检查摊位物品并反馈用户搜索的图片",
|
|
4
|
-
"version": "0.0
|
|
4
|
+
"version": "2.0.0",
|
|
5
5
|
"contributors": [
|
|
6
6
|
"rixiang <1148147857@qq.com>"
|
|
7
7
|
],
|
|
@@ -37,4 +37,4 @@
|
|
|
37
37
|
"pngjs": "^7.0.0",
|
|
38
38
|
"puppeteer-core": "^22.12.1"
|
|
39
39
|
}
|
|
40
|
-
}
|
|
40
|
+
}
|