koishi-plugin-checkgal 1.6.3 → 1.6.4
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/commands.js +36 -19
- package/package.json +4 -3
package/lib/commands.js
CHANGED
|
@@ -13,10 +13,12 @@ function apply(ctx, config, deps) {
|
|
|
13
13
|
await session.send('正在查询,请稍候...');
|
|
14
14
|
const results = await touchgal.searchGame(keyword, config);
|
|
15
15
|
if (!results.length) {
|
|
16
|
-
return
|
|
16
|
+
return `未找到关于"${keyword}"的任何游戏。`;
|
|
17
17
|
}
|
|
18
18
|
// 缓存结果
|
|
19
19
|
results.forEach(game => gameCache.set(game.id, game));
|
|
20
|
+
// 构建合并转发消息
|
|
21
|
+
const forwardMessages = [];
|
|
20
22
|
for (const game of results) {
|
|
21
23
|
const imageBuffer = await touchgal.downloadAndConvertImage(game.banner);
|
|
22
24
|
const imageElement = imageBuffer
|
|
@@ -29,8 +31,10 @@ function apply(ctx, config, deps) {
|
|
|
29
31
|
`平台: ${game.platform.join(', ')}`,
|
|
30
32
|
`语言: ${game.language.join(', ')}`,
|
|
31
33
|
].join('\n');
|
|
32
|
-
|
|
34
|
+
forwardMessages.push((0, koishi_1.h)('message', {}, content));
|
|
33
35
|
}
|
|
36
|
+
// 发送合并转发消息
|
|
37
|
+
await session.send((0, koishi_1.h)('message', { forward: true }, forwardMessages));
|
|
34
38
|
});
|
|
35
39
|
ctx.command('下载gal <id:number>', '获取Galgame下载地址')
|
|
36
40
|
.action(async ({ session }, id) => {
|
|
@@ -49,7 +53,7 @@ function apply(ctx, config, deps) {
|
|
|
49
53
|
gameCache.set(id, gameInfo);
|
|
50
54
|
}
|
|
51
55
|
else {
|
|
52
|
-
await session.send(
|
|
56
|
+
await session.send(`无法获取游戏"${id}"的详细信息,但仍会尝试获取下载链接...`);
|
|
53
57
|
}
|
|
54
58
|
}
|
|
55
59
|
const downloads = await touchgal.getDownloads(id);
|
|
@@ -58,24 +62,37 @@ function apply(ctx, config, deps) {
|
|
|
58
62
|
}
|
|
59
63
|
const gameTitle = gameInfo ? `游戏: ${gameInfo.name} (ID: ${id})` : `游戏ID: ${id}`;
|
|
60
64
|
const imageBuffer = gameInfo ? await touchgal.downloadAndConvertImage(gameInfo.banner) : null;
|
|
61
|
-
//
|
|
65
|
+
// 构建合并转发消息
|
|
66
|
+
const forwardMessages = [];
|
|
67
|
+
// 第一条消息:游戏标题和封面
|
|
62
68
|
if (imageBuffer) {
|
|
63
|
-
|
|
69
|
+
const headerContent = [
|
|
70
|
+
koishi_1.h.image(imageBuffer, 'image/jpeg'),
|
|
71
|
+
gameTitle,
|
|
72
|
+
`共找到 ${downloads.length} 个下载资源`,
|
|
73
|
+
].join('\n');
|
|
74
|
+
forwardMessages.push((0, koishi_1.h)('message', {}, headerContent));
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
const headerContent = [
|
|
78
|
+
gameTitle,
|
|
79
|
+
`共找到 ${downloads.length} 个下载资源`,
|
|
80
|
+
].join('\n');
|
|
81
|
+
forwardMessages.push((0, koishi_1.h)('message', {}, headerContent));
|
|
64
82
|
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
` 提取码: ${res.code || '无'}`,
|
|
75
|
-
` 解压码: ${res.password || '无'}`,
|
|
76
|
-
` 备注: ${res.note || '无'}`,
|
|
83
|
+
// 后续消息:每个下载资源一条消息
|
|
84
|
+
for (const res of downloads) {
|
|
85
|
+
const resContent = [
|
|
86
|
+
`名称: ${res.name}`,
|
|
87
|
+
`平台: ${res.platform.join(', ')} | 大小: ${res.size}`,
|
|
88
|
+
`下载地址: ${res.content}`,
|
|
89
|
+
`提取码: ${res.code || '无'}`,
|
|
90
|
+
`解压码: ${res.password || '无'}`,
|
|
91
|
+
`备注: ${res.note || '无'}`,
|
|
77
92
|
].join('\n');
|
|
78
|
-
|
|
79
|
-
|
|
93
|
+
forwardMessages.push((0, koishi_1.h)('message', {}, resContent));
|
|
94
|
+
}
|
|
95
|
+
// 发送合并转发消息
|
|
96
|
+
await session.send((0, koishi_1.h)('message', { forward: true }, forwardMessages));
|
|
80
97
|
});
|
|
81
98
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "koishi-plugin-checkgal",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.4",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"build": "tsc"
|
|
6
6
|
},
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
],
|
|
32
32
|
"peerDependencies": {
|
|
33
33
|
"koishi": "^4.18.9",
|
|
34
|
-
"koishi-plugin-ffmpeg": ""
|
|
34
|
+
"koishi-plugin-ffmpeg": "^1.1.0"
|
|
35
35
|
},
|
|
36
36
|
"koishi": {
|
|
37
37
|
"description": {
|
|
@@ -44,7 +44,8 @@
|
|
|
44
44
|
}
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
|
+
"koishi-plugin-ffmpeg": "^1.1.0",
|
|
47
48
|
"typescript": "^5.4.0",
|
|
48
49
|
"@types/node": "^18.0.0"
|
|
49
50
|
}
|
|
50
|
-
}
|
|
51
|
+
}
|