koishi-plugin-booth-get 2.0.0 → 3.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/README.md +16 -1
- package/lib/index.js +24 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -8,4 +8,19 @@
|
|
|
8
8
|
|
|
9
9
|
内容展示:
|
|
10
10
|
|
|
11
|
-
https://www.freeimg.cn/i/2024/09/01/66d47ad049577.png
|
|
11
|
+
https://www.freeimg.cn/i/2024/09/01/66d47ad049577.png
|
|
12
|
+
|
|
13
|
+
更新内容:
|
|
14
|
+
|
|
15
|
+
2.0.0版本更新自定义代理
|
|
16
|
+
|
|
17
|
+
3.0.0版本更新ws服务(目前还在测试阶段,预测5.0.0版本与大家见面)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
感谢大家的喜欢与支持
|
|
21
|
+
|
|
22
|
+
最后更新预测6.0.0版本,本版本将优化反馈图片
|
|
23
|
+
|
|
24
|
+
图片预览
|
|
25
|
+
|
|
26
|
+
https://www.freeimg.cn/i/2024/09/15/66e626ea2f552.webp
|
package/lib/index.js
CHANGED
|
@@ -33,6 +33,8 @@ var Config = import_koishi.Schema.object({
|
|
|
33
33
|
loadTimeout: import_koishi.Schema.natural().role("ms").description("加载页面的最长时间。当一个页面等待时间超过这个值时,如果此页面主体已经加载完成,则会发送一条提示消息“正在加载中,请稍等片刻”并继续等待加载;否则会直接提示“无法打开页面”并终止加载。").default(import_koishi.Time.second * 5),
|
|
34
34
|
idleTimeout: import_koishi.Schema.natural().role("ms").description("等待页面空闲的最长时间。当一个页面等待时间超过这个值时,将停止进一步的加载并立即发送截图。").default(import_koishi.Time.second * 30),
|
|
35
35
|
proxyServer: import_koishi.Schema.string().description("自定义代理服务器地址。例如:http://127.0.0.1:1080").default(""),
|
|
36
|
+
wsServer: import_koishi.Schema.string().description("WebSocket服务器地址。").default(""),
|
|
37
|
+
enableWs: import_koishi.Schema.boolean().description("是否启用WebSocket连接。").default(false),
|
|
36
38
|
}).description("booth-get");
|
|
37
39
|
function apply(ctx, config) {
|
|
38
40
|
const logger = ctx.logger("screenshot");
|
|
@@ -41,6 +43,28 @@ function apply(ctx, config) {
|
|
|
41
43
|
const booth_url = "https://booth.pm/zh-cn/items/";
|
|
42
44
|
const maxSize = 1024 * 1024;
|
|
43
45
|
const launchOptions = { ...ctx.puppeteer.config.launchOptions };
|
|
46
|
+
|
|
47
|
+
if (config.enableWs && config.wsServer) {
|
|
48
|
+
const WebSocket = require('ws');
|
|
49
|
+
let wsUrl = config.wsServer;
|
|
50
|
+
if (!wsUrl.startsWith('ws://') && !wsUrl.startsWith('wss://')) {
|
|
51
|
+
wsUrl = 'ws://' + wsUrl;
|
|
52
|
+
}
|
|
53
|
+
const ws = new WebSocket(wsUrl);
|
|
54
|
+
ws.on('open', function open() {
|
|
55
|
+
console.log('Connected to WebSocket server');
|
|
56
|
+
ws.send('Hello, server!');
|
|
57
|
+
});
|
|
58
|
+
ws.on('message', function incoming(data) {
|
|
59
|
+
console.log('Received message:', data);
|
|
60
|
+
});
|
|
61
|
+
ws.on('error', function handleErrors(error) {
|
|
62
|
+
console.error('WebSocket error:', error);
|
|
63
|
+
});
|
|
64
|
+
ws.on('close', function close() {
|
|
65
|
+
console.log('Disconnected from WebSocket server');
|
|
66
|
+
});
|
|
67
|
+
}
|
|
44
68
|
|
|
45
69
|
if (proxyServer) {
|
|
46
70
|
launchOptions.args = launchOptions.args || [];
|