Commit d6118002 authored by nanahira's avatar nanahira

bump

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