Commit d6118002 authored by nanahira's avatar nanahira

bump

parent c476b097
......@@ -26,6 +26,23 @@ app.plugin(DatabasePlugin);
app.plugin(ExtrasInDev);
// Target plugin
app.plugin(TargetPlugin, {} as any);
app.plugin(TargetPlugin, {
instances: [
{
name: 'yande',
weight: 1,
endpoint: 'https://yande.re/post.json',
pageLimit: 200,
isDefault: true,
},
{
name: 'konachan',
weight: 1,
endpoint: 'https://konachan.com/post.json',
pageLimit: 200,
isDefault: true,
},
],
});
app.start();
......@@ -35,8 +35,8 @@
"ws": "^8.5.0"
},
"peerDependencies": {
"koishi": "^4.6.0",
"koishi-plugin-pics": "^9.0.0"
"koishi": "^4.6.1",
"koishi-plugin-pics": "^9.0.3"
}
},
"node_modules/@ampproject/remapping": {
......@@ -1069,15 +1069,15 @@
}
},
"node_modules/@koishijs/core": {
"version": "4.6.0",
"resolved": "https://registry.npmjs.org/@koishijs/core/-/core-4.6.0.tgz",
"integrity": "sha512-m+K2h/Oqmpcw39dQhJ/D9MBmwnWNUf9uFqymJ94+nP4CR7rcM1DTWNiaMGshGUqNu+s4q0ildoEDlQrE4hVuWA==",
"version": "4.6.1",
"resolved": "https://registry.npmjs.org/@koishijs/core/-/core-4.6.1.tgz",
"integrity": "sha512-2HzdUi76YSLFZYpPXcmEwwVyHQLPF8BL0GJR6PuCYdOYfHykzwA5NmqOGx29EyeuYzs8sS6yr25IQktxMYqsdg==",
"peer": true,
"dependencies": {
"@koishijs/utils": "^5.4.0",
"cosmotype": "^1.0.3",
"@koishijs/utils": "^5.4.1",
"cosmotype": "^1.0.6",
"fastest-levenshtein": "^1.0.12",
"ns-require": "^1.1.0"
"ns-require": "^1.1.2"
},
"engines": {
"node": ">=12.0.0"
......@@ -1156,15 +1156,15 @@
"peer": true
},
"node_modules/@koishijs/utils": {
"version": "5.4.0",
"resolved": "https://registry.npmjs.org/@koishijs/utils/-/utils-5.4.0.tgz",
"integrity": "sha512-w5SHArw032cXVtxp5nXkc5jzP6Fn3LrF7FQTanPnOgmjGv/AIOAKfJ6bqaOUsSg+ttcK3iO8xs65W6XsNz3g7g==",
"version": "5.4.1",
"resolved": "https://registry.npmjs.org/@koishijs/utils/-/utils-5.4.1.tgz",
"integrity": "sha512-M3L9KqtdTyCzQK1LxTtp7QCucc75IA2vRwnYJA1gXMAxPC3SoEjUVmsk/oNFBSknmfADdViI5mFJtUXMCpJW1g==",
"peer": true,
"dependencies": {
"@koishijs/segment": "^1.1.1",
"cosmokit": "^1.1.1",
"reggol": "^1.0.1",
"schemastery": "^3.3.2",
"cosmokit": "^1.1.2",
"reggol": "^1.0.2",
"schemastery": "^3.3.3",
"supports-color": "^8.1.1"
}
},
......@@ -2632,18 +2632,18 @@
"peer": true
},
"node_modules/cosmokit": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/cosmokit/-/cosmokit-1.1.1.tgz",
"integrity": "sha512-+f8x9pFGIc7I6HTObS90dq2K5YsI4U3Me4l9OminU9woVtF9Sv3CAHb5vKbFZ93XpTFctAQ6qAVSGjkGvGI9iw=="
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/cosmokit/-/cosmokit-1.1.2.tgz",
"integrity": "sha512-cSNrcyxZ3GT+tjSlUzWIzMiK7Wndq1Nm/2tlRhT65RXltSIcH5zaHdmnz1TnIhLuOViaO9qfSdnRPzxNkxMv0g=="
},
"node_modules/cosmotype": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/cosmotype/-/cosmotype-1.0.3.tgz",
"integrity": "sha512-JykvyDjyjaDjycm8CcK8GD4Xt6/Glu4pJU9uJ5lsDuE5B5bdmAykiTPMHfs+Is8QUsNaDKpsHfxtxCUBDPYgdw==",
"version": "1.0.9",
"resolved": "https://registry.npmjs.org/cosmotype/-/cosmotype-1.0.9.tgz",
"integrity": "sha512-ot2m5LYBj9UNFvYpQNQ28hWYDG4GWmym094us2HNn6qgYzvALmjs4FxEVBsjA+VBnIf3ykuMGRYcex5cqZTvJQ==",
"peer": true,
"dependencies": {
"cosmokit": "^1.1.1",
"ns-require": "^1.1.0"
"cosmokit": "^1.1.2",
"ns-require": "^1.1.2"
}
},
"node_modules/cosmotype-decorators": {
......@@ -5215,14 +5215,14 @@
}
},
"node_modules/koishi": {
"version": "4.6.0",
"resolved": "https://registry.npmjs.org/koishi/-/koishi-4.6.0.tgz",
"integrity": "sha512-QhjFWTGhrFnYfpVg4dNNxgHER38zSij3nyM/RB3YrLTM4VwImVk5unpgg0QryViwWxSYM4zJ0YUoys4A9jgG6A==",
"version": "4.6.1",
"resolved": "https://registry.npmjs.org/koishi/-/koishi-4.6.1.tgz",
"integrity": "sha512-9NtcXrIKLN8AG9zEf3GzweSiHQubew0AWfjaci0grIxy760T77D8iLVsDbVhzmGSnc26WOR2q3CMFdRmE2igVA==",
"peer": true,
"dependencies": {
"@koa/router": "^10.1.1",
"@koishijs/core": "^4.6.0",
"@koishijs/utils": "^5.4.0",
"@koishijs/core": "^4.6.1",
"@koishijs/utils": "^5.4.1",
"@types/koa": "*",
"@types/koa__router": "*",
"@types/ws": "^8.5.3",
......@@ -5255,16 +5255,16 @@
}
},
"node_modules/koishi-plugin-pics": {
"version": "9.0.0",
"resolved": "https://registry.npmjs.org/koishi-plugin-pics/-/koishi-plugin-pics-9.0.0.tgz",
"integrity": "sha512-oRbgqbTs2sZvER5+i6OeD6TYR4ttSC3BfQjXuGq5em1Itt9KPLkQ6ZXcZPYMdidFQokFDfBvCu8abA6IDZBLjQ==",
"version": "9.0.3",
"resolved": "https://registry.npmjs.org/koishi-plugin-pics/-/koishi-plugin-pics-9.0.3.tgz",
"integrity": "sha512-ZXzRJnGwg1W7dNRdmcaRyYFiGDFuOPq8qLh/Qer0Bk/dHVTW9tYZcdViXfA5TSe7sxluoB2koTRB8JvwPTnhVA==",
"peer": true,
"dependencies": {
"koishi-thirdeye": "^10.0.0",
"koishi-thirdeye": "^10.0.5",
"lodash": "^4.17.21"
},
"peerDependencies": {
"koishi": "^4.6.0"
"koishi": "^4.6.1"
}
},
"node_modules/koishi-thirdeye": {
......@@ -5580,9 +5580,9 @@
}
},
"node_modules/ns-require": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/ns-require/-/ns-require-1.1.0.tgz",
"integrity": "sha512-Iw349zwWNgkGZjYJtruf+BXUe8YHOiMZE0iUNffvpt/A1yTSabTnpBMQ0zNl65G1LhpzwCo1KMCqjmJF0z8O6g==",
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/ns-require/-/ns-require-1.1.2.tgz",
"integrity": "sha512-GUF6I1hWDsGx1cA9FW27KIRAlkMel2UZagR39dVNPAPBgwWK1Ez0XB96WEz2OFcwHsCORI9h75dEZueHqZ/1pA==",
"peer": true
},
"node_modules/nwsapi": {
......@@ -6176,12 +6176,12 @@
}
},
"node_modules/reggol": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/reggol/-/reggol-1.0.1.tgz",
"integrity": "sha512-ZMOp3rZG6YQFVp/DC+BgFZaXSQcxHDayCmo7cL/kGujsSEoUzee0VJq1KCe9sgNt0qsM6JzkuSlj/+5SmmoO7Q==",
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/reggol/-/reggol-1.0.2.tgz",
"integrity": "sha512-BP7gx5nUBntWChG4x/yf7xLdpxy1R5PMtF/LJlOsz+XkWtip4YVNkQp2Flmio9hXSc2UxrwUyP0WrQ1M/FFWXw==",
"peer": true,
"dependencies": {
"cosmokit": "^1.1.0",
"cosmokit": "^1.1.2",
"supports-color": "^8.1.1"
}
},
......@@ -6362,12 +6362,12 @@
}
},
"node_modules/schemastery": {
"version": "3.3.2",
"resolved": "https://registry.npmjs.org/schemastery/-/schemastery-3.3.2.tgz",
"integrity": "sha512-Z1C850OPtNEBs+D4QBPdC+Wu1t6Fn1BrOJILRHs2b+I/u61hUKP2vIPMAXFLvmmONnwqAW8ksPdCD6Zz9n8zhg==",
"version": "3.3.3",
"resolved": "https://registry.npmjs.org/schemastery/-/schemastery-3.3.3.tgz",
"integrity": "sha512-DwRsse6C+Qao90P/Bz+4G3gmAjM3he/VgHk3TykmEWv3KFqvwmqEn61SF3BPaTPP0L77a5Kc6q4+KQvdN1bBqA==",
"peer": true,
"dependencies": {
"cosmokit": "^1.1.0"
"cosmokit": "^1.1.2"
}
},
"node_modules/schemastery-gen": {
......@@ -8484,15 +8484,15 @@
}
},
"@koishijs/core": {
"version": "4.6.0",
"resolved": "https://registry.npmjs.org/@koishijs/core/-/core-4.6.0.tgz",
"integrity": "sha512-m+K2h/Oqmpcw39dQhJ/D9MBmwnWNUf9uFqymJ94+nP4CR7rcM1DTWNiaMGshGUqNu+s4q0ildoEDlQrE4hVuWA==",
"version": "4.6.1",
"resolved": "https://registry.npmjs.org/@koishijs/core/-/core-4.6.1.tgz",
"integrity": "sha512-2HzdUi76YSLFZYpPXcmEwwVyHQLPF8BL0GJR6PuCYdOYfHykzwA5NmqOGx29EyeuYzs8sS6yr25IQktxMYqsdg==",
"peer": true,
"requires": {
"@koishijs/utils": "^5.4.0",
"cosmotype": "^1.0.3",
"@koishijs/utils": "^5.4.1",
"cosmotype": "^1.0.6",
"fastest-levenshtein": "^1.0.12",
"ns-require": "^1.1.0"
"ns-require": "^1.1.2"
}
},
"@koishijs/plugin-cache-lru": {
......@@ -8555,15 +8555,15 @@
"peer": true
},
"@koishijs/utils": {
"version": "5.4.0",
"resolved": "https://registry.npmjs.org/@koishijs/utils/-/utils-5.4.0.tgz",
"integrity": "sha512-w5SHArw032cXVtxp5nXkc5jzP6Fn3LrF7FQTanPnOgmjGv/AIOAKfJ6bqaOUsSg+ttcK3iO8xs65W6XsNz3g7g==",
"version": "5.4.1",
"resolved": "https://registry.npmjs.org/@koishijs/utils/-/utils-5.4.1.tgz",
"integrity": "sha512-M3L9KqtdTyCzQK1LxTtp7QCucc75IA2vRwnYJA1gXMAxPC3SoEjUVmsk/oNFBSknmfADdViI5mFJtUXMCpJW1g==",
"peer": true,
"requires": {
"@koishijs/segment": "^1.1.1",
"cosmokit": "^1.1.1",
"reggol": "^1.0.1",
"schemastery": "^3.3.2",
"cosmokit": "^1.1.2",
"reggol": "^1.0.2",
"schemastery": "^3.3.3",
"supports-color": "^8.1.1"
}
},
......@@ -9773,18 +9773,18 @@
"peer": true
},
"cosmokit": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/cosmokit/-/cosmokit-1.1.1.tgz",
"integrity": "sha512-+f8x9pFGIc7I6HTObS90dq2K5YsI4U3Me4l9OminU9woVtF9Sv3CAHb5vKbFZ93XpTFctAQ6qAVSGjkGvGI9iw=="
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/cosmokit/-/cosmokit-1.1.2.tgz",
"integrity": "sha512-cSNrcyxZ3GT+tjSlUzWIzMiK7Wndq1Nm/2tlRhT65RXltSIcH5zaHdmnz1TnIhLuOViaO9qfSdnRPzxNkxMv0g=="
},
"cosmotype": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/cosmotype/-/cosmotype-1.0.3.tgz",
"integrity": "sha512-JykvyDjyjaDjycm8CcK8GD4Xt6/Glu4pJU9uJ5lsDuE5B5bdmAykiTPMHfs+Is8QUsNaDKpsHfxtxCUBDPYgdw==",
"version": "1.0.9",
"resolved": "https://registry.npmjs.org/cosmotype/-/cosmotype-1.0.9.tgz",
"integrity": "sha512-ot2m5LYBj9UNFvYpQNQ28hWYDG4GWmym094us2HNn6qgYzvALmjs4FxEVBsjA+VBnIf3ykuMGRYcex5cqZTvJQ==",
"peer": true,
"requires": {
"cosmokit": "^1.1.1",
"ns-require": "^1.1.0"
"cosmokit": "^1.1.2",
"ns-require": "^1.1.2"
}
},
"cosmotype-decorators": {
......@@ -11704,14 +11704,14 @@
}
},
"koishi": {
"version": "4.6.0",
"resolved": "https://registry.npmjs.org/koishi/-/koishi-4.6.0.tgz",
"integrity": "sha512-QhjFWTGhrFnYfpVg4dNNxgHER38zSij3nyM/RB3YrLTM4VwImVk5unpgg0QryViwWxSYM4zJ0YUoys4A9jgG6A==",
"version": "4.6.1",
"resolved": "https://registry.npmjs.org/koishi/-/koishi-4.6.1.tgz",
"integrity": "sha512-9NtcXrIKLN8AG9zEf3GzweSiHQubew0AWfjaci0grIxy760T77D8iLVsDbVhzmGSnc26WOR2q3CMFdRmE2igVA==",
"peer": true,
"requires": {
"@koa/router": "^10.1.1",
"@koishijs/core": "^4.6.0",
"@koishijs/utils": "^5.4.0",
"@koishijs/core": "^4.6.1",
"@koishijs/utils": "^5.4.1",
"@types/koa": "*",
"@types/koa__router": "*",
"@types/ws": "^8.5.3",
......@@ -11738,12 +11738,12 @@
}
},
"koishi-plugin-pics": {
"version": "9.0.0",
"resolved": "https://registry.npmjs.org/koishi-plugin-pics/-/koishi-plugin-pics-9.0.0.tgz",
"integrity": "sha512-oRbgqbTs2sZvER5+i6OeD6TYR4ttSC3BfQjXuGq5em1Itt9KPLkQ6ZXcZPYMdidFQokFDfBvCu8abA6IDZBLjQ==",
"version": "9.0.3",
"resolved": "https://registry.npmjs.org/koishi-plugin-pics/-/koishi-plugin-pics-9.0.3.tgz",
"integrity": "sha512-ZXzRJnGwg1W7dNRdmcaRyYFiGDFuOPq8qLh/Qer0Bk/dHVTW9tYZcdViXfA5TSe7sxluoB2koTRB8JvwPTnhVA==",
"peer": true,
"requires": {
"koishi-thirdeye": "^10.0.0",
"koishi-thirdeye": "^10.0.5",
"lodash": "^4.17.21"
}
},
......@@ -11998,9 +11998,9 @@
}
},
"ns-require": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/ns-require/-/ns-require-1.1.0.tgz",
"integrity": "sha512-Iw349zwWNgkGZjYJtruf+BXUe8YHOiMZE0iUNffvpt/A1yTSabTnpBMQ0zNl65G1LhpzwCo1KMCqjmJF0z8O6g==",
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/ns-require/-/ns-require-1.1.2.tgz",
"integrity": "sha512-GUF6I1hWDsGx1cA9FW27KIRAlkMel2UZagR39dVNPAPBgwWK1Ez0XB96WEz2OFcwHsCORI9h75dEZueHqZ/1pA==",
"peer": true
},
"nwsapi": {
......@@ -12431,12 +12431,12 @@
"dev": true
},
"reggol": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/reggol/-/reggol-1.0.1.tgz",
"integrity": "sha512-ZMOp3rZG6YQFVp/DC+BgFZaXSQcxHDayCmo7cL/kGujsSEoUzee0VJq1KCe9sgNt0qsM6JzkuSlj/+5SmmoO7Q==",
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/reggol/-/reggol-1.0.2.tgz",
"integrity": "sha512-BP7gx5nUBntWChG4x/yf7xLdpxy1R5PMtF/LJlOsz+XkWtip4YVNkQp2Flmio9hXSc2UxrwUyP0WrQ1M/FFWXw==",
"peer": true,
"requires": {
"cosmokit": "^1.1.0",
"cosmokit": "^1.1.2",
"supports-color": "^8.1.1"
}
},
......@@ -12547,12 +12547,12 @@
}
},
"schemastery": {
"version": "3.3.2",
"resolved": "https://registry.npmjs.org/schemastery/-/schemastery-3.3.2.tgz",
"integrity": "sha512-Z1C850OPtNEBs+D4QBPdC+Wu1t6Fn1BrOJILRHs2b+I/u61hUKP2vIPMAXFLvmmONnwqAW8ksPdCD6Zz9n8zhg==",
"version": "3.3.3",
"resolved": "https://registry.npmjs.org/schemastery/-/schemastery-3.3.3.tgz",
"integrity": "sha512-DwRsse6C+Qao90P/Bz+4G3gmAjM3he/VgHk3TykmEWv3KFqvwmqEn61SF3BPaTPP0L77a5Kc6q4+KQvdN1bBqA==",
"peer": true,
"requires": {
"cosmokit": "^1.1.0"
"cosmokit": "^1.1.2"
}
},
"schemastery-gen": {
......
......@@ -28,8 +28,8 @@
},
"homepage": "https://code.mycard.moe/3rdeye/koishi-plugin-picsource-yande",
"peerDependencies": {
"koishi": "^4.6.0",
"koishi-plugin-pics": "^9.0.0"
"koishi": "^4.6.1",
"koishi-plugin-pics": "^9.0.3"
},
"dependencies": {
"koishi-thirdeye": "^10.0.5"
......
......@@ -3,7 +3,7 @@ import { DefineSchema, RegisterSchema } from 'koishi-thirdeye';
import { PicSourceConfig } from 'koishi-plugin-pics';
@RegisterSchema()
export class InstanceConfig extends PicSourceConfig {
export class PicSourceYandePluginConfig extends PicSourceConfig {
@DefineSchema({
description:
'网站 post.json 的地址。如果使用 Konachan 则可以使用 `https://konachan.com/post.json` 。',
......@@ -18,22 +18,3 @@ export class InstanceConfig extends PicSourceConfig {
@DefineSchema({ description: '使用原始图而不是 sample 图。', default: true })
useOriginal: boolean;
}
@RegisterSchema()
export class PicSourceYandePluginConfig {
constructor(config: PicSourceYandePluginConfigLike) {}
@DefineSchema({
description: '实例列表。',
type: InstanceConfig,
default: [
{ name: 'yande', url: 'https://yande.re/post.json' },
{ name: 'konachan', url: 'https://konachan.com/post.json' },
],
})
instances: InstanceConfig[];
}
export interface PicSourceYandePluginConfigLike {
instances: Partial<InstanceConfig>[];
}
// import 'source-map-support/register';
import { InstanceConfig, PicSourceYandePluginConfig, PicSourceYandePluginConfigLike } from './config';
import {
DefinePlugin,
BasePlugin,
Inject,
LifecycleEvents,
} from 'koishi-thirdeye';
import PicsContainer, { PicSource } from 'koishi-plugin-pics';
import { Context, Random } from 'koishi';
import { PicSourceYandePluginConfig } from './config';
import { DefinePlugin, Inject } from 'koishi-thirdeye';
import { DefineMultiSourcePlugin, PicSourcePlugin } from 'koishi-plugin-pics';
import { Random, Quester } from 'koishi';
import { PicInfo } from './def';
export * from './config';
export class PicSourceInstance extends PicSource {
constructor(ctx: Context, private config: InstanceConfig) {
super(ctx);
config.applyTo(this);
}
@DefinePlugin({ name: 'picsource-yande', schema: PicSourceYandePluginConfig })
export class PicSourceYande extends PicSourcePlugin<PicSourceYandePluginConfig> {
@Inject(true)
private http: Quester;
private page = 1;
private nextPage() {
......@@ -30,7 +24,7 @@ export class PicSourceInstance extends PicSource {
async randomPic(picTags: string[]) {
const page = this.nextPage();
const data = await this.ctx.http.get<PicInfo[]>(this.config.endpoint, {
const data = await this.http.get<PicInfo[]>(this.config.endpoint, {
params: {
tags: picTags.length ? picTags.join('+') : undefined,
limit: 1000,
......@@ -61,17 +55,7 @@ export class PicSourceInstance extends PicSource {
}
}
@DefinePlugin({ name: 'picsource-yande', schema: PicSourceYandePluginConfig })
export default class PicSourceYandePlugin
extends BasePlugin<PicSourceYandePluginConfig, PicSourceYandePluginConfigLike>
implements LifecycleEvents
{
@Inject(true)
private pics: PicsContainer;
onApply() {
for (const instanceConfig of this.config.instances) {
this.pics.addSource(new PicSourceInstance(this.ctx, instanceConfig));
}
}
}
export default class PicSourceYandePlugin extends DefineMultiSourcePlugin(
PicSourceYande,
PicSourceYandePluginConfig,
) {}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment