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",
"description": "Koishi plugin market information",
"version": "1.1.5",
"version": "1.2.0",
"main": "lib/index.js",
"typings": "lib/index.d.ts",
"files": [

View File

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

View File

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