koishi-plugin-checkgal 1.0.1 → 1.0.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/commands.d.ts +1 -0
- package/lib/commands.js +10 -2
- package/package.json +1 -1
package/lib/commands.d.ts
CHANGED
package/lib/commands.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.inject = void 0;
|
|
3
4
|
exports.apply = apply;
|
|
4
5
|
const koishi_1 = require("koishi");
|
|
6
|
+
exports.inject = ['touchgal', 'gameCache'];
|
|
5
7
|
function apply(ctx, config) {
|
|
6
8
|
ctx.command('查询gal <keyword:text>', '查询Galgame信息')
|
|
7
9
|
.action(async ({ session }, keyword) => {
|
|
@@ -20,8 +22,11 @@ function apply(ctx, config) {
|
|
|
20
22
|
const imageBuffers = await Promise.all(results.map(game => ctx.touchgal.downloadAndConvertImage(game.banner)));
|
|
21
23
|
const forwardMessages = results.map((game, index) => {
|
|
22
24
|
const imageBuffer = imageBuffers[index];
|
|
25
|
+
const imageElement = imageBuffer
|
|
26
|
+
? (0, koishi_1.h)('image', { url: `base64://${imageBuffer.toString('base64')}` })
|
|
27
|
+
: (0, koishi_1.h)('text', { content: '封面图加载失败' });
|
|
23
28
|
const content = [
|
|
24
|
-
|
|
29
|
+
imageElement,
|
|
25
30
|
`ID: ${game.id}`,
|
|
26
31
|
`名称: ${game.name}`,
|
|
27
32
|
`平台: ${game.platform.join(', ')}`,
|
|
@@ -59,8 +64,11 @@ function apply(ctx, config) {
|
|
|
59
64
|
}
|
|
60
65
|
const gameTitle = gameInfo ? `游戏: ${gameInfo.name} (ID: ${id})` : `游戏ID: ${id}`;
|
|
61
66
|
const imageBuffer = gameInfo ? await ctx.touchgal.downloadAndConvertImage(gameInfo.banner) : null;
|
|
67
|
+
const imageElement = imageBuffer
|
|
68
|
+
? (0, koishi_1.h)('image', { url: `base64://${imageBuffer.toString('base64')}` })
|
|
69
|
+
: (0, koishi_1.h)('text', { content: gameInfo ? '封面图加载失败' : '' });
|
|
62
70
|
const header = [
|
|
63
|
-
|
|
71
|
+
imageElement,
|
|
64
72
|
gameTitle,
|
|
65
73
|
`共找到 ${downloads.length} 个下载资源:`,
|
|
66
74
|
].filter(Boolean).join('\n');
|