koishi-plugin-checkgal 1.3.6 → 1.4.1
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 +8 -10
- package/package.json +1 -1
package/lib/commands.js
CHANGED
|
@@ -18,9 +18,15 @@ function apply(ctx, config) {
|
|
|
18
18
|
}
|
|
19
19
|
// 缓存结果
|
|
20
20
|
results.forEach(game => ctx.gameCache.set(game.id, game));
|
|
21
|
-
//
|
|
22
|
-
const
|
|
21
|
+
// 并发下载并转换所有图片
|
|
22
|
+
const imageBuffers = await Promise.all(results.map(game => ctx.touchgal.downloadAndConvertImage(game.banner)));
|
|
23
|
+
const forwardMessages = results.map((game, index) => {
|
|
24
|
+
const imageBuffer = imageBuffers[index];
|
|
25
|
+
const imageElement = imageBuffer
|
|
26
|
+
? koishi_1.h.image(imageBuffer, 'image/jpeg')
|
|
27
|
+
: (0, koishi_1.h)('text', { content: '封面图加载失败' });
|
|
23
28
|
const content = [
|
|
29
|
+
imageElement,
|
|
24
30
|
`ID: ${game.id}`,
|
|
25
31
|
`名称: ${game.name}`,
|
|
26
32
|
`平台: ${game.platform.join(', ')}`,
|
|
@@ -29,14 +35,6 @@ function apply(ctx, config) {
|
|
|
29
35
|
return (0, koishi_1.h)('message', { userId: session.bot.selfId, nickname: 'CheckGal Bot' }, content);
|
|
30
36
|
});
|
|
31
37
|
await session.send((0, koishi_1.h)('message', { forward: true }, forwardMessages));
|
|
32
|
-
await session.send('封面图将单独发送:');
|
|
33
|
-
// 单独逐张发送图片
|
|
34
|
-
for (const game of results) {
|
|
35
|
-
const imageBuffer = await ctx.touchgal.downloadAndConvertImage(game.banner);
|
|
36
|
-
if (imageBuffer) {
|
|
37
|
-
await session.send(koishi_1.h.image(imageBuffer, 'image/jpeg'));
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
38
|
});
|
|
41
39
|
ctx.command('下载gal <id:number>', '获取Galgame下载地址')
|
|
42
40
|
.action(async ({ session }, id) => {
|