koishi-plugin-checkgal 1.5.2 → 1.6.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/api.d.ts +6 -0
- package/lib/api.js +8 -5
- package/lib/index.d.ts +1 -0
- package/lib/index.js +2 -1
- package/package.json +16 -8
package/lib/api.d.ts
CHANGED
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
import { Context } from 'koishi';
|
|
2
2
|
import { GameInfo, DownloadResource } from './types';
|
|
3
3
|
import { Config } from './config';
|
|
4
|
+
declare module 'koishi' {
|
|
5
|
+
interface Context {
|
|
6
|
+
canvas: any;
|
|
7
|
+
}
|
|
8
|
+
}
|
|
4
9
|
export declare class TouchGalAPI {
|
|
5
10
|
private http;
|
|
6
11
|
private logger;
|
|
12
|
+
private ctx;
|
|
7
13
|
constructor(ctx: Context);
|
|
8
14
|
searchGame(keyword: string, config: Config): Promise<GameInfo[]>;
|
|
9
15
|
getDownloads(patchId: number): Promise<DownloadResource[]>;
|
package/lib/api.js
CHANGED
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.TouchGalAPI = void 0;
|
|
7
|
-
const sharp_1 = __importDefault(require("sharp"));
|
|
8
4
|
class TouchGalAPI {
|
|
9
5
|
constructor(ctx) {
|
|
6
|
+
this.ctx = ctx;
|
|
10
7
|
this.http = ctx.http;
|
|
11
8
|
this.logger = ctx.logger('checkgal-api');
|
|
12
9
|
}
|
|
@@ -71,7 +68,13 @@ class TouchGalAPI {
|
|
|
71
68
|
});
|
|
72
69
|
if (!(response instanceof ArrayBuffer))
|
|
73
70
|
return null;
|
|
74
|
-
|
|
71
|
+
const imageBuffer = Buffer.from(response);
|
|
72
|
+
const image = await this.ctx.canvas.loadImage(imageBuffer);
|
|
73
|
+
const canvas = this.ctx.canvas.createCanvas(image.width, image.height);
|
|
74
|
+
const ctx = canvas.getContext('2d');
|
|
75
|
+
ctx.drawImage(image, 0, 0);
|
|
76
|
+
const jpegBuffer = canvas.toBuffer('image/jpeg');
|
|
77
|
+
return jpegBuffer;
|
|
75
78
|
}
|
|
76
79
|
catch (error) {
|
|
77
80
|
this.logger.error(`Failed to download or convert image from ${url}:`, error);
|
package/lib/index.d.ts
CHANGED
package/lib/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Config = exports.name = void 0;
|
|
3
|
+
exports.Config = exports.inject = exports.name = void 0;
|
|
4
4
|
exports.apply = apply;
|
|
5
5
|
const config_1 = require("./config");
|
|
6
6
|
Object.defineProperty(exports, "Config", { enumerable: true, get: function () { return config_1.Config; } });
|
|
@@ -8,6 +8,7 @@ const api_1 = require("./api");
|
|
|
8
8
|
const cache_1 = require("./cache");
|
|
9
9
|
const commands_1 = require("./commands");
|
|
10
10
|
exports.name = 'checkgal';
|
|
11
|
+
exports.inject = ['canvas'];
|
|
11
12
|
function apply(ctx, config) {
|
|
12
13
|
// 初始化服务
|
|
13
14
|
const api = new api_1.TouchGalAPI(ctx);
|
package/package.json
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "koishi-plugin-checkgal",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.6.1",
|
|
4
|
+
"scripts": {
|
|
5
|
+
"build": "tsc"
|
|
6
|
+
},
|
|
4
7
|
"description": "基于TouchGal API的Galgame信息查询与下载插件",
|
|
5
|
-
|
|
8
|
+
"contributors": [
|
|
6
9
|
"lumia.wang <fenglian19980510@gmail.com>"
|
|
7
10
|
],
|
|
8
11
|
"main": "lib/index.js",
|
|
@@ -11,13 +14,13 @@
|
|
|
11
14
|
"lib",
|
|
12
15
|
"dist"
|
|
13
16
|
],
|
|
14
|
-
"homepage": "https://github.com/
|
|
17
|
+
"homepage": "https://github.com/lumia1998/koishi-plugin-checkgal",
|
|
15
18
|
"bugs": {
|
|
16
|
-
"url": "https://github.com/
|
|
19
|
+
"url": "https://github.com/lumia1998/koishi-plugin-checkgal/issues"
|
|
17
20
|
},
|
|
18
21
|
"repository": {
|
|
19
22
|
"type": "git",
|
|
20
|
-
"url": "git+https://github.com/
|
|
23
|
+
"url": "git+https://github.com/lumia1998/koishi-plugin-checkgal.git"
|
|
21
24
|
},
|
|
22
25
|
"license": "AGPL-3.0",
|
|
23
26
|
"keywords": [
|
|
@@ -32,10 +35,15 @@
|
|
|
32
35
|
"koishi": {
|
|
33
36
|
"description": {
|
|
34
37
|
"zh": "基于TouchGal API的Galgame信息查询与下载插件"
|
|
38
|
+
},
|
|
39
|
+
"service": {
|
|
40
|
+
"required": [
|
|
41
|
+
"canvas"
|
|
42
|
+
]
|
|
35
43
|
}
|
|
36
44
|
},
|
|
37
45
|
"devDependencies": {
|
|
38
|
-
"typescript": "^5.
|
|
39
|
-
"@types/
|
|
46
|
+
"typescript": "^5.4.0",
|
|
47
|
+
"@types/node": "^18.0.0"
|
|
40
48
|
}
|
|
41
|
-
}
|
|
49
|
+
}
|