feat: support plugin detail

This commit is contained in:
Shigma 2023-04-07 23:34:35 +08:00
parent d5d08d040b
commit eec3db2b86
No known key found for this signature in database
GPG Key ID: 414458B84ACF8744
3 changed files with 15 additions and 5 deletions

View File

@ -1,7 +1,7 @@
{ {
"name": "koishi-plugin-market-info", "name": "koishi-plugin-market-info",
"description": "Koishi plugin market information", "description": "Koishi plugin market information",
"version": "1.1.5", "version": "1.2.0",
"main": "lib/index.js", "main": "lib/index.js",
"typings": "lib/index.d.ts", "typings": "lib/index.d.ts",
"files": [ "files": [

View File

@ -57,10 +57,16 @@ export function apply(ctx: Context, config: Config) {
ctx.on('ready', async () => { ctx.on('ready', async () => {
let previous = await getMarket() let previous = await getMarket()
ctx.command('market') ctx.command('market [name]')
.action(async ({ session }) => { .action(async ({ session }, name) => {
const objects = Object.values(previous).filter(data => !data.manifest.hidden) if (!name) {
return session.text('.overview', [objects.length]) const objects = Object.values(previous).filter(data => !data.manifest.hidden)
return session.text('.overview', [objects.length])
}
const data = previous[name]
if (!data) return session.text('.not-found', [name])
return session.text('.detail', data)
}) })
ctx.setInterval(async () => { ctx.setInterval(async () => {

View File

@ -4,6 +4,10 @@ commands:
messages: messages:
overview: 当前共有 {0} 个插件。 overview: 当前共有 {0} 个插件。
not-found: 未找到插件 {0}。
detail: |-
{name} ({version})
{manifest.description.zh || manifest.description.en}
market-info: market-info:
header: '[插件市场更新]' header: '[插件市场更新]'