Commit 818c3bc3 authored by Maiko Sinkyaet Tan's avatar Maiko Sinkyaet Tan Committed by GitHub

Merge master

parents e17ed426 547632df
Pipeline #11433 failed with stage
in 1 minute and 3 seconds
......@@ -77,15 +77,16 @@ plugins:
### 获取随机图片
```text
pic
pic [...tags:string]
获取随机图片
从各个图源中随机获取一张随机图片。图源可以用 pic.sources 查询。参数均为可选。
可用的选项有:
-s, --source <source> 指定图源,逗号分隔。图源可以用 ${this.config.commandName}.sources 查询。
-t, --tag <tag> 需要查询的图片标签,逗号分隔。
使用示例:
pic -s pixiv -t yuyuko 从 pixiv 图源中获取一张具有 yuyuko 标签的图。
pic 获取一张随机图片。
pic yuyuko 获取一张 yuyuko 标签的图片。
pic -s yande 获取一张 yande 图源的图片。
pic -s yande yuyuko saigyouji 从 yande 图源中获取一张具有 yuyuko 以及 saigyouji 标签的图。
可用的子指令有:
pic.sources 查询图源列表
```
......@@ -96,10 +97,10 @@ pic.sources 查询图源列表
pic.sources
查询图源列表
图源标签可用于图片获取的图源筛选。
可用的选项有:
-s, --source <source> 要查询的图源标签,逗号分隔。
使用示例:
pic.sources 查询全部的图源。 pic -s pixiv 查询含有 pixiv 标签的图源。
pic.sources 查询全部的图源。
pic pixiv 查询含有 pixiv 标签的图源。
```
## 配置
......
This diff is collapsed.
{
"name": "koishi-plugin-pics",
"description": "Koishi 的随机图片插件",
"version": "8.6.10",
"version": "8.7.3",
"main": "dist/index.js",
"types": "dist/src/index.d.ts",
"scripts": {
......@@ -29,13 +29,13 @@
},
"homepage": "https://github.com/koishijs/koishi-plugin-pics",
"dependencies": {
"koishi-thirdeye": "^9.2.14",
"koishi-thirdeye": "^9.2.18",
"lodash": "^4.17.21"
},
"devDependencies": {
"@koishijs/plugin-cache-lru": "^1.0.0-rc.0",
"@koishijs/plugin-console": "^3.1.2",
"@koishijs/plugin-database-memory": "^1.0.2",
"@koishijs/plugin-console": "^3.2.4",
"@koishijs/plugin-database-memory": "^1.1.0",
"@koishijs/plugin-sandbox": "^1.0.2",
"@types/jest": "^27.4.0",
"@types/lodash": "^4.14.176",
......@@ -57,7 +57,7 @@
"ws": "^8.3.0"
},
"peerDependencies": {
"koishi": "^4.4.2"
"koishi": "^4.5.0"
},
"jest": {
"moduleFileExtensions": [
......
......@@ -24,7 +24,7 @@ export interface PicSourceInfo {
}
export class PicSourceConfig implements PicSourceInfo {
constructor(config: PicSourceInfo) {}
constructor(config: Partial<PicSourceInfo>) {}
@DefineSchema({ type: 'string', default: [], description: '图源标签' })
tags: string[];
......
......@@ -216,12 +216,17 @@ export default class PicsContainer
'source',
`-s <source:string> 指定图源,逗号分隔。图源可以用 ${this.config.commandName}.sources 查询。`,
)
.example(`${this.config.commandName} 获取一张随机图片。`)
.example(`${this.config.commandName} yuyuko 获取一张 yuyuko 标签的图片。`)
.example(
`${this.config.commandName} yuyuko -s yande 从 yande 图源中获取一张具有 yuyuko 标签的图。`,
`${this.config.commandName} -s yande 获取一张 yande 图源的图片。`,
)
.example(
`${this.config.commandName} -s yande yuyuko saigyouji 从 yande 图源中获取一张具有 yuyuko 以及 saigyouji 标签的图。`,
)
.action(async (argv, ...picTags) => {
const sourceTags = argv.options.source
? argv.options.source.split(/[,+\uFF0C\uFF0B\u3001]/)
? argv.options.source.split(/[ ,+\uFF0C\uFF0B\u3001]/)
: [];
picTags ||= [];
const result = await this.randomPic(picTags, sourceTags);
......@@ -247,10 +252,8 @@ export default class PicsContainer
.subcommand('.sources [...tags:string]', '查询图源列表')
// .option('source', '-s <source:string> 要查询的图源标签,逗号分隔。')
.usage('图源标签可用于图片获取的图源筛选。')
.example(`${this.config.commandName}.sources 查询全部的图源`)
.example(
`${this.config.commandName} -s pixiv 查询含有 pixiv 标签的图源。`,
)
.example(`${this.config.commandName}.sources 查询全部的图源。`)
.example(`${this.config.commandName} pixiv 查询含有 pixiv 标签的图源。`)
.action(async (argv, ...sourceTags) => {
sourceTags ||= [];
const sources = this.pickAvailableSources(sourceTags, true);
......
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