diff --git a/docs/.vitepress/config/de-DE.json b/docs/.vitepress/config/de-DE.json new file mode 100644 index 000000000..688491ebd --- /dev/null +++ b/docs/.vitepress/config/de-DE.json @@ -0,0 +1,132 @@ +{ + "description": "Bildersuche", + "head": [ + [ + "link", + { + "rel": "icon", + "href": "https://koishi.chat/logo.png" + } + ], + [ + "link", + { + "rel": "manifest", + "href": "/manifest/de-DE.json" + } + ], + [ + "meta", + { + "name": "theme-color", + "content": "#5546a3" + } + ] + ], + "themeConfig": { + "editLink": { + "text": "Übersetzen dieser Seite auf Crowdin", + "pattern": "https://crowdin.com/translate/koishi/:id/zhcn-de" + }, + "sidebar": { + "/": [ + { + "text": "指南", + "items": [ + { + "text": "介绍", + "link": "/" + }, + { + "text": "使用", + "link": "/usage" + }, + { + "text": "配置项", + "link": "/config" + } + ] + }, + { + "text": "插件", + "items": [ + { + "text": "Danbooru", + "link": "/plugins/danbooru" + }, + { + "text": "e621", + "link": "/plugins/e621" + }, + { + "text": "Gelbooru", + "link": "/plugins/gelbooru" + }, + { + "text": "Konachan", + "link": "/plugins/konachan" + }, + { + "text": "Lolibooru", + "link": "/plugins/lolibooru" + }, + { + "text": "Lolicon", + "link": "/plugins/lolicon" + }, + { + "text": "Local", + "link": "/plugins/local" + }, + { + "text": "Pixiv", + "link": "/plugins/pixiv" + }, + { + "text": "Safebooru", + "link": "/plugins/safebooru" + }, + { + "text": "Sankaku", + "link": "/plugins/sankaku" + }, + { + "text": "Yande", + "link": "/plugins/yande" + } + ] + }, + { + "text": "Entwicklung", + "items": [ + { + "text": "图源", + "link": "/develop/source" + }, + { + "text": "服务", + "link": "/develop/service" + }, + { + "text": "API", + "link": "/develop/api" + } + ] + }, + { + "text": "Mehr", + "items": [ + { + "text": "Koishi 官网", + "link": "https://koishi.chat" + }, + { + "text": "爱发电:@迷子", + "link": "https://afdian.net/a/ff14_hamster" + } + ] + } + ] + } + } +} \ No newline at end of file diff --git a/docs/.vitepress/config/en-US.json b/docs/.vitepress/config/en-US.json new file mode 100644 index 000000000..f21e37dfc --- /dev/null +++ b/docs/.vitepress/config/en-US.json @@ -0,0 +1,132 @@ +{ + "description": "A lot of image galleries, whatever you want.", + "head": [ + [ + "link", + { + "rel": "icon", + "href": "https://koishi.chat/logo.png" + } + ], + [ + "link", + { + "rel": "manifest", + "href": "/manifest/en-US.json" + } + ], + [ + "meta", + { + "name": "theme-color", + "content": "#5546a3" + } + ] + ], + "themeConfig": { + "editLink": { + "text": "Translate this page on Crowdin", + "pattern": "https://crowdin.com/translate/koishi/:id/zhcn-enus" + }, + "sidebar": { + "/": [ + { + "text": "Developing Guide", + "items": [ + { + "text": "Introduction", + "link": "/" + }, + { + "text": "Usage", + "link": "/usage" + }, + { + "text": "配置项", + "link": "/config" + } + ] + }, + { + "text": "Plugins", + "items": [ + { + "text": "Danbooru", + "link": "/plugins/danbooru" + }, + { + "text": "e621", + "link": "/plugins/e621" + }, + { + "text": "Gelbooru", + "link": "/plugins/gelbooru" + }, + { + "text": "Konachan", + "link": "/plugins/konachan" + }, + { + "text": "Lolibooru", + "link": "/plugins/lolibooru" + }, + { + "text": "Lolicon", + "link": "/plugins/lolicon" + }, + { + "text": "Local", + "link": "/plugins/local" + }, + { + "text": "Pixiv", + "link": "/plugins/pixiv" + }, + { + "text": "Safebooru", + "link": "/plugins/safebooru" + }, + { + "text": "Sankaku", + "link": "/plugins/sankaku" + }, + { + "text": "Yande", + "link": "/plugins/yande" + } + ] + }, + { + "text": "Develop", + "items": [ + { + "text": "图源", + "link": "/develop/source" + }, + { + "text": "service", + "link": "/develop/service" + }, + { + "text": "API", + "link": "/develop/api" + } + ] + }, + { + "text": "More", + "items": [ + { + "text": "Koishi 官网", + "link": "https://koishi.chat" + }, + { + "text": "爱发电:@迷子", + "link": "https://afdian.net/a/ff14_hamster" + } + ] + } + ] + } + } +} \ No newline at end of file diff --git a/docs/.vitepress/config/fr-FR.json b/docs/.vitepress/config/fr-FR.json new file mode 100644 index 000000000..37ddbdb71 --- /dev/null +++ b/docs/.vitepress/config/fr-FR.json @@ -0,0 +1,132 @@ +{ + "description": "Recherche des images, c'est très bien !", + "head": [ + [ + "link", + { + "rel": "icon", + "href": "https://koishi.chat/logo.png" + } + ], + [ + "link", + { + "rel": "manifest", + "href": "/manifest/fr-FR.json" + } + ], + [ + "meta", + { + "name": "theme-color", + "content": "#5546a3" + } + ] + ], + "themeConfig": { + "editLink": { + "text": "Traduire cette page sur Crowdin", + "pattern": "https://crowdin.com/translate/koishi/:id/zhcn-fr" + }, + "sidebar": { + "/": [ + { + "text": "指南", + "items": [ + { + "text": "Introduction", + "link": "/" + }, + { + "text": "Utilisation", + "link": "/usage" + }, + { + "text": "配置项", + "link": "/config" + } + ] + }, + { + "text": "plugin", + "items": [ + { + "text": "Danbooru", + "link": "/plugins/danbooru" + }, + { + "text": "e621", + "link": "/plugins/e621" + }, + { + "text": "Gelbooru", + "link": "/plugins/gelbooru" + }, + { + "text": "Konachan", + "link": "/plugins/konachan" + }, + { + "text": "Lolibooru", + "link": "/plugins/lolibooru" + }, + { + "text": "Lolicon", + "link": "/plugins/lolicon" + }, + { + "text": "Local", + "link": "/plugins/local" + }, + { + "text": "Pixiv", + "link": "/plugins/pixiv" + }, + { + "text": "Safebooru", + "link": "/plugins/safebooru" + }, + { + "text": "Sankaku", + "link": "/plugins/sankaku" + }, + { + "text": "Yande", + "link": "/plugins/yande" + } + ] + }, + { + "text": "Développement", + "items": [ + { + "text": "图源", + "link": "/develop/source" + }, + { + "text": "service", + "link": "/develop/service" + }, + { + "text": "API", + "link": "/develop/api" + } + ] + }, + { + "text": "À propos", + "items": [ + { + "text": "Koishi 官网", + "link": "https://koishi.chat" + }, + { + "text": "爱发电:@迷子", + "link": "https://afdian.net/a/ff14_hamster" + } + ] + } + ] + } + } +} \ No newline at end of file diff --git a/docs/.vitepress/config/ja-JP.json b/docs/.vitepress/config/ja-JP.json new file mode 100644 index 000000000..ffb5038f7 --- /dev/null +++ b/docs/.vitepress/config/ja-JP.json @@ -0,0 +1,132 @@ +{ + "description": "最高な画像検索プラグイン!", + "head": [ + [ + "link", + { + "rel": "icon", + "href": "https://koishi.chat/logo.png" + } + ], + [ + "link", + { + "rel": "manifest", + "href": "/manifest/ja-JP.json" + } + ], + [ + "meta", + { + "name": "theme-color", + "content": "#5546a3" + } + ] + ], + "themeConfig": { + "editLink": { + "text": "Crowdin でこのページを翻訳する", + "pattern": "https://crowdin.com/translate/koishi/:id/zhcn-ja" + }, + "sidebar": { + "/": [ + { + "text": "指南", + "items": [ + { + "text": "介绍", + "link": "/" + }, + { + "text": "使用", + "link": "/usage" + }, + { + "text": "配置项", + "link": "/config" + } + ] + }, + { + "text": "プラグイン", + "items": [ + { + "text": "Danbooru", + "link": "/plugins/danbooru" + }, + { + "text": "e621", + "link": "/plugins/e621" + }, + { + "text": "Gelbooru", + "link": "/plugins/gelbooru" + }, + { + "text": "Konachan", + "link": "/plugins/konachan" + }, + { + "text": "Lolibooru", + "link": "/plugins/lolibooru" + }, + { + "text": "Lolicon", + "link": "/plugins/lolicon" + }, + { + "text": "Local", + "link": "/plugins/local" + }, + { + "text": "Pixiv", + "link": "/plugins/pixiv" + }, + { + "text": "Safebooru", + "link": "/plugins/safebooru" + }, + { + "text": "Sankaku", + "link": "/plugins/sankaku" + }, + { + "text": "Yande", + "link": "/plugins/yande" + } + ] + }, + { + "text": "開発", + "items": [ + { + "text": "图源", + "link": "/develop/source" + }, + { + "text": "Service", + "link": "/develop/service" + }, + { + "text": "API", + "link": "/develop/api" + } + ] + }, + { + "text": "さらに表示", + "items": [ + { + "text": "Koishi 官网", + "link": "https://koishi.chat" + }, + { + "text": "爱发电:@迷子", + "link": "https://afdian.net/a/ff14_hamster" + } + ] + } + ] + } + } +} \ No newline at end of file diff --git a/docs/.vitepress/config/ru-RU.json b/docs/.vitepress/config/ru-RU.json new file mode 100644 index 000000000..008dca4e9 --- /dev/null +++ b/docs/.vitepress/config/ru-RU.json @@ -0,0 +1,132 @@ +{ + "description": "Вы хотите немного рисунок?", + "head": [ + [ + "link", + { + "rel": "icon", + "href": "https://koishi.chat/logo.png" + } + ], + [ + "link", + { + "rel": "manifest", + "href": "/manifest/ru-RU.json" + } + ], + [ + "meta", + { + "name": "theme-color", + "content": "#5546a3" + } + ] + ], + "themeConfig": { + "editLink": { + "text": "在 GitHub 编辑此页面", + "pattern": "https://crowdin.com/translate/koishi/:id/zhcn-ru" + }, + "sidebar": { + "/": [ + { + "text": "指南", + "items": [ + { + "text": "介绍", + "link": "/" + }, + { + "text": "使用", + "link": "/usage" + }, + { + "text": "配置项", + "link": "/config" + } + ] + }, + { + "text": "插件", + "items": [ + { + "text": "Danbooru", + "link": "/plugins/danbooru" + }, + { + "text": "e621", + "link": "/plugins/e621" + }, + { + "text": "Gelbooru", + "link": "/plugins/gelbooru" + }, + { + "text": "Konachan", + "link": "/plugins/konachan" + }, + { + "text": "Lolibooru", + "link": "/plugins/lolibooru" + }, + { + "text": "Lolicon", + "link": "/plugins/lolicon" + }, + { + "text": "Local", + "link": "/plugins/local" + }, + { + "text": "Pixiv", + "link": "/plugins/pixiv" + }, + { + "text": "Safebooru", + "link": "/plugins/safebooru" + }, + { + "text": "Sankaku", + "link": "/plugins/sankaku" + }, + { + "text": "Yande", + "link": "/plugins/yande" + } + ] + }, + { + "text": "开发", + "items": [ + { + "text": "图源", + "link": "/develop/source" + }, + { + "text": "服务", + "link": "/develop/service" + }, + { + "text": "API", + "link": "/develop/api" + } + ] + }, + { + "text": "更多", + "items": [ + { + "text": "Koishi 官网", + "link": "https://koishi.chat" + }, + { + "text": "爱发电:@迷子", + "link": "https://afdian.net/a/ff14_hamster" + } + ] + } + ] + } + } +} \ No newline at end of file diff --git a/docs/.vitepress/config/zh-TW.json b/docs/.vitepress/config/zh-TW.json new file mode 100644 index 000000000..f4ecf72a4 --- /dev/null +++ b/docs/.vitepress/config/zh-TW.json @@ -0,0 +1,132 @@ +{ + "description": "最好的圖像檢索外掛程式!", + "head": [ + [ + "link", + { + "rel": "icon", + "href": "https://koishi.chat/logo.png" + } + ], + [ + "link", + { + "rel": "manifest", + "href": "/manifest/zh-TW.json" + } + ], + [ + "meta", + { + "name": "theme-color", + "content": "#5546a3" + } + ] + ], + "themeConfig": { + "editLink": { + "text": "在 Crowdin 上翻譯此頁面", + "pattern": "https://crowdin.com/translate/koishi/:id/zhcn-zhtw" + }, + "sidebar": { + "/": [ + { + "text": "指南", + "items": [ + { + "text": "介紹", + "link": "/" + }, + { + "text": "使用", + "link": "/usage" + }, + { + "text": "配置项", + "link": "/config" + } + ] + }, + { + "text": "插件", + "items": [ + { + "text": "Danbooru", + "link": "/plugins/danbooru" + }, + { + "text": "e621", + "link": "/plugins/e621" + }, + { + "text": "Gelbooru", + "link": "/plugins/gelbooru" + }, + { + "text": "Konachan", + "link": "/plugins/konachan" + }, + { + "text": "Lolibooru", + "link": "/plugins/lolibooru" + }, + { + "text": "Lolicon", + "link": "/plugins/lolicon" + }, + { + "text": "Local", + "link": "/plugins/local" + }, + { + "text": "Pixiv", + "link": "/plugins/pixiv" + }, + { + "text": "Safebooru", + "link": "/plugins/safebooru" + }, + { + "text": "Sankaku", + "link": "/plugins/sankaku" + }, + { + "text": "Yande", + "link": "/plugins/yande" + } + ] + }, + { + "text": "開發", + "items": [ + { + "text": "图源", + "link": "/develop/source" + }, + { + "text": "服务", + "link": "/develop/service" + }, + { + "text": "API", + "link": "/develop/api" + } + ] + }, + { + "text": "更多", + "items": [ + { + "text": "Koishi 官网", + "link": "https://koishi.chat" + }, + { + "text": "爱发电:@迷子", + "link": "https://afdian.net/a/ff14_hamster" + } + ] + } + ] + } + } +} \ No newline at end of file diff --git a/docs/de-DE/config.md b/docs/de-DE/config.md new file mode 100644 index 000000000..7c4764e83 --- /dev/null +++ b/docs/de-DE/config.md @@ -0,0 +1,56 @@ +# 配置项 + +## 搜索设置 + +### detectLanguage + +- 类型: `boolean` +- 默认值: `false` + +是否自动检测语言。 + +当启用此选项时,插件会自动检测输入的 tag 的语言,并选择提供了相应语言支持的图源进行检索。 + +### confidence + +- 类型: `number` +- 默认值: `0.5` + +当 `detectLanguage` 启用时,此选项用于设置语言检测的置信度阈值。 + +### maxCount + +- 类型: `number` +- 默认值: `10` + +设置全局检索允许的最大图片数量。 + +## 输出设置 + +## output + +- 类型: `enum` +- 可选值:`仅发送图片`、`发送图片和相关信息`、`发送图片、相关信息和链接`、`发送全部信息` +- 默认值: `发送图片和相关信息` + +设置输出的信息。 + +## 图源全局设置 + +:::tip +此项设置存在于图源插件中而非全局设置里,因此可以针对不同的图源设置不同的配置。 +::: + +### label + +- 类型: `string` +- 默认值: `图源名称` + +图源标签,可用于在指令中手动指定图源。 + +### weight + +- 类型: `number` +- 默认值: `1` + +图源权重。在多个符合标签的图源中,将按照各自的权重随机选择。 diff --git a/docs/de-DE/develop/api.md b/docs/de-DE/develop/api.md new file mode 100644 index 000000000..19a54b603 --- /dev/null +++ b/docs/de-DE/develop/api.md @@ -0,0 +1,80 @@ +# API + +## 服务方法 + +### `ctx.booru.register()` + +```ts +ctx.booru.register(source: ImageSource): () => boolean +``` + +注册一个图源,返回一个 dispose 函数,调用此函数可以注销此图源。 + +### `ctx.booru.hasSource()` + +```ts +ctx.booru.hasSource(name?: string): boolean +``` + +当不传入参数时,判断是否存在激活的图源;当传入参数时,判断是否存在指定名称的图源。 + +### `ctx.booru.get()` + +```ts +ctx.booru.get(query: ImageService.Query): Promise +``` + +获取符合条件的图片,返回一个 Promise,resolve 时返回一个图片数组。 + +当 `query.tags` 为空时,应当返回随机的图片。 + +当获取不到图片时,应当返回 `undefined`。 + +## 类型定义 + +### `ImageSource` + +```ts +export abstract class ImageSource { + languages: string[] = ['en'] // 图源支持的语言 + + constructor(public ctx: Context, public config: Config) { + this.ctx.booru.register(this) + } + + // 对标签进行分词,返回一个标签数组 + tokenize(query: string): string[] + + // 获取图片 + abstract get(query: ImageSource.Query): Promise +} +``` + + +### `ImageSource.Query` + +```ts +export interface Query { + tags: string[] + /** raw query */ + raw: string + count: number +} +``` + +### `ImageSource.Result` + +```ts +export type NsfwType = 'furry' | 'guro' | 'shota' | 'bl' + +export interface Result { + url: string + pageUrl?: string + author?: string + authorUrl?: string + title?: string + desc?: string + tags?: string[] + nsfw?: boolean | NsfwType +} +``` diff --git a/docs/de-DE/develop/service.md b/docs/de-DE/develop/service.md new file mode 100644 index 000000000..6378cbc2d --- /dev/null +++ b/docs/de-DE/develop/service.md @@ -0,0 +1,65 @@ +# 服务 + +`booru` 插件会注册名为 `booru` 的服务,可以被其他插件调用。 + +## 检测图源 + +`booru` 服务提供了 `hasSource()` 方法,可以用于判断是否存在任意图源,或是否存在指定的图源。 + +```ts +import { Context } from 'koishi' + +export function apply(ctx: Context) { + ctx.booru.hasSource() // 是否存在任意图源 + ctx.boooru.hasSource('pixiv') // 是否存在 pixiv 图源 +} +``` + +## 获取图片 + +`booru` 服务提供了 `get()` 方法,可以用于获取图片。 + +```tsx +import { Context } from 'koishi' + +export function apply(ctx: Context) { + ctx.command('恋恋最可爱').action(async () => { + const image = await ctx.booru.get({ tags: 'komeiji koishi', raw: 'komeiji koishi', count: 1 }) + return + }) +} +``` + + +恋恋最可爱 + + + + + + +
+
+
+ +## 注册图源 + +`booru` 服务提供了 `register()` 方法,可以用于注册图源。 + +```ts +import { Context } from 'koishi' + +class PixivSource extends ImageSource { + name = 'pixiv' + async get(query) { + // ... + } +} + +export function apply(ctx: Context, config: Config) { + // 注册图源 + const dispose = ctx.booru.register(new PixivSource(ctx, config)) + // 注销图源 + dispose() +} +``` diff --git a/docs/de-DE/develop/source.md b/docs/de-DE/develop/source.md new file mode 100644 index 000000000..ec6a62d59 --- /dev/null +++ b/docs/de-DE/develop/source.md @@ -0,0 +1,98 @@ +# 图源 + +## 介绍 + +图源插件是用于获取图片的插件,它可以从网络、本地文件、剪贴板、数据库等地方获取图片。 + +由于图源插件本身也是一个标准的 [Koishi 插件](https://koishi.chat/zh-CN/guide/plugin/#%E6%8F%92%E4%BB%B6%E7%9A%84%E5%9F%BA%E6%9C%AC%E5%BD%A2%E5%BC%8F),这意味着它必须导出一个函数,或者一个带有 `apply` 方法的对象。为了方便开发,我们提供了一个抽象类 `ImageSource`,当你继承它并实现相应方法后以默认方式导出,就可以作为 Koishi 插件被加载,这有助于插件作者快速开发图源插件。 + +## 准备工作 + +在此,我们将假设你已经阅读了[认识插件](https://koishi.chat/zh-CN/guide/plugin/),并且配置好了 Koishi 插件的开发环境。 + +图源插件需要继承的 `ImageSource` 类定义在 `koishi-plugin-booru` 包中,因此你需要将 `koishi-plugin-booru` 插件列为你的图源插件的对等依赖 (peerDependencies)。 + +```json +{ + "peerDependencies": { + "booru": "^1.0.3" + } +} +``` + +**请根据你所需求的功能酌情升级对等依赖的 booru 插件的版本** + +## 开发图源插件 + +此处以简化版的 `lolicon` 插件为例,可以从 `https://api.lolicon.net/` 的 API 获取图片及元信息。 + +```ts +import { Context, Schema } from 'koishi' +import { ImageSource } from 'koishi-plugin-booru' + +class LoliconImageSource extends ImageSource { + // 定义图源支持的语言 + // 如 lolicon 支持日语、英语和汉语-简体中文等 + languages: string[] = ['en', 'zh-CN', 'ja'] + + constructor(ctx: Context, config: LoliconImageSource.Config) { + // 调用父类的拟构函数以注册图源 + super(ctx, config) + } + + // `booru` 默认将标签转换为类 `danbooru` 的形式,即「空格分割标签,下划线替代空格」。 + // 而 lolicon 支持的标签不带空格,因此此处需要将其重载为空格分割。 + override tokenize(query: string): string[] { + return query.split(/\s+/) + } + + async get(query: ImageSource.Query): Promise { + const param = { + // `tags` 是一个字符串数组,根据 Lolicon API 的文档,传入数组等于「与」操作。 + tag: query.tags, + // 指定获取数量 + num: query.count, + } + // 注:根据图源设计规范,当 `query.tags` 为空数组或空时,应当返回随机图片。 + // 由于 Lolicon API 默认对空标签会返回随机图,因此不需要做特别处理, + // 但对于其他图源可能需要传入特别的参数才能使用随机图片功能。 + const resp = await this.ctx.http.post('https://api.lolicon.app/setu/v2', param) + + if (!Array.isArray(resp.data)) { + return + } + + // 返回类型为 `Result` 的数组,可用字段可参考类型提示。 + // 其中 `url` 字段是图片的地址,也可以是 `base64` 编码。 + return resp.data.map((setu) => { + return { + url: setu.urls.original, + title: setu.title, + author: setu.author, + nsfw: setu.r18, + tags: setu.tags, + pageUrl: `https://pixiv.net/i/${setu.pid}`, + } + }) + } +} + +// 图源插件还需要导出配置项,因此我们采用 TypeScript 的 namespace +// 将配置项 Config 与上面的 class 定义合并。 +namespace LoliconImageSource { + export interface Config extends ImageSource.Config {} + + export const Config: Schema = Schema.intersect([ + // 结合使用 `Svchema.intersect` 和 `createSchema` 辅助函数, + // 向图源插件的配置项里添加全局的通用配置,`label` 一般为图源插件名。 + ImageSource.createSchema({ label: 'lolicon' }), + ]) +} + +// 以默认导出方式导出整个命名空间 +export default LoliconImageSource +``` + +:::tip +上述代码为介绍与解释 `booru` 图源的开发步骤有一定简化,你可以直接在 [GitHub](https://github.com/koishijs/koishi-plugin-booru/tree/main/packages/lolicon) 上阅读 lolicon 插件真正的源码。 +::: diff --git a/docs/de-DE/index.md b/docs/de-DE/index.md new file mode 100644 index 000000000..8afc8f7b8 --- /dev/null +++ b/docs/de-DE/index.md @@ -0,0 +1,35 @@ +# 介绍 + +> 「最好的涩图插件!」 —— Shigma + +Booru 是一个基于 [Koishi](https://koishi.chat/) 的图片检索插件,支持多个图源站点。 + +:::tip +你需要安装至少一个图源插件才能使用 Booru 插件。 +::: + +## 特性 + +- 支持多个[图源站点](#图源插件) +- 支持多种发送方式 +- 支持随机检索 + +## 图源插件 + +Booru 插件支持多个图源站点,每个图源站点都有一个对应的插件。目前支持的图源站点有: + +| 图源 | 插件 | +| -------------------------------------------------- | --------------------------------------------------------- | +| [Danbooru](https://danbooru.donmai.us/) | [`koishi-plugin-booru-danbooru`](./plugins/danbooru.md) | +| [e621](https://e621.net/) | [`koishi-plugin-booru-e621`](./plugins/e621.md) | +| [e926](https://e926.net/) | [`koishi-plugin-booru-e621`](./plugins/e621.md) | +| [Gelbooru](https://gelbooru.com/) | [`koishi-plugin-booru-gelbooru`](./plugins/gelbooru.md) | +| [Konachan](https://konachan.com/) | [`koishi-plugin-booru-konachan`](./plugins/konachan.md) | +| [Konachan.net](https://konachan.net/) | [`koishi-plugin-booru-konachan`](./plugins/konachan.md) | +| [Lolibooru](https://lolibooru.moe/) | [`koishi-plugin-booru-lolibooru`](./plugins/lolibooru.md) | +| [Lolicon](https://lolicon.app/) | [`koishi-plugin-booru-lolicon`](./plugins/lolicon.md) | +| [Pixiv](https://www.pixiv.net/) | [`koishi-plugin-booru-pixiv`](./plugins/pixiv.md) | +| [Safebooru](https://safebooru.org/) | [`koishi-plugin-booru-safebooru`](./plugins/safebooru.md) | +| [SankakuComplex](https://chan.sankakucomplex.com/) | [`koishi-plugin-booru-sankaku`](./plugins/sankaku.md) | +| [Yande.re](https://yande.re/) | [`koishi-plugin-booru-yande`](./plugins/yande.md) | +| 本地文件夹 | [`koishi-plugin-booru-local`](./plugins/local.md) | diff --git a/docs/de-DE/plugins/danbooru.md b/docs/de-DE/plugins/danbooru.md new file mode 100644 index 000000000..cbab7a233 --- /dev/null +++ b/docs/de-DE/plugins/danbooru.md @@ -0,0 +1,24 @@ +# koishi-plugin-booru-danbooru + +## Installation + +1. 在 Koishi 中下载并安装本插件,若你还未安装 [Booru 插件](../index.md),请先安装。 + +## 配置项 + +### 全局设置 + +:::tip +此处的配置项可参考[图源全局设置](../config#图源全局设置) +::: + +### 搜索设置 + +
+ +#### endpoint + +- 类型:`string` +- 默认值:`https://danbooru.donmai.us` + +Danbooru 的 API 地址。 diff --git a/docs/de-DE/plugins/e621.md b/docs/de-DE/plugins/e621.md new file mode 100644 index 000000000..af46a4794 --- /dev/null +++ b/docs/de-DE/plugins/e621.md @@ -0,0 +1,31 @@ +# koishi-plugin-booru-e621 + +## Installation + +1. 在 Koishi 中下载并安装本插件,若你还未安装 [Booru 插件](../index.md),请先安装。 + +## 配置项 + +### 全局设置 + +:::tip +此处的配置项可参考[图源全局设置](../config#图源全局设置) +::: + +### 搜索设置 + +
+ +#### userAgent + +- 类型:`string` +- 默认值:`Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36 Edg/114.0.1823.37` + +请求时所使用的 User-Agent + +#### endpoint + +- 类型:`string` +- 默认值:`https://e621.net` + +e621/e926 的 API 地址。 diff --git a/docs/de-DE/plugins/gelbooru.md b/docs/de-DE/plugins/gelbooru.md new file mode 100644 index 000000000..b20065df3 --- /dev/null +++ b/docs/de-DE/plugins/gelbooru.md @@ -0,0 +1,24 @@ +# koishi-plugin-booru-gelbooru + +## Installation + +1. 在 Koishi 中下载并安装本插件,若你还未安装 [Booru 插件](../index.md),请先安装。 + +## 配置项 + +### 全局设置 + +:::tip +此处的配置项可参考[图源全局设置](../config#图源全局设置) +::: + +### 搜索设置 + +
+ +#### endpoint + +- 类型:`string` +- 默认值:`https://gelbooru.com/index.php` + +Gelbooru 的 API 地址。 diff --git a/docs/de-DE/plugins/konachan.md b/docs/de-DE/plugins/konachan.md new file mode 100644 index 000000000..4baba4202 --- /dev/null +++ b/docs/de-DE/plugins/konachan.md @@ -0,0 +1,24 @@ +# koishi-plugin-booru-konachan + +## Installation + +1. 在 Koishi 中下载并安装本插件,若你还未安装 [Booru 插件](../index.md),请先安装。 + +## 配置项 + +### 全局设置 + +:::tip +此处的配置项可参考[图源全局设置](../config#图源全局设置) +::: + +### 搜索设置 + +
+ +#### endpoint + +- 类型:`string` +- 默认值:`https://konachan.com/` + +Konachan 的 API 地址。 diff --git a/docs/de-DE/plugins/local.md b/docs/de-DE/plugins/local.md new file mode 100644 index 000000000..e79f5d1fe --- /dev/null +++ b/docs/de-DE/plugins/local.md @@ -0,0 +1,100 @@ +# koishi-plugin-booru-local + +超快的本地图源支持 + +## Installation + +1. 在 Koishi 中下载并安装本插件,若你还未安装 [Booru 插件](../index.md),请先安装。 + +## 配置项 + +### 全局设置 + +:::tip +此处的配置项可参考[图源全局设置](../config#图源全局设置) +::: + +### 图源设置 + +
+ +#### endpoint + +- 类型: `string[]` + +图源文件夹,支持多个不同的文件夹 + +#### languages + +- 类型: `string[]` +- 默认值: `['zh-CN', 'en']` + +图源支持的语言 + +#### extension + +- 类型: `string[]` +- 默认值: `['.jpg', '.png', '.jpeg', '.gif']` + +支持的图片扩展名 + +#### scraper + +- 类型: `string` +- 默认值: `{filename}-{tag}` + +文件元信息刮削器格式,详见 [刮削器](#刮削器) + +## 刮削器 + +:::tip +该方式需要图片文件名是特定的格式,且为减少边界情况,仅支持使用 `-` 分割 +::: + +这是一个在文件名中指定该图片元信息的方式,以便于插件能够正确的搜索符合需求的图片。 + +### 使用 + +插件设置中 `scraper` 默认值可得出大致的使用方式 + +### 标签 + +#### `#...#` + +- 类型: `string` +- 默认值: `name` +- 示例: `#name#{fliename}-{tag}` + +(仅在开头有效)指定刮削器的工作方式,目前支持以下几种方式: + +1. `name`: 文件名模式 +2. `meta`(WIP): 文件元信息模式(开发中) + +#### `{filename}` + +- 类型: `string` + +> 当 `{filename}` 被放置在最后时,`+` 将失效(即 `{foo}-{filename}+`) + +文件名 + +#### `{tag}` + +- 类型: `string[]` + +图片拥有的 tag + +#### `{nsfw}`(WIP) + +- 类型: `boolean | 'furry' | 'guro' | 'shota' | 'bl'` +- 默认值: `nsfw=false` + +限制级图片 + +#### `+` + +忽略后续的内容不作为元信息处理 + +#### `.` + +匹配 `.` 开头的隐藏文件,不设置的情况下将忽略隐藏文件 diff --git a/docs/de-DE/plugins/lolibooru.md b/docs/de-DE/plugins/lolibooru.md new file mode 100644 index 000000000..4dbd0a0cb --- /dev/null +++ b/docs/de-DE/plugins/lolibooru.md @@ -0,0 +1,24 @@ +# koishi-plugin-booru-lolibooru + +## Installation + +1. 在 Koishi 中下载并安装本插件,若你还未安装 [Booru 插件](../index.md),请先安装。 + +## 配置项 + +### 全局设置 + +:::tip +此处的配置项可参考[图源全局设置](../config#图源全局设置) +::: + +### 搜索设置 + +
+ +#### endpoint + +- 类型:`string` +- 默认值:`https://lolibooru.moe/` + +Lolibooru 的 API 地址。 diff --git a/docs/de-DE/plugins/lolicon.md b/docs/de-DE/plugins/lolicon.md new file mode 100644 index 000000000..c00f2742c --- /dev/null +++ b/docs/de-DE/plugins/lolicon.md @@ -0,0 +1,34 @@ +# koishi-plugin-booru-lolicon + +## Installation + +1. 在 Koishi 中下载并安装本插件,若你还未安装 [Booru 插件](../index.md),请先安装。 + +## 配置项 + +### 全局设置 + +:::tip +此处的配置项可参考[图源全局设置](../config#图源全局设置) +::: + +### 搜索设置 + +
+ +#### endpoint + +- 类型: `string` +- 默认值: `https://api.lolicon.app/setu/v2` + +#### r18 + +- 类型: `enum` +- 可选值: `'非 R18' | '仅 R18' | '混合'` +- 默认值: `'非 R18'` + +#### proxy + +- 类型: `{ endpoint: string } | string` +- 可选值: `'i.pixiv.re' | 'i.pixiv.cat'` +- 默认值: `'i.pixiv.re'` diff --git a/docs/de-DE/plugins/pixiv.md b/docs/de-DE/plugins/pixiv.md new file mode 100644 index 000000000..d9ccca9f5 --- /dev/null +++ b/docs/de-DE/plugins/pixiv.md @@ -0,0 +1,40 @@ +# koishi-plugin-booru-pixiv + +## Installation + +1. 在 Koishi 中下载并安装本插件,若你还未安装 [Booru 插件](../index.md),请先安装。 +2. 在 [Pixiv](https://www.pixiv.net/) 注册账号并登录。 +3. 使用 [Pixiv OAuth Script](https://gist.github.com/ZipFile/c9ebedb224406f4f11845ab700124362) 脚本获取 `Refresh Token`。 +4. 将 `Refresh Token` 填入配置项中的 `token` 项。 + +## 配置项 + +### 全局设置 + +:::tip +此处的配置项可参考[图源全局设置](../config#图源全局设置) +::: + +### 搜索设置 + +
+ +#### token + +- 类型:`string` +- 是否必填:是 + +Pixiv APP API 的 `Refresh Token`。 + +#### minBookmarks + +- 类型: `number` +- 默认值: `0` + +最少收藏数 + +#### proxy + +- 类型: `{ endpoint: string } | string` +- 可选值: `'i.pixiv.re' | 'i.pixiv.cat'` +- 默认值: `'i.pixiv.re'` diff --git a/docs/de-DE/plugins/safebooru.md b/docs/de-DE/plugins/safebooru.md new file mode 100644 index 000000000..57f5c31d0 --- /dev/null +++ b/docs/de-DE/plugins/safebooru.md @@ -0,0 +1,24 @@ +# koishi-plugin-booru-safebooru + +## Installation + +1. 在 Koishi 中下载并安装本插件,若你还未安装 [Booru 插件](../index.md),请先安装。 + +## 配置项 + +### 全局设置 + +:::tip +此处的配置项可参考[图源全局设置](../config#图源全局设置) +::: + +### 搜索设置 + +
+ +#### endpoint + +- 类型:`string` +- 默认值:`https://safebooru.org/index.php` + +Safebooru 的 API 地址。 diff --git a/docs/de-DE/plugins/sankaku.md b/docs/de-DE/plugins/sankaku.md new file mode 100644 index 000000000..2ede19200 --- /dev/null +++ b/docs/de-DE/plugins/sankaku.md @@ -0,0 +1,24 @@ +# koishi-plugin-booru-sankaku + +## Installation + +1. 在 Koishi 中下载并安装本插件,若你还未安装 [Booru 插件](../index.md),请先安装。 + +## 配置项 + +### 全局设置 + +:::tip +此处的配置项可参考[图源全局设置](../config#图源全局设置) +::: + +### 搜索设置 + +
+ +#### endpoint + +- 类型:`string` +- 默认值:`https://capi-v2.sankakucomplex.com/` + +SankakuComplex 的 API 地址。 diff --git a/docs/de-DE/plugins/yande.md b/docs/de-DE/plugins/yande.md new file mode 100644 index 000000000..6e5ffa2ff --- /dev/null +++ b/docs/de-DE/plugins/yande.md @@ -0,0 +1,24 @@ +# koishi-plugin-booru-yande + +## Installation + +1. 在 Koishi 中下载并安装本插件,若你还未安装 [Booru 插件](../index.md),请先安装。 + +## 配置项 + +### 全局设置 + +:::tip +此处的配置项可参考[图源全局设置](../config#图源全局设置) +::: + +### 搜索设置 + +
+ +#### endpoint + +- 类型:`string` +- 默认值:`https://yande.re/` + +Yande 的 API 地址。 diff --git a/docs/de-DE/usage.md b/docs/de-DE/usage.md new file mode 100644 index 000000000..6a84d7ed1 --- /dev/null +++ b/docs/de-DE/usage.md @@ -0,0 +1,23 @@ +# 使用 + +## 指令 + +`booru` 插件会注册名为 `booru` 的指令,用于搜索图片,只需在指令后面跟上搜索关键词即可。当搜索关键词为空时,会返回随机图片。 + +::: tip +每个图源插件都有适用语言,当你打开了 [`detectLanguage`](./config.md#detectlanguage) 选项时,`booru` 插件会自动检测你的语言并使用对应的图源插件。 + +如 [`danbooru`](./plugins/danbooru.md), [`gelbooru`](./plugins/gelbooru.md) 等图源插件仅支持英语 (en),而 [`pixiv`](./plugins/pixiv.md) 则支持日语 (ja)、英语 (en)、简体与繁体中文 (zh) 和韩语 (ko),但大部分情况下日语 (ja) 会有更好的效果。 +::: + + +booru komeiji koishi + + + + + + +
+
+
diff --git a/docs/en-US/config.md b/docs/en-US/config.md new file mode 100644 index 000000000..7c4764e83 --- /dev/null +++ b/docs/en-US/config.md @@ -0,0 +1,56 @@ +# 配置项 + +## 搜索设置 + +### detectLanguage + +- 类型: `boolean` +- 默认值: `false` + +是否自动检测语言。 + +当启用此选项时,插件会自动检测输入的 tag 的语言,并选择提供了相应语言支持的图源进行检索。 + +### confidence + +- 类型: `number` +- 默认值: `0.5` + +当 `detectLanguage` 启用时,此选项用于设置语言检测的置信度阈值。 + +### maxCount + +- 类型: `number` +- 默认值: `10` + +设置全局检索允许的最大图片数量。 + +## 输出设置 + +## output + +- 类型: `enum` +- 可选值:`仅发送图片`、`发送图片和相关信息`、`发送图片、相关信息和链接`、`发送全部信息` +- 默认值: `发送图片和相关信息` + +设置输出的信息。 + +## 图源全局设置 + +:::tip +此项设置存在于图源插件中而非全局设置里,因此可以针对不同的图源设置不同的配置。 +::: + +### label + +- 类型: `string` +- 默认值: `图源名称` + +图源标签,可用于在指令中手动指定图源。 + +### weight + +- 类型: `number` +- 默认值: `1` + +图源权重。在多个符合标签的图源中,将按照各自的权重随机选择。 diff --git a/docs/en-US/develop/api.md b/docs/en-US/develop/api.md new file mode 100644 index 000000000..19a54b603 --- /dev/null +++ b/docs/en-US/develop/api.md @@ -0,0 +1,80 @@ +# API + +## 服务方法 + +### `ctx.booru.register()` + +```ts +ctx.booru.register(source: ImageSource): () => boolean +``` + +注册一个图源,返回一个 dispose 函数,调用此函数可以注销此图源。 + +### `ctx.booru.hasSource()` + +```ts +ctx.booru.hasSource(name?: string): boolean +``` + +当不传入参数时,判断是否存在激活的图源;当传入参数时,判断是否存在指定名称的图源。 + +### `ctx.booru.get()` + +```ts +ctx.booru.get(query: ImageService.Query): Promise +``` + +获取符合条件的图片,返回一个 Promise,resolve 时返回一个图片数组。 + +当 `query.tags` 为空时,应当返回随机的图片。 + +当获取不到图片时,应当返回 `undefined`。 + +## 类型定义 + +### `ImageSource` + +```ts +export abstract class ImageSource { + languages: string[] = ['en'] // 图源支持的语言 + + constructor(public ctx: Context, public config: Config) { + this.ctx.booru.register(this) + } + + // 对标签进行分词,返回一个标签数组 + tokenize(query: string): string[] + + // 获取图片 + abstract get(query: ImageSource.Query): Promise +} +``` + + +### `ImageSource.Query` + +```ts +export interface Query { + tags: string[] + /** raw query */ + raw: string + count: number +} +``` + +### `ImageSource.Result` + +```ts +export type NsfwType = 'furry' | 'guro' | 'shota' | 'bl' + +export interface Result { + url: string + pageUrl?: string + author?: string + authorUrl?: string + title?: string + desc?: string + tags?: string[] + nsfw?: boolean | NsfwType +} +``` diff --git a/docs/en-US/develop/service.md b/docs/en-US/develop/service.md new file mode 100644 index 000000000..8171ce428 --- /dev/null +++ b/docs/en-US/develop/service.md @@ -0,0 +1,65 @@ +# service + +`booru` 插件会注册名为 `booru` 的服务,可以被其他插件调用。 + +## 检测图源 + +`booru` 服务提供了 `hasSource()` 方法,可以用于判断是否存在任意图源,或是否存在指定的图源。 + +```ts +import { Context } from 'koishi' + +export function apply(ctx: Context) { + ctx.booru.hasSource() // 是否存在任意图源 + ctx.boooru.hasSource('pixiv') // 是否存在 pixiv 图源 +} +``` + +## 获取图片 + +`booru` 服务提供了 `get()` 方法,可以用于获取图片。 + +```tsx +import { Context } from 'koishi' + +export function apply(ctx: Context) { + ctx.command('恋恋最可爱').action(async () => { + const image = await ctx.booru.get({ tags: 'komeiji koishi', raw: 'komeiji koishi', count: 1 }) + return + }) +} +``` + + +恋恋最可爱 + + + + + + +
+
+
+ +## 注册图源 + +`booru` 服务提供了 `register()` 方法,可以用于注册图源。 + +```ts +import { Context } from 'koishi' + +class PixivSource extends ImageSource { + name = 'pixiv' + async get(query) { + // ... + } +} + +export function apply(ctx: Context, config: Config) { + // 注册图源 + const dispose = ctx.booru.register(new PixivSource(ctx, config)) + // 注销图源 + dispose() +} +``` diff --git a/docs/en-US/develop/source.md b/docs/en-US/develop/source.md new file mode 100644 index 000000000..a2a48e023 --- /dev/null +++ b/docs/en-US/develop/source.md @@ -0,0 +1,98 @@ +# 图源 + +## Introduction + +图源插件是用于获取图片的插件,它可以从网络、本地文件、剪贴板、数据库等地方获取图片。 + +由于图源插件本身也是一个标准的 [Koishi 插件](https://koishi.chat/zh-CN/guide/plugin/#%E6%8F%92%E4%BB%B6%E7%9A%84%E5%9F%BA%E6%9C%AC%E5%BD%A2%E5%BC%8F),这意味着它必须导出一个函数,或者一个带有 `apply` 方法的对象。为了方便开发,我们提供了一个抽象类 `ImageSource`,当你继承它并实现相应方法后以默认方式导出,就可以作为 Koishi 插件被加载,这有助于插件作者快速开发图源插件。 + +## Prerequisite + +在此,我们将假设你已经阅读了[认识插件](https://koishi.chat/zh-CN/guide/plugin/),并且配置好了 Koishi 插件的开发环境。 + +图源插件需要继承的 `ImageSource` 类定义在 `koishi-plugin-booru` 包中,因此你需要将 `koishi-plugin-booru` 插件列为你的图源插件的对等依赖 (peerDependencies)。 + +```json +{ + "peerDependencies": { + "booru": "^1.0.3" + } +} +``` + +**请根据你所需求的功能酌情升级对等依赖的 booru 插件的版本** + +## 开发图源插件 + +此处以简化版的 `lolicon` 插件为例,可以从 `https://api.lolicon.net/` 的 API 获取图片及元信息。 + +```ts +import { Context, Schema } from 'koishi' +import { ImageSource } from 'koishi-plugin-booru' + +class LoliconImageSource extends ImageSource { + // 定义图源支持的语言 + // 如 lolicon 支持日语、英语和汉语-简体中文等 + languages: string[] = ['en', 'zh-CN', 'ja'] + + constructor(ctx: Context, config: LoliconImageSource.Config) { + // 调用父类的拟构函数以注册图源 + super(ctx, config) + } + + // `booru` 默认将标签转换为类 `danbooru` 的形式,即「空格分割标签,下划线替代空格」。 + // 而 lolicon 支持的标签不带空格,因此此处需要将其重载为空格分割。 + override tokenize(query: string): string[] { + return query.split(/\s+/) + } + + async get(query: ImageSource.Query): Promise { + const param = { + // `tags` 是一个字符串数组,根据 Lolicon API 的文档,传入数组等于「与」操作。 + tag: query.tags, + // 指定获取数量 + num: query.count, + } + // 注:根据图源设计规范,当 `query.tags` 为空数组或空时,应当返回随机图片。 + // 由于 Lolicon API 默认对空标签会返回随机图,因此不需要做特别处理, + // 但对于其他图源可能需要传入特别的参数才能使用随机图片功能。 + const resp = await this.ctx.http.post('https://api.lolicon.app/setu/v2', param) + + if (!Array.isArray(resp.data)) { + return + } + + // 返回类型为 `Result` 的数组,可用字段可参考类型提示。 + // 其中 `url` 字段是图片的地址,也可以是 `base64` 编码。 + return resp.data.map((setu) => { + return { + url: setu.urls.original, + title: setu.title, + author: setu.author, + nsfw: setu.r18, + tags: setu.tags, + pageUrl: `https://pixiv.net/i/${setu.pid}`, + } + }) + } +} + +// 图源插件还需要导出配置项,因此我们采用 TypeScript 的 namespace +// 将配置项 Config 与上面的 class 定义合并。 +namespace LoliconImageSource { + export interface Config extends ImageSource.Config {} + + export const Config: Schema = Schema.intersect([ + // 结合使用 `Svchema.intersect` 和 `createSchema` 辅助函数, + // 向图源插件的配置项里添加全局的通用配置,`label` 一般为图源插件名。 + ImageSource.createSchema({ label: 'lolicon' }), + ]) +} + +// 以默认导出方式导出整个命名空间 +export default LoliconImageSource +``` + +:::tip +上述代码为介绍与解释 `booru` 图源的开发步骤有一定简化,你可以直接在 [GitHub](https://github.com/koishijs/koishi-plugin-booru/tree/main/packages/lolicon) 上阅读 lolicon 插件真正的源码。 +::: diff --git a/docs/en-US/index.md b/docs/en-US/index.md new file mode 100644 index 000000000..51a92d4db --- /dev/null +++ b/docs/en-US/index.md @@ -0,0 +1,35 @@ +# Introduction + +> 「最好的涩图插件!」 —— Shigma + +Booru 是一个基于 [Koishi](https://koishi.chat/) 的图片检索插件,支持多个图源站点。 + +:::tip +你需要安装至少一个图源插件才能使用 Booru 插件。 +::: + +## Features + +- 支持多个[图源站点](#图源插件) +- 支持多种发送方式 +- 支持随机检索 + +## 图源插件 + +Booru 插件支持多个图源站点,每个图源站点都有一个对应的插件。目前支持的图源站点有: + +| 图源 | Plugins | +| -------------------------------------------------- | --------------------------------------------------------- | +| [Danbooru](https://danbooru.donmai.us/) | [`koishi-plugin-booru-danbooru`](./plugins/danbooru.md) | +| [e621](https://e621.net/) | [`koishi-plugin-booru-e621`](./plugins/e621.md) | +| [e926](https://e926.net/) | [`koishi-plugin-booru-e621`](./plugins/e621.md) | +| [Gelbooru](https://gelbooru.com/) | [`koishi-plugin-booru-gelbooru`](./plugins/gelbooru.md) | +| [Konachan](https://konachan.com/) | [`koishi-plugin-booru-konachan`](./plugins/konachan.md) | +| [Konachan.net](https://konachan.net/) | [`koishi-plugin-booru-konachan`](./plugins/konachan.md) | +| [Lolibooru](https://lolibooru.moe/) | [`koishi-plugin-booru-lolibooru`](./plugins/lolibooru.md) | +| [Lolicon](https://lolicon.app/) | [`koishi-plugin-booru-lolicon`](./plugins/lolicon.md) | +| [Pixiv](https://www.pixiv.net/) | [`koishi-plugin-booru-pixiv`](./plugins/pixiv.md) | +| [Safebooru](https://safebooru.org/) | [`koishi-plugin-booru-safebooru`](./plugins/safebooru.md) | +| [SankakuComplex](https://chan.sankakucomplex.com/) | [`koishi-plugin-booru-sankaku`](./plugins/sankaku.md) | +| [Yande.re](https://yande.re/) | [`koishi-plugin-booru-yande`](./plugins/yande.md) | +| 本地文件夹 | [`koishi-plugin-booru-local`](./plugins/local.md) | diff --git a/docs/en-US/plugins/danbooru.md b/docs/en-US/plugins/danbooru.md new file mode 100644 index 000000000..009b88526 --- /dev/null +++ b/docs/en-US/plugins/danbooru.md @@ -0,0 +1,24 @@ +# koishi-plugin-booru-danbooru + +## Install + +1. 在 Koishi 中下载并安装本插件,若你还未安装 [Booru 插件](../index.md),请先安装。 + +## 配置项 + +### 全局设置 + +:::tip +此处的配置项可参考[图源全局设置](../config#图源全局设置) +::: + +### 搜索设置 + +
+ +#### endpoint + +- 类型:`string` +- 默认值:`https://danbooru.donmai.us` + +Danbooru 的 API 地址。 diff --git a/docs/en-US/plugins/e621.md b/docs/en-US/plugins/e621.md new file mode 100644 index 000000000..d75a72a3d --- /dev/null +++ b/docs/en-US/plugins/e621.md @@ -0,0 +1,31 @@ +# koishi-plugin-booru-e621 + +## Install + +1. 在 Koishi 中下载并安装本插件,若你还未安装 [Booru 插件](../index.md),请先安装。 + +## 配置项 + +### 全局设置 + +:::tip +此处的配置项可参考[图源全局设置](../config#图源全局设置) +::: + +### 搜索设置 + +
+ +#### userAgent + +- 类型:`string` +- 默认值:`Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36 Edg/114.0.1823.37` + +请求时所使用的 User-Agent + +#### endpoint + +- 类型:`string` +- 默认值:`https://e621.net` + +e621/e926 的 API 地址。 diff --git a/docs/en-US/plugins/gelbooru.md b/docs/en-US/plugins/gelbooru.md new file mode 100644 index 000000000..39d97ee9c --- /dev/null +++ b/docs/en-US/plugins/gelbooru.md @@ -0,0 +1,24 @@ +# koishi-plugin-booru-gelbooru + +## Install + +1. 在 Koishi 中下载并安装本插件,若你还未安装 [Booru 插件](../index.md),请先安装。 + +## 配置项 + +### 全局设置 + +:::tip +此处的配置项可参考[图源全局设置](../config#图源全局设置) +::: + +### 搜索设置 + +
+ +#### endpoint + +- 类型:`string` +- 默认值:`https://gelbooru.com/index.php` + +Gelbooru 的 API 地址。 diff --git a/docs/en-US/plugins/konachan.md b/docs/en-US/plugins/konachan.md new file mode 100644 index 000000000..a308d2987 --- /dev/null +++ b/docs/en-US/plugins/konachan.md @@ -0,0 +1,24 @@ +# koishi-plugin-booru-konachan + +## Install + +1. 在 Koishi 中下载并安装本插件,若你还未安装 [Booru 插件](../index.md),请先安装。 + +## 配置项 + +### 全局设置 + +:::tip +此处的配置项可参考[图源全局设置](../config#图源全局设置) +::: + +### 搜索设置 + +
+ +#### endpoint + +- 类型:`string` +- 默认值:`https://konachan.com/` + +Konachan 的 API 地址。 diff --git a/docs/en-US/plugins/local.md b/docs/en-US/plugins/local.md new file mode 100644 index 000000000..5c188c127 --- /dev/null +++ b/docs/en-US/plugins/local.md @@ -0,0 +1,100 @@ +# koishi-plugin-booru-local + +超快的本地图源支持 + +## Install + +1. 在 Koishi 中下载并安装本插件,若你还未安装 [Booru 插件](../index.md),请先安装。 + +## 配置项 + +### 全局设置 + +:::tip +此处的配置项可参考[图源全局设置](../config#图源全局设置) +::: + +### 图源设置 + +
+ +#### endpoint + +- 类型: `string[]` + +图源文件夹,支持多个不同的文件夹 + +#### languages + +- 类型: `string[]` +- 默认值: `['zh-CN', 'en']` + +图源支持的语言 + +#### extension + +- 类型: `string[]` +- 默认值: `['.jpg', '.png', '.jpeg', '.gif']` + +支持的图片扩展名 + +#### scraper + +- 类型: `string` +- 默认值: `{filename}-{tag}` + +文件元信息刮削器格式,详见 [刮削器](#刮削器) + +## 刮削器 + +:::tip +该方式需要图片文件名是特定的格式,且为减少边界情况,仅支持使用 `-` 分割 +::: + +这是一个在文件名中指定该图片元信息的方式,以便于插件能够正确的搜索符合需求的图片。 + +### Usage + +插件设置中 `scraper` 默认值可得出大致的使用方式 + +### 标签 + +#### `#...#` + +- 类型: `string` +- 默认值: `name` +- 示例: `#name#{fliename}-{tag}` + +(仅在开头有效)指定刮削器的工作方式,目前支持以下几种方式: + +1. `name`: 文件名模式 +2. `meta`(WIP): 文件元信息模式(开发中) + +#### `{filename}` + +- 类型: `string` + +> 当 `{filename}` 被放置在最后时,`+` 将失效(即 `{foo}-{filename}+`) + +文件名 + +#### `{tag}` + +- 类型: `string[]` + +图片拥有的 tag + +#### `{nsfw}`(WIP) + +- 类型: `boolean | 'furry' | 'guro' | 'shota' | 'bl'` +- 默认值: `nsfw=false` + +限制级图片 + +#### `+` + +忽略后续的内容不作为元信息处理 + +#### `.` + +匹配 `.` 开头的隐藏文件,不设置的情况下将忽略隐藏文件 diff --git a/docs/en-US/plugins/lolibooru.md b/docs/en-US/plugins/lolibooru.md new file mode 100644 index 000000000..bbf4132e0 --- /dev/null +++ b/docs/en-US/plugins/lolibooru.md @@ -0,0 +1,24 @@ +# koishi-plugin-booru-lolibooru + +## Install + +1. 在 Koishi 中下载并安装本插件,若你还未安装 [Booru 插件](../index.md),请先安装。 + +## 配置项 + +### 全局设置 + +:::tip +此处的配置项可参考[图源全局设置](../config#图源全局设置) +::: + +### 搜索设置 + +
+ +#### endpoint + +- 类型:`string` +- 默认值:`https://lolibooru.moe/` + +Lolibooru 的 API 地址。 diff --git a/docs/en-US/plugins/lolicon.md b/docs/en-US/plugins/lolicon.md new file mode 100644 index 000000000..6e83cb9ec --- /dev/null +++ b/docs/en-US/plugins/lolicon.md @@ -0,0 +1,34 @@ +# koishi-plugin-booru-lolicon + +## Install + +1. 在 Koishi 中下载并安装本插件,若你还未安装 [Booru 插件](../index.md),请先安装。 + +## 配置项 + +### 全局设置 + +:::tip +此处的配置项可参考[图源全局设置](../config#图源全局设置) +::: + +### 搜索设置 + +
+ +#### endpoint + +- 类型: `string` +- 默认值: `https://api.lolicon.app/setu/v2` + +#### r18 + +- 类型: `enum` +- 可选值: `'非 R18' | '仅 R18' | '混合'` +- 默认值: `'非 R18'` + +#### proxy + +- 类型: `{ endpoint: string } | string` +- 可选值: `'i.pixiv.re' | 'i.pixiv.cat'` +- 默认值: `'i.pixiv.re'` diff --git a/docs/en-US/plugins/pixiv.md b/docs/en-US/plugins/pixiv.md new file mode 100644 index 000000000..af370cd85 --- /dev/null +++ b/docs/en-US/plugins/pixiv.md @@ -0,0 +1,40 @@ +# koishi-plugin-booru-pixiv + +## Install + +1. 在 Koishi 中下载并安装本插件,若你还未安装 [Booru 插件](../index.md),请先安装。 +2. 在 [Pixiv](https://www.pixiv.net/) 注册账号并登录。 +3. 使用 [Pixiv OAuth Script](https://gist.github.com/ZipFile/c9ebedb224406f4f11845ab700124362) 脚本获取 `Refresh Token`。 +4. 将 `Refresh Token` 填入配置项中的 `token` 项。 + +## 配置项 + +### 全局设置 + +:::tip +此处的配置项可参考[图源全局设置](../config#图源全局设置) +::: + +### 搜索设置 + +
+ +#### token + +- 类型:`string` +- 是否必填:是 + +Pixiv APP API 的 `Refresh Token`。 + +#### minBookmarks + +- 类型: `number` +- 默认值: `0` + +最少收藏数 + +#### proxy + +- 类型: `{ endpoint: string } | string` +- 可选值: `'i.pixiv.re' | 'i.pixiv.cat'` +- 默认值: `'i.pixiv.re'` diff --git a/docs/en-US/plugins/safebooru.md b/docs/en-US/plugins/safebooru.md new file mode 100644 index 000000000..ff88e3634 --- /dev/null +++ b/docs/en-US/plugins/safebooru.md @@ -0,0 +1,24 @@ +# koishi-plugin-booru-safebooru + +## Install + +1. 在 Koishi 中下载并安装本插件,若你还未安装 [Booru 插件](../index.md),请先安装。 + +## 配置项 + +### 全局设置 + +:::tip +此处的配置项可参考[图源全局设置](../config#图源全局设置) +::: + +### 搜索设置 + +
+ +#### endpoint + +- 类型:`string` +- 默认值:`https://safebooru.org/index.php` + +Safebooru 的 API 地址。 diff --git a/docs/en-US/plugins/sankaku.md b/docs/en-US/plugins/sankaku.md new file mode 100644 index 000000000..5dbba6cd2 --- /dev/null +++ b/docs/en-US/plugins/sankaku.md @@ -0,0 +1,24 @@ +# koishi-plugin-booru-sankaku + +## Install + +1. 在 Koishi 中下载并安装本插件,若你还未安装 [Booru 插件](../index.md),请先安装。 + +## 配置项 + +### 全局设置 + +:::tip +此处的配置项可参考[图源全局设置](../config#图源全局设置) +::: + +### 搜索设置 + +
+ +#### endpoint + +- 类型:`string` +- 默认值:`https://capi-v2.sankakucomplex.com/` + +SankakuComplex 的 API 地址。 diff --git a/docs/en-US/plugins/yande.md b/docs/en-US/plugins/yande.md new file mode 100644 index 000000000..d084d8cfc --- /dev/null +++ b/docs/en-US/plugins/yande.md @@ -0,0 +1,24 @@ +# koishi-plugin-booru-yande + +## Install + +1. 在 Koishi 中下载并安装本插件,若你还未安装 [Booru 插件](../index.md),请先安装。 + +## 配置项 + +### 全局设置 + +:::tip +此处的配置项可参考[图源全局设置](../config#图源全局设置) +::: + +### 搜索设置 + +
+ +#### endpoint + +- 类型:`string` +- 默认值:`https://yande.re/` + +Yande 的 API 地址。 diff --git a/docs/en-US/usage.md b/docs/en-US/usage.md new file mode 100644 index 000000000..82e8b815f --- /dev/null +++ b/docs/en-US/usage.md @@ -0,0 +1,23 @@ +# Usage + +## command + +`booru` 插件会注册名为 `booru` 的指令,用于搜索图片,只需在指令后面跟上搜索关键词即可。当搜索关键词为空时,会返回随机图片。 + +::: tip +每个图源插件都有适用语言,当你打开了 [`detectLanguage`](./config.md#detectlanguage) 选项时,`booru` 插件会自动检测你的语言并使用对应的图源插件。 + +如 [`danbooru`](./plugins/danbooru.md), [`gelbooru`](./plugins/gelbooru.md) 等图源插件仅支持英语 (en),而 [`pixiv`](./plugins/pixiv.md) 则支持日语 (ja)、英语 (en)、简体与繁体中文 (zh) 和韩语 (ko),但大部分情况下日语 (ja) 会有更好的效果。 +::: + + +booru komeiji koishi + + + + + + +
+
+
diff --git a/docs/fr-FR/config.md b/docs/fr-FR/config.md new file mode 100644 index 000000000..7c4764e83 --- /dev/null +++ b/docs/fr-FR/config.md @@ -0,0 +1,56 @@ +# 配置项 + +## 搜索设置 + +### detectLanguage + +- 类型: `boolean` +- 默认值: `false` + +是否自动检测语言。 + +当启用此选项时,插件会自动检测输入的 tag 的语言,并选择提供了相应语言支持的图源进行检索。 + +### confidence + +- 类型: `number` +- 默认值: `0.5` + +当 `detectLanguage` 启用时,此选项用于设置语言检测的置信度阈值。 + +### maxCount + +- 类型: `number` +- 默认值: `10` + +设置全局检索允许的最大图片数量。 + +## 输出设置 + +## output + +- 类型: `enum` +- 可选值:`仅发送图片`、`发送图片和相关信息`、`发送图片、相关信息和链接`、`发送全部信息` +- 默认值: `发送图片和相关信息` + +设置输出的信息。 + +## 图源全局设置 + +:::tip +此项设置存在于图源插件中而非全局设置里,因此可以针对不同的图源设置不同的配置。 +::: + +### label + +- 类型: `string` +- 默认值: `图源名称` + +图源标签,可用于在指令中手动指定图源。 + +### weight + +- 类型: `number` +- 默认值: `1` + +图源权重。在多个符合标签的图源中,将按照各自的权重随机选择。 diff --git a/docs/fr-FR/develop/api.md b/docs/fr-FR/develop/api.md new file mode 100644 index 000000000..19a54b603 --- /dev/null +++ b/docs/fr-FR/develop/api.md @@ -0,0 +1,80 @@ +# API + +## 服务方法 + +### `ctx.booru.register()` + +```ts +ctx.booru.register(source: ImageSource): () => boolean +``` + +注册一个图源,返回一个 dispose 函数,调用此函数可以注销此图源。 + +### `ctx.booru.hasSource()` + +```ts +ctx.booru.hasSource(name?: string): boolean +``` + +当不传入参数时,判断是否存在激活的图源;当传入参数时,判断是否存在指定名称的图源。 + +### `ctx.booru.get()` + +```ts +ctx.booru.get(query: ImageService.Query): Promise +``` + +获取符合条件的图片,返回一个 Promise,resolve 时返回一个图片数组。 + +当 `query.tags` 为空时,应当返回随机的图片。 + +当获取不到图片时,应当返回 `undefined`。 + +## 类型定义 + +### `ImageSource` + +```ts +export abstract class ImageSource { + languages: string[] = ['en'] // 图源支持的语言 + + constructor(public ctx: Context, public config: Config) { + this.ctx.booru.register(this) + } + + // 对标签进行分词,返回一个标签数组 + tokenize(query: string): string[] + + // 获取图片 + abstract get(query: ImageSource.Query): Promise +} +``` + + +### `ImageSource.Query` + +```ts +export interface Query { + tags: string[] + /** raw query */ + raw: string + count: number +} +``` + +### `ImageSource.Result` + +```ts +export type NsfwType = 'furry' | 'guro' | 'shota' | 'bl' + +export interface Result { + url: string + pageUrl?: string + author?: string + authorUrl?: string + title?: string + desc?: string + tags?: string[] + nsfw?: boolean | NsfwType +} +``` diff --git a/docs/fr-FR/develop/service.md b/docs/fr-FR/develop/service.md new file mode 100644 index 000000000..8171ce428 --- /dev/null +++ b/docs/fr-FR/develop/service.md @@ -0,0 +1,65 @@ +# service + +`booru` 插件会注册名为 `booru` 的服务,可以被其他插件调用。 + +## 检测图源 + +`booru` 服务提供了 `hasSource()` 方法,可以用于判断是否存在任意图源,或是否存在指定的图源。 + +```ts +import { Context } from 'koishi' + +export function apply(ctx: Context) { + ctx.booru.hasSource() // 是否存在任意图源 + ctx.boooru.hasSource('pixiv') // 是否存在 pixiv 图源 +} +``` + +## 获取图片 + +`booru` 服务提供了 `get()` 方法,可以用于获取图片。 + +```tsx +import { Context } from 'koishi' + +export function apply(ctx: Context) { + ctx.command('恋恋最可爱').action(async () => { + const image = await ctx.booru.get({ tags: 'komeiji koishi', raw: 'komeiji koishi', count: 1 }) + return + }) +} +``` + + +恋恋最可爱 + + + + + + +
+
+
+ +## 注册图源 + +`booru` 服务提供了 `register()` 方法,可以用于注册图源。 + +```ts +import { Context } from 'koishi' + +class PixivSource extends ImageSource { + name = 'pixiv' + async get(query) { + // ... + } +} + +export function apply(ctx: Context, config: Config) { + // 注册图源 + const dispose = ctx.booru.register(new PixivSource(ctx, config)) + // 注销图源 + dispose() +} +``` diff --git a/docs/fr-FR/develop/source.md b/docs/fr-FR/develop/source.md new file mode 100644 index 000000000..1377213ed --- /dev/null +++ b/docs/fr-FR/develop/source.md @@ -0,0 +1,98 @@ +# 图源 + +## Introduction + +图源插件是用于获取图片的插件,它可以从网络、本地文件、剪贴板、数据库等地方获取图片。 + +由于图源插件本身也是一个标准的 [Koishi 插件](https://koishi.chat/zh-CN/guide/plugin/#%E6%8F%92%E4%BB%B6%E7%9A%84%E5%9F%BA%E6%9C%AC%E5%BD%A2%E5%BC%8F),这意味着它必须导出一个函数,或者一个带有 `apply` 方法的对象。为了方便开发,我们提供了一个抽象类 `ImageSource`,当你继承它并实现相应方法后以默认方式导出,就可以作为 Koishi 插件被加载,这有助于插件作者快速开发图源插件。 + +## 准备工作 + +在此,我们将假设你已经阅读了[认识插件](https://koishi.chat/zh-CN/guide/plugin/),并且配置好了 Koishi 插件的开发环境。 + +图源插件需要继承的 `ImageSource` 类定义在 `koishi-plugin-booru` 包中,因此你需要将 `koishi-plugin-booru` 插件列为你的图源插件的对等依赖 (peerDependencies)。 + +```json +{ + "peerDependencies": { + "booru": "^1.0.3" + } +} +``` + +**请根据你所需求的功能酌情升级对等依赖的 booru 插件的版本** + +## 开发图源插件 + +此处以简化版的 `lolicon` 插件为例,可以从 `https://api.lolicon.net/` 的 API 获取图片及元信息。 + +```ts +import { Context, Schema } from 'koishi' +import { ImageSource } from 'koishi-plugin-booru' + +class LoliconImageSource extends ImageSource { + // 定义图源支持的语言 + // 如 lolicon 支持日语、英语和汉语-简体中文等 + languages: string[] = ['en', 'zh-CN', 'ja'] + + constructor(ctx: Context, config: LoliconImageSource.Config) { + // 调用父类的拟构函数以注册图源 + super(ctx, config) + } + + // `booru` 默认将标签转换为类 `danbooru` 的形式,即「空格分割标签,下划线替代空格」。 + // 而 lolicon 支持的标签不带空格,因此此处需要将其重载为空格分割。 + override tokenize(query: string): string[] { + return query.split(/\s+/) + } + + async get(query: ImageSource.Query): Promise { + const param = { + // `tags` 是一个字符串数组,根据 Lolicon API 的文档,传入数组等于「与」操作。 + tag: query.tags, + // 指定获取数量 + num: query.count, + } + // 注:根据图源设计规范,当 `query.tags` 为空数组或空时,应当返回随机图片。 + // 由于 Lolicon API 默认对空标签会返回随机图,因此不需要做特别处理, + // 但对于其他图源可能需要传入特别的参数才能使用随机图片功能。 + const resp = await this.ctx.http.post('https://api.lolicon.app/setu/v2', param) + + if (!Array.isArray(resp.data)) { + return + } + + // 返回类型为 `Result` 的数组,可用字段可参考类型提示。 + // 其中 `url` 字段是图片的地址,也可以是 `base64` 编码。 + return resp.data.map((setu) => { + return { + url: setu.urls.original, + title: setu.title, + author: setu.author, + nsfw: setu.r18, + tags: setu.tags, + pageUrl: `https://pixiv.net/i/${setu.pid}`, + } + }) + } +} + +// 图源插件还需要导出配置项,因此我们采用 TypeScript 的 namespace +// 将配置项 Config 与上面的 class 定义合并。 +namespace LoliconImageSource { + export interface Config extends ImageSource.Config {} + + export const Config: Schema = Schema.intersect([ + // 结合使用 `Svchema.intersect` 和 `createSchema` 辅助函数, + // 向图源插件的配置项里添加全局的通用配置,`label` 一般为图源插件名。 + ImageSource.createSchema({ label: 'lolicon' }), + ]) +} + +// 以默认导出方式导出整个命名空间 +export default LoliconImageSource +``` + +:::tip +上述代码为介绍与解释 `booru` 图源的开发步骤有一定简化,你可以直接在 [GitHub](https://github.com/koishijs/koishi-plugin-booru/tree/main/packages/lolicon) 上阅读 lolicon 插件真正的源码。 +::: diff --git a/docs/fr-FR/index.md b/docs/fr-FR/index.md new file mode 100644 index 000000000..05879b971 --- /dev/null +++ b/docs/fr-FR/index.md @@ -0,0 +1,35 @@ +# Introduction + +> 「最好的涩图插件!」 —— Shigma + +Booru 是一个基于 [Koishi](https://koishi.chat/) 的图片检索插件,支持多个图源站点。 + +:::tip +你需要安装至少一个图源插件才能使用 Booru 插件。 +::: + +## Fonctionnalités + +- 支持多个[图源站点](#图源插件) +- 支持多种发送方式 +- 支持随机检索 + +## 图源插件 + +Booru 插件支持多个图源站点,每个图源站点都有一个对应的插件。目前支持的图源站点有: + +| 图源 | plugin | +| -------------------------------------------------- | --------------------------------------------------------- | +| [Danbooru](https://danbooru.donmai.us/) | [`koishi-plugin-booru-danbooru`](./plugins/danbooru.md) | +| [e621](https://e621.net/) | [`koishi-plugin-booru-e621`](./plugins/e621.md) | +| [e926](https://e926.net/) | [`koishi-plugin-booru-e621`](./plugins/e621.md) | +| [Gelbooru](https://gelbooru.com/) | [`koishi-plugin-booru-gelbooru`](./plugins/gelbooru.md) | +| [Konachan](https://konachan.com/) | [`koishi-plugin-booru-konachan`](./plugins/konachan.md) | +| [Konachan.net](https://konachan.net/) | [`koishi-plugin-booru-konachan`](./plugins/konachan.md) | +| [Lolibooru](https://lolibooru.moe/) | [`koishi-plugin-booru-lolibooru`](./plugins/lolibooru.md) | +| [Lolicon](https://lolicon.app/) | [`koishi-plugin-booru-lolicon`](./plugins/lolicon.md) | +| [Pixiv](https://www.pixiv.net/) | [`koishi-plugin-booru-pixiv`](./plugins/pixiv.md) | +| [Safebooru](https://safebooru.org/) | [`koishi-plugin-booru-safebooru`](./plugins/safebooru.md) | +| [SankakuComplex](https://chan.sankakucomplex.com/) | [`koishi-plugin-booru-sankaku`](./plugins/sankaku.md) | +| [Yande.re](https://yande.re/) | [`koishi-plugin-booru-yande`](./plugins/yande.md) | +| 本地文件夹 | [`koishi-plugin-booru-local`](./plugins/local.md) | diff --git a/docs/fr-FR/plugins/danbooru.md b/docs/fr-FR/plugins/danbooru.md new file mode 100644 index 000000000..cbab7a233 --- /dev/null +++ b/docs/fr-FR/plugins/danbooru.md @@ -0,0 +1,24 @@ +# koishi-plugin-booru-danbooru + +## Installation + +1. 在 Koishi 中下载并安装本插件,若你还未安装 [Booru 插件](../index.md),请先安装。 + +## 配置项 + +### 全局设置 + +:::tip +此处的配置项可参考[图源全局设置](../config#图源全局设置) +::: + +### 搜索设置 + +
+ +#### endpoint + +- 类型:`string` +- 默认值:`https://danbooru.donmai.us` + +Danbooru 的 API 地址。 diff --git a/docs/fr-FR/plugins/e621.md b/docs/fr-FR/plugins/e621.md new file mode 100644 index 000000000..af46a4794 --- /dev/null +++ b/docs/fr-FR/plugins/e621.md @@ -0,0 +1,31 @@ +# koishi-plugin-booru-e621 + +## Installation + +1. 在 Koishi 中下载并安装本插件,若你还未安装 [Booru 插件](../index.md),请先安装。 + +## 配置项 + +### 全局设置 + +:::tip +此处的配置项可参考[图源全局设置](../config#图源全局设置) +::: + +### 搜索设置 + +
+ +#### userAgent + +- 类型:`string` +- 默认值:`Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36 Edg/114.0.1823.37` + +请求时所使用的 User-Agent + +#### endpoint + +- 类型:`string` +- 默认值:`https://e621.net` + +e621/e926 的 API 地址。 diff --git a/docs/fr-FR/plugins/gelbooru.md b/docs/fr-FR/plugins/gelbooru.md new file mode 100644 index 000000000..b20065df3 --- /dev/null +++ b/docs/fr-FR/plugins/gelbooru.md @@ -0,0 +1,24 @@ +# koishi-plugin-booru-gelbooru + +## Installation + +1. 在 Koishi 中下载并安装本插件,若你还未安装 [Booru 插件](../index.md),请先安装。 + +## 配置项 + +### 全局设置 + +:::tip +此处的配置项可参考[图源全局设置](../config#图源全局设置) +::: + +### 搜索设置 + +
+ +#### endpoint + +- 类型:`string` +- 默认值:`https://gelbooru.com/index.php` + +Gelbooru 的 API 地址。 diff --git a/docs/fr-FR/plugins/konachan.md b/docs/fr-FR/plugins/konachan.md new file mode 100644 index 000000000..4baba4202 --- /dev/null +++ b/docs/fr-FR/plugins/konachan.md @@ -0,0 +1,24 @@ +# koishi-plugin-booru-konachan + +## Installation + +1. 在 Koishi 中下载并安装本插件,若你还未安装 [Booru 插件](../index.md),请先安装。 + +## 配置项 + +### 全局设置 + +:::tip +此处的配置项可参考[图源全局设置](../config#图源全局设置) +::: + +### 搜索设置 + +
+ +#### endpoint + +- 类型:`string` +- 默认值:`https://konachan.com/` + +Konachan 的 API 地址。 diff --git a/docs/fr-FR/plugins/local.md b/docs/fr-FR/plugins/local.md new file mode 100644 index 000000000..f1d07bad3 --- /dev/null +++ b/docs/fr-FR/plugins/local.md @@ -0,0 +1,100 @@ +# koishi-plugin-booru-local + +超快的本地图源支持 + +## Installation + +1. 在 Koishi 中下载并安装本插件,若你还未安装 [Booru 插件](../index.md),请先安装。 + +## 配置项 + +### 全局设置 + +:::tip +此处的配置项可参考[图源全局设置](../config#图源全局设置) +::: + +### 图源设置 + +
+ +#### endpoint + +- 类型: `string[]` + +图源文件夹,支持多个不同的文件夹 + +#### languages + +- 类型: `string[]` +- 默认值: `['zh-CN', 'en']` + +图源支持的语言 + +#### extension + +- 类型: `string[]` +- 默认值: `['.jpg', '.png', '.jpeg', '.gif']` + +支持的图片扩展名 + +#### scraper + +- 类型: `string` +- 默认值: `{filename}-{tag}` + +文件元信息刮削器格式,详见 [刮削器](#刮削器) + +## 刮削器 + +:::tip +该方式需要图片文件名是特定的格式,且为减少边界情况,仅支持使用 `-` 分割 +::: + +这是一个在文件名中指定该图片元信息的方式,以便于插件能够正确的搜索符合需求的图片。 + +### Utilisation + +插件设置中 `scraper` 默认值可得出大致的使用方式 + +### 标签 + +#### `#...#` + +- 类型: `string` +- 默认值: `name` +- 示例: `#name#{fliename}-{tag}` + +(仅在开头有效)指定刮削器的工作方式,目前支持以下几种方式: + +1. `name`: 文件名模式 +2. `meta`(WIP): 文件元信息模式(开发中) + +#### `{filename}` + +- 类型: `string` + +> 当 `{filename}` 被放置在最后时,`+` 将失效(即 `{foo}-{filename}+`) + +文件名 + +#### `{tag}` + +- 类型: `string[]` + +图片拥有的 tag + +#### `{nsfw}`(WIP) + +- 类型: `boolean | 'furry' | 'guro' | 'shota' | 'bl'` +- 默认值: `nsfw=false` + +限制级图片 + +#### `+` + +忽略后续的内容不作为元信息处理 + +#### `.` + +匹配 `.` 开头的隐藏文件,不设置的情况下将忽略隐藏文件 diff --git a/docs/fr-FR/plugins/lolibooru.md b/docs/fr-FR/plugins/lolibooru.md new file mode 100644 index 000000000..4dbd0a0cb --- /dev/null +++ b/docs/fr-FR/plugins/lolibooru.md @@ -0,0 +1,24 @@ +# koishi-plugin-booru-lolibooru + +## Installation + +1. 在 Koishi 中下载并安装本插件,若你还未安装 [Booru 插件](../index.md),请先安装。 + +## 配置项 + +### 全局设置 + +:::tip +此处的配置项可参考[图源全局设置](../config#图源全局设置) +::: + +### 搜索设置 + +
+ +#### endpoint + +- 类型:`string` +- 默认值:`https://lolibooru.moe/` + +Lolibooru 的 API 地址。 diff --git a/docs/fr-FR/plugins/lolicon.md b/docs/fr-FR/plugins/lolicon.md new file mode 100644 index 000000000..c00f2742c --- /dev/null +++ b/docs/fr-FR/plugins/lolicon.md @@ -0,0 +1,34 @@ +# koishi-plugin-booru-lolicon + +## Installation + +1. 在 Koishi 中下载并安装本插件,若你还未安装 [Booru 插件](../index.md),请先安装。 + +## 配置项 + +### 全局设置 + +:::tip +此处的配置项可参考[图源全局设置](../config#图源全局设置) +::: + +### 搜索设置 + +
+ +#### endpoint + +- 类型: `string` +- 默认值: `https://api.lolicon.app/setu/v2` + +#### r18 + +- 类型: `enum` +- 可选值: `'非 R18' | '仅 R18' | '混合'` +- 默认值: `'非 R18'` + +#### proxy + +- 类型: `{ endpoint: string } | string` +- 可选值: `'i.pixiv.re' | 'i.pixiv.cat'` +- 默认值: `'i.pixiv.re'` diff --git a/docs/fr-FR/plugins/pixiv.md b/docs/fr-FR/plugins/pixiv.md new file mode 100644 index 000000000..d9ccca9f5 --- /dev/null +++ b/docs/fr-FR/plugins/pixiv.md @@ -0,0 +1,40 @@ +# koishi-plugin-booru-pixiv + +## Installation + +1. 在 Koishi 中下载并安装本插件,若你还未安装 [Booru 插件](../index.md),请先安装。 +2. 在 [Pixiv](https://www.pixiv.net/) 注册账号并登录。 +3. 使用 [Pixiv OAuth Script](https://gist.github.com/ZipFile/c9ebedb224406f4f11845ab700124362) 脚本获取 `Refresh Token`。 +4. 将 `Refresh Token` 填入配置项中的 `token` 项。 + +## 配置项 + +### 全局设置 + +:::tip +此处的配置项可参考[图源全局设置](../config#图源全局设置) +::: + +### 搜索设置 + +
+ +#### token + +- 类型:`string` +- 是否必填:是 + +Pixiv APP API 的 `Refresh Token`。 + +#### minBookmarks + +- 类型: `number` +- 默认值: `0` + +最少收藏数 + +#### proxy + +- 类型: `{ endpoint: string } | string` +- 可选值: `'i.pixiv.re' | 'i.pixiv.cat'` +- 默认值: `'i.pixiv.re'` diff --git a/docs/fr-FR/plugins/safebooru.md b/docs/fr-FR/plugins/safebooru.md new file mode 100644 index 000000000..57f5c31d0 --- /dev/null +++ b/docs/fr-FR/plugins/safebooru.md @@ -0,0 +1,24 @@ +# koishi-plugin-booru-safebooru + +## Installation + +1. 在 Koishi 中下载并安装本插件,若你还未安装 [Booru 插件](../index.md),请先安装。 + +## 配置项 + +### 全局设置 + +:::tip +此处的配置项可参考[图源全局设置](../config#图源全局设置) +::: + +### 搜索设置 + +
+ +#### endpoint + +- 类型:`string` +- 默认值:`https://safebooru.org/index.php` + +Safebooru 的 API 地址。 diff --git a/docs/fr-FR/plugins/sankaku.md b/docs/fr-FR/plugins/sankaku.md new file mode 100644 index 000000000..2ede19200 --- /dev/null +++ b/docs/fr-FR/plugins/sankaku.md @@ -0,0 +1,24 @@ +# koishi-plugin-booru-sankaku + +## Installation + +1. 在 Koishi 中下载并安装本插件,若你还未安装 [Booru 插件](../index.md),请先安装。 + +## 配置项 + +### 全局设置 + +:::tip +此处的配置项可参考[图源全局设置](../config#图源全局设置) +::: + +### 搜索设置 + +
+ +#### endpoint + +- 类型:`string` +- 默认值:`https://capi-v2.sankakucomplex.com/` + +SankakuComplex 的 API 地址。 diff --git a/docs/fr-FR/plugins/yande.md b/docs/fr-FR/plugins/yande.md new file mode 100644 index 000000000..6e5ffa2ff --- /dev/null +++ b/docs/fr-FR/plugins/yande.md @@ -0,0 +1,24 @@ +# koishi-plugin-booru-yande + +## Installation + +1. 在 Koishi 中下载并安装本插件,若你还未安装 [Booru 插件](../index.md),请先安装。 + +## 配置项 + +### 全局设置 + +:::tip +此处的配置项可参考[图源全局设置](../config#图源全局设置) +::: + +### 搜索设置 + +
+ +#### endpoint + +- 类型:`string` +- 默认值:`https://yande.re/` + +Yande 的 API 地址。 diff --git a/docs/fr-FR/usage.md b/docs/fr-FR/usage.md new file mode 100644 index 000000000..1bb74894e --- /dev/null +++ b/docs/fr-FR/usage.md @@ -0,0 +1,23 @@ +# Utilisation + +## commande + +`booru` 插件会注册名为 `booru` 的指令,用于搜索图片,只需在指令后面跟上搜索关键词即可。当搜索关键词为空时,会返回随机图片。 + +::: tip +每个图源插件都有适用语言,当你打开了 [`detectLanguage`](./config.md#detectlanguage) 选项时,`booru` 插件会自动检测你的语言并使用对应的图源插件。 + +如 [`danbooru`](./plugins/danbooru.md), [`gelbooru`](./plugins/gelbooru.md) 等图源插件仅支持英语 (en),而 [`pixiv`](./plugins/pixiv.md) 则支持日语 (ja)、英语 (en)、简体与繁体中文 (zh) 和韩语 (ko),但大部分情况下日语 (ja) 会有更好的效果。 +::: + + +booru komeiji koishi + + + + + + +
+
+
diff --git a/docs/ja-JP/config.md b/docs/ja-JP/config.md new file mode 100644 index 000000000..7c4764e83 --- /dev/null +++ b/docs/ja-JP/config.md @@ -0,0 +1,56 @@ +# 配置项 + +## 搜索设置 + +### detectLanguage + +- 类型: `boolean` +- 默认值: `false` + +是否自动检测语言。 + +当启用此选项时,插件会自动检测输入的 tag 的语言,并选择提供了相应语言支持的图源进行检索。 + +### confidence + +- 类型: `number` +- 默认值: `0.5` + +当 `detectLanguage` 启用时,此选项用于设置语言检测的置信度阈值。 + +### maxCount + +- 类型: `number` +- 默认值: `10` + +设置全局检索允许的最大图片数量。 + +## 输出设置 + +## output + +- 类型: `enum` +- 可选值:`仅发送图片`、`发送图片和相关信息`、`发送图片、相关信息和链接`、`发送全部信息` +- 默认值: `发送图片和相关信息` + +设置输出的信息。 + +## 图源全局设置 + +:::tip +此项设置存在于图源插件中而非全局设置里,因此可以针对不同的图源设置不同的配置。 +::: + +### label + +- 类型: `string` +- 默认值: `图源名称` + +图源标签,可用于在指令中手动指定图源。 + +### weight + +- 类型: `number` +- 默认值: `1` + +图源权重。在多个符合标签的图源中,将按照各自的权重随机选择。 diff --git a/docs/ja-JP/develop/api.md b/docs/ja-JP/develop/api.md new file mode 100644 index 000000000..19a54b603 --- /dev/null +++ b/docs/ja-JP/develop/api.md @@ -0,0 +1,80 @@ +# API + +## 服务方法 + +### `ctx.booru.register()` + +```ts +ctx.booru.register(source: ImageSource): () => boolean +``` + +注册一个图源,返回一个 dispose 函数,调用此函数可以注销此图源。 + +### `ctx.booru.hasSource()` + +```ts +ctx.booru.hasSource(name?: string): boolean +``` + +当不传入参数时,判断是否存在激活的图源;当传入参数时,判断是否存在指定名称的图源。 + +### `ctx.booru.get()` + +```ts +ctx.booru.get(query: ImageService.Query): Promise +``` + +获取符合条件的图片,返回一个 Promise,resolve 时返回一个图片数组。 + +当 `query.tags` 为空时,应当返回随机的图片。 + +当获取不到图片时,应当返回 `undefined`。 + +## 类型定义 + +### `ImageSource` + +```ts +export abstract class ImageSource { + languages: string[] = ['en'] // 图源支持的语言 + + constructor(public ctx: Context, public config: Config) { + this.ctx.booru.register(this) + } + + // 对标签进行分词,返回一个标签数组 + tokenize(query: string): string[] + + // 获取图片 + abstract get(query: ImageSource.Query): Promise +} +``` + + +### `ImageSource.Query` + +```ts +export interface Query { + tags: string[] + /** raw query */ + raw: string + count: number +} +``` + +### `ImageSource.Result` + +```ts +export type NsfwType = 'furry' | 'guro' | 'shota' | 'bl' + +export interface Result { + url: string + pageUrl?: string + author?: string + authorUrl?: string + title?: string + desc?: string + tags?: string[] + nsfw?: boolean | NsfwType +} +``` diff --git a/docs/ja-JP/develop/service.md b/docs/ja-JP/develop/service.md new file mode 100644 index 000000000..7c9ade069 --- /dev/null +++ b/docs/ja-JP/develop/service.md @@ -0,0 +1,65 @@ +# Service + +`booru` 插件会注册名为 `booru` 的服务,可以被其他插件调用。 + +## 检测图源 + +`booru` 服务提供了 `hasSource()` 方法,可以用于判断是否存在任意图源,或是否存在指定的图源。 + +```ts +import { Context } from 'koishi' + +export function apply(ctx: Context) { + ctx.booru.hasSource() // 是否存在任意图源 + ctx.boooru.hasSource('pixiv') // 是否存在 pixiv 图源 +} +``` + +## 获取图片 + +`booru` 服务提供了 `get()` 方法,可以用于获取图片。 + +```tsx +import { Context } from 'koishi' + +export function apply(ctx: Context) { + ctx.command('恋恋最可爱').action(async () => { + const image = await ctx.booru.get({ tags: 'komeiji koishi', raw: 'komeiji koishi', count: 1 }) + return + }) +} +``` + + +恋恋最可爱 + + + + + + +
+
+
+ +## 注册图源 + +`booru` 服务提供了 `register()` 方法,可以用于注册图源。 + +```ts +import { Context } from 'koishi' + +class PixivSource extends ImageSource { + name = 'pixiv' + async get(query) { + // ... + } +} + +export function apply(ctx: Context, config: Config) { + // 注册图源 + const dispose = ctx.booru.register(new PixivSource(ctx, config)) + // 注销图源 + dispose() +} +``` diff --git a/docs/ja-JP/develop/source.md b/docs/ja-JP/develop/source.md new file mode 100644 index 000000000..ec6a62d59 --- /dev/null +++ b/docs/ja-JP/develop/source.md @@ -0,0 +1,98 @@ +# 图源 + +## 介绍 + +图源插件是用于获取图片的插件,它可以从网络、本地文件、剪贴板、数据库等地方获取图片。 + +由于图源插件本身也是一个标准的 [Koishi 插件](https://koishi.chat/zh-CN/guide/plugin/#%E6%8F%92%E4%BB%B6%E7%9A%84%E5%9F%BA%E6%9C%AC%E5%BD%A2%E5%BC%8F),这意味着它必须导出一个函数,或者一个带有 `apply` 方法的对象。为了方便开发,我们提供了一个抽象类 `ImageSource`,当你继承它并实现相应方法后以默认方式导出,就可以作为 Koishi 插件被加载,这有助于插件作者快速开发图源插件。 + +## 准备工作 + +在此,我们将假设你已经阅读了[认识插件](https://koishi.chat/zh-CN/guide/plugin/),并且配置好了 Koishi 插件的开发环境。 + +图源插件需要继承的 `ImageSource` 类定义在 `koishi-plugin-booru` 包中,因此你需要将 `koishi-plugin-booru` 插件列为你的图源插件的对等依赖 (peerDependencies)。 + +```json +{ + "peerDependencies": { + "booru": "^1.0.3" + } +} +``` + +**请根据你所需求的功能酌情升级对等依赖的 booru 插件的版本** + +## 开发图源插件 + +此处以简化版的 `lolicon` 插件为例,可以从 `https://api.lolicon.net/` 的 API 获取图片及元信息。 + +```ts +import { Context, Schema } from 'koishi' +import { ImageSource } from 'koishi-plugin-booru' + +class LoliconImageSource extends ImageSource { + // 定义图源支持的语言 + // 如 lolicon 支持日语、英语和汉语-简体中文等 + languages: string[] = ['en', 'zh-CN', 'ja'] + + constructor(ctx: Context, config: LoliconImageSource.Config) { + // 调用父类的拟构函数以注册图源 + super(ctx, config) + } + + // `booru` 默认将标签转换为类 `danbooru` 的形式,即「空格分割标签,下划线替代空格」。 + // 而 lolicon 支持的标签不带空格,因此此处需要将其重载为空格分割。 + override tokenize(query: string): string[] { + return query.split(/\s+/) + } + + async get(query: ImageSource.Query): Promise { + const param = { + // `tags` 是一个字符串数组,根据 Lolicon API 的文档,传入数组等于「与」操作。 + tag: query.tags, + // 指定获取数量 + num: query.count, + } + // 注:根据图源设计规范,当 `query.tags` 为空数组或空时,应当返回随机图片。 + // 由于 Lolicon API 默认对空标签会返回随机图,因此不需要做特别处理, + // 但对于其他图源可能需要传入特别的参数才能使用随机图片功能。 + const resp = await this.ctx.http.post('https://api.lolicon.app/setu/v2', param) + + if (!Array.isArray(resp.data)) { + return + } + + // 返回类型为 `Result` 的数组,可用字段可参考类型提示。 + // 其中 `url` 字段是图片的地址,也可以是 `base64` 编码。 + return resp.data.map((setu) => { + return { + url: setu.urls.original, + title: setu.title, + author: setu.author, + nsfw: setu.r18, + tags: setu.tags, + pageUrl: `https://pixiv.net/i/${setu.pid}`, + } + }) + } +} + +// 图源插件还需要导出配置项,因此我们采用 TypeScript 的 namespace +// 将配置项 Config 与上面的 class 定义合并。 +namespace LoliconImageSource { + export interface Config extends ImageSource.Config {} + + export const Config: Schema = Schema.intersect([ + // 结合使用 `Svchema.intersect` 和 `createSchema` 辅助函数, + // 向图源插件的配置项里添加全局的通用配置,`label` 一般为图源插件名。 + ImageSource.createSchema({ label: 'lolicon' }), + ]) +} + +// 以默认导出方式导出整个命名空间 +export default LoliconImageSource +``` + +:::tip +上述代码为介绍与解释 `booru` 图源的开发步骤有一定简化,你可以直接在 [GitHub](https://github.com/koishijs/koishi-plugin-booru/tree/main/packages/lolicon) 上阅读 lolicon 插件真正的源码。 +::: diff --git a/docs/ja-JP/index.md b/docs/ja-JP/index.md new file mode 100644 index 000000000..72053dbed --- /dev/null +++ b/docs/ja-JP/index.md @@ -0,0 +1,35 @@ +# 介绍 + +> 「最好的涩图插件!」 —— Shigma + +Booru 是一个基于 [Koishi](https://koishi.chat/) 的图片检索插件,支持多个图源站点。 + +:::tip +你需要安装至少一个图源插件才能使用 Booru 插件。 +::: + +## 特性 + +- 支持多个[图源站点](#图源插件) +- 支持多种发送方式 +- 支持随机检索 + +## 图源插件 + +Booru 插件支持多个图源站点,每个图源站点都有一个对应的插件。目前支持的图源站点有: + +| 图源 | プラグイン | +| -------------------------------------------------- | --------------------------------------------------------- | +| [Danbooru](https://danbooru.donmai.us/) | [`koishi-plugin-booru-danbooru`](./plugins/danbooru.md) | +| [e621](https://e621.net/) | [`koishi-plugin-booru-e621`](./plugins/e621.md) | +| [e926](https://e926.net/) | [`koishi-plugin-booru-e621`](./plugins/e621.md) | +| [Gelbooru](https://gelbooru.com/) | [`koishi-plugin-booru-gelbooru`](./plugins/gelbooru.md) | +| [Konachan](https://konachan.com/) | [`koishi-plugin-booru-konachan`](./plugins/konachan.md) | +| [Konachan.net](https://konachan.net/) | [`koishi-plugin-booru-konachan`](./plugins/konachan.md) | +| [Lolibooru](https://lolibooru.moe/) | [`koishi-plugin-booru-lolibooru`](./plugins/lolibooru.md) | +| [Lolicon](https://lolicon.app/) | [`koishi-plugin-booru-lolicon`](./plugins/lolicon.md) | +| [Pixiv](https://www.pixiv.net/) | [`koishi-plugin-booru-pixiv`](./plugins/pixiv.md) | +| [Safebooru](https://safebooru.org/) | [`koishi-plugin-booru-safebooru`](./plugins/safebooru.md) | +| [SankakuComplex](https://chan.sankakucomplex.com/) | [`koishi-plugin-booru-sankaku`](./plugins/sankaku.md) | +| [Yande.re](https://yande.re/) | [`koishi-plugin-booru-yande`](./plugins/yande.md) | +| 本地文件夹 | [`koishi-plugin-booru-local`](./plugins/local.md) | diff --git a/docs/ja-JP/plugins/danbooru.md b/docs/ja-JP/plugins/danbooru.md new file mode 100644 index 000000000..bf0c8dafa --- /dev/null +++ b/docs/ja-JP/plugins/danbooru.md @@ -0,0 +1,24 @@ +# koishi-plugin-booru-danbooru + +## インストール + +1. 在 Koishi 中下载并安装本插件,若你还未安装 [Booru 插件](../index.md),请先安装。 + +## 配置项 + +### 全局设置 + +:::tip +此处的配置项可参考[图源全局设置](../config#图源全局设置) +::: + +### 搜索设置 + +
+ +#### endpoint + +- 类型:`string` +- 默认值:`https://danbooru.donmai.us` + +Danbooru 的 API 地址。 diff --git a/docs/ja-JP/plugins/e621.md b/docs/ja-JP/plugins/e621.md new file mode 100644 index 000000000..08dc4e340 --- /dev/null +++ b/docs/ja-JP/plugins/e621.md @@ -0,0 +1,31 @@ +# koishi-plugin-booru-e621 + +## インストール + +1. 在 Koishi 中下载并安装本插件,若你还未安装 [Booru 插件](../index.md),请先安装。 + +## 配置项 + +### 全局设置 + +:::tip +此处的配置项可参考[图源全局设置](../config#图源全局设置) +::: + +### 搜索设置 + +
+ +#### userAgent + +- 类型:`string` +- 默认值:`Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36 Edg/114.0.1823.37` + +请求时所使用的 User-Agent + +#### endpoint + +- 类型:`string` +- 默认值:`https://e621.net` + +e621/e926 的 API 地址。 diff --git a/docs/ja-JP/plugins/gelbooru.md b/docs/ja-JP/plugins/gelbooru.md new file mode 100644 index 000000000..3108db8b4 --- /dev/null +++ b/docs/ja-JP/plugins/gelbooru.md @@ -0,0 +1,24 @@ +# koishi-plugin-booru-gelbooru + +## インストール + +1. 在 Koishi 中下载并安装本插件,若你还未安装 [Booru 插件](../index.md),请先安装。 + +## 配置项 + +### 全局设置 + +:::tip +此处的配置项可参考[图源全局设置](../config#图源全局设置) +::: + +### 搜索设置 + +
+ +#### endpoint + +- 类型:`string` +- 默认值:`https://gelbooru.com/index.php` + +Gelbooru 的 API 地址。 diff --git a/docs/ja-JP/plugins/konachan.md b/docs/ja-JP/plugins/konachan.md new file mode 100644 index 000000000..35a14c53f --- /dev/null +++ b/docs/ja-JP/plugins/konachan.md @@ -0,0 +1,24 @@ +# koishi-plugin-booru-konachan + +## インストール + +1. 在 Koishi 中下载并安装本插件,若你还未安装 [Booru 插件](../index.md),请先安装。 + +## 配置项 + +### 全局设置 + +:::tip +此处的配置项可参考[图源全局设置](../config#图源全局设置) +::: + +### 搜索设置 + +
+ +#### endpoint + +- 类型:`string` +- 默认值:`https://konachan.com/` + +Konachan 的 API 地址。 diff --git a/docs/ja-JP/plugins/local.md b/docs/ja-JP/plugins/local.md new file mode 100644 index 000000000..a356c6730 --- /dev/null +++ b/docs/ja-JP/plugins/local.md @@ -0,0 +1,100 @@ +# koishi-plugin-booru-local + +超快的本地图源支持 + +## インストール + +1. 在 Koishi 中下载并安装本插件,若你还未安装 [Booru 插件](../index.md),请先安装。 + +## 配置项 + +### 全局设置 + +:::tip +此处的配置项可参考[图源全局设置](../config#图源全局设置) +::: + +### 图源设置 + +
+ +#### endpoint + +- 类型: `string[]` + +图源文件夹,支持多个不同的文件夹 + +#### languages + +- 类型: `string[]` +- 默认值: `['zh-CN', 'en']` + +图源支持的语言 + +#### extension + +- 类型: `string[]` +- 默认值: `['.jpg', '.png', '.jpeg', '.gif']` + +支持的图片扩展名 + +#### scraper + +- 类型: `string` +- 默认值: `{filename}-{tag}` + +文件元信息刮削器格式,详见 [刮削器](#刮削器) + +## 刮削器 + +:::tip +该方式需要图片文件名是特定的格式,且为减少边界情况,仅支持使用 `-` 分割 +::: + +这是一个在文件名中指定该图片元信息的方式,以便于插件能够正确的搜索符合需求的图片。 + +### 使用 + +插件设置中 `scraper` 默认值可得出大致的使用方式 + +### 标签 + +#### `#...#` + +- 类型: `string` +- 默认值: `name` +- 示例: `#name#{fliename}-{tag}` + +(仅在开头有效)指定刮削器的工作方式,目前支持以下几种方式: + +1. `name`: 文件名模式 +2. `meta`(WIP): 文件元信息模式(开发中) + +#### `{filename}` + +- 类型: `string` + +> 当 `{filename}` 被放置在最后时,`+` 将失效(即 `{foo}-{filename}+`) + +文件名 + +#### `{tag}` + +- 类型: `string[]` + +图片拥有的 tag + +#### `{nsfw}`(WIP) + +- 类型: `boolean | 'furry' | 'guro' | 'shota' | 'bl'` +- 默认值: `nsfw=false` + +限制级图片 + +#### `+` + +忽略后续的内容不作为元信息处理 + +#### `.` + +匹配 `.` 开头的隐藏文件,不设置的情况下将忽略隐藏文件 diff --git a/docs/ja-JP/plugins/lolibooru.md b/docs/ja-JP/plugins/lolibooru.md new file mode 100644 index 000000000..9a7b9a494 --- /dev/null +++ b/docs/ja-JP/plugins/lolibooru.md @@ -0,0 +1,24 @@ +# koishi-plugin-booru-lolibooru + +## インストール + +1. 在 Koishi 中下载并安装本插件,若你还未安装 [Booru 插件](../index.md),请先安装。 + +## 配置项 + +### 全局设置 + +:::tip +此处的配置项可参考[图源全局设置](../config#图源全局设置) +::: + +### 搜索设置 + +
+ +#### endpoint + +- 类型:`string` +- 默认值:`https://lolibooru.moe/` + +Lolibooru 的 API 地址。 diff --git a/docs/ja-JP/plugins/lolicon.md b/docs/ja-JP/plugins/lolicon.md new file mode 100644 index 000000000..c035cbe19 --- /dev/null +++ b/docs/ja-JP/plugins/lolicon.md @@ -0,0 +1,34 @@ +# koishi-plugin-booru-lolicon + +## インストール + +1. 在 Koishi 中下载并安装本插件,若你还未安装 [Booru 插件](../index.md),请先安装。 + +## 配置项 + +### 全局设置 + +:::tip +此处的配置项可参考[图源全局设置](../config#图源全局设置) +::: + +### 搜索设置 + +
+ +#### endpoint + +- 类型: `string` +- 默认值: `https://api.lolicon.app/setu/v2` + +#### r18 + +- 类型: `enum` +- 可选值: `'非 R18' | '仅 R18' | '混合'` +- 默认值: `'非 R18'` + +#### proxy + +- 类型: `{ endpoint: string } | string` +- 可选值: `'i.pixiv.re' | 'i.pixiv.cat'` +- 默认值: `'i.pixiv.re'` diff --git a/docs/ja-JP/plugins/pixiv.md b/docs/ja-JP/plugins/pixiv.md new file mode 100644 index 000000000..784488bee --- /dev/null +++ b/docs/ja-JP/plugins/pixiv.md @@ -0,0 +1,40 @@ +# koishi-plugin-booru-pixiv + +## インストール + +1. 在 Koishi 中下载并安装本插件,若你还未安装 [Booru 插件](../index.md),请先安装。 +2. 在 [Pixiv](https://www.pixiv.net/) 注册账号并登录。 +3. 使用 [Pixiv OAuth Script](https://gist.github.com/ZipFile/c9ebedb224406f4f11845ab700124362) 脚本获取 `Refresh Token`。 +4. 将 `Refresh Token` 填入配置项中的 `token` 项。 + +## 配置项 + +### 全局设置 + +:::tip +此处的配置项可参考[图源全局设置](../config#图源全局设置) +::: + +### 搜索设置 + +
+ +#### token + +- 类型:`string` +- 是否必填:是 + +Pixiv APP API 的 `Refresh Token`。 + +#### minBookmarks + +- 类型: `number` +- 默认值: `0` + +最少收藏数 + +#### proxy + +- 类型: `{ endpoint: string } | string` +- 可选值: `'i.pixiv.re' | 'i.pixiv.cat'` +- 默认值: `'i.pixiv.re'` diff --git a/docs/ja-JP/plugins/safebooru.md b/docs/ja-JP/plugins/safebooru.md new file mode 100644 index 000000000..720832e70 --- /dev/null +++ b/docs/ja-JP/plugins/safebooru.md @@ -0,0 +1,24 @@ +# koishi-plugin-booru-safebooru + +## インストール + +1. 在 Koishi 中下载并安装本插件,若你还未安装 [Booru 插件](../index.md),请先安装。 + +## 配置项 + +### 全局设置 + +:::tip +此处的配置项可参考[图源全局设置](../config#图源全局设置) +::: + +### 搜索设置 + +
+ +#### endpoint + +- 类型:`string` +- 默认值:`https://safebooru.org/index.php` + +Safebooru 的 API 地址。 diff --git a/docs/ja-JP/plugins/sankaku.md b/docs/ja-JP/plugins/sankaku.md new file mode 100644 index 000000000..1f6d0bb01 --- /dev/null +++ b/docs/ja-JP/plugins/sankaku.md @@ -0,0 +1,24 @@ +# koishi-plugin-booru-sankaku + +## インストール + +1. 在 Koishi 中下载并安装本插件,若你还未安装 [Booru 插件](../index.md),请先安装。 + +## 配置项 + +### 全局设置 + +:::tip +此处的配置项可参考[图源全局设置](../config#图源全局设置) +::: + +### 搜索设置 + +
+ +#### endpoint + +- 类型:`string` +- 默认值:`https://capi-v2.sankakucomplex.com/` + +SankakuComplex 的 API 地址。 diff --git a/docs/ja-JP/plugins/yande.md b/docs/ja-JP/plugins/yande.md new file mode 100644 index 000000000..050d8d6a8 --- /dev/null +++ b/docs/ja-JP/plugins/yande.md @@ -0,0 +1,24 @@ +# koishi-plugin-booru-yande + +## インストール + +1. 在 Koishi 中下载并安装本插件,若你还未安装 [Booru 插件](../index.md),请先安装。 + +## 配置项 + +### 全局设置 + +:::tip +此处的配置项可参考[图源全局设置](../config#图源全局设置) +::: + +### 搜索设置 + +
+ +#### endpoint + +- 类型:`string` +- 默认值:`https://yande.re/` + +Yande 的 API 地址。 diff --git a/docs/ja-JP/usage.md b/docs/ja-JP/usage.md new file mode 100644 index 000000000..e4b9917c8 --- /dev/null +++ b/docs/ja-JP/usage.md @@ -0,0 +1,23 @@ +# 使用 + +## コマンド + +`booru` 插件会注册名为 `booru` 的指令,用于搜索图片,只需在指令后面跟上搜索关键词即可。当搜索关键词为空时,会返回随机图片。 + +::: tip +每个图源插件都有适用语言,当你打开了 [`detectLanguage`](./config.md#detectlanguage) 选项时,`booru` 插件会自动检测你的语言并使用对应的图源插件。 + +如 [`danbooru`](./plugins/danbooru.md), [`gelbooru`](./plugins/gelbooru.md) 等图源插件仅支持英语 (en),而 [`pixiv`](./plugins/pixiv.md) 则支持日语 (ja)、英语 (en)、简体与繁体中文 (zh) 和韩语 (ko),但大部分情况下日语 (ja) 会有更好的效果。 +::: + + +booru komeiji koishi + + + + + + +
+
+
diff --git a/docs/public/manifest/de-DE.json b/docs/public/manifest/de-DE.json new file mode 100644 index 000000000..9a02c21b4 --- /dev/null +++ b/docs/public/manifest/de-DE.json @@ -0,0 +1,16 @@ +{ + "name": "koishi-plugin-booru", + "short_name": "Booru", + "description": "Bildersuche", + "start_url": "/zh-CN/", + "display": "standalone", + "background_color": "#ffffff", + "theme_color": "#5546a3", + "icons": [ + { + "src": "https://koishi.chat/logo.png", + "sizes": "384x384", + "type": "image/png" + } + ] +} diff --git a/docs/public/manifest/en-US.json b/docs/public/manifest/en-US.json new file mode 100644 index 000000000..4cef8f8fd --- /dev/null +++ b/docs/public/manifest/en-US.json @@ -0,0 +1,16 @@ +{ + "name": "koishi-plugin-booru", + "short_name": "Booru", + "description": "A lot of image galleries, whatever you want.", + "start_url": "/en-US/", + "display": "standalone", + "background_color": "#ffffff", + "theme_color": "#5546a3", + "icons": [ + { + "src": "https://koishi.chat/logo.png", + "sizes": "384x384", + "type": "image/png" + } + ] +} diff --git a/docs/public/manifest/fr-FR.json b/docs/public/manifest/fr-FR.json new file mode 100644 index 000000000..b5ee7d335 --- /dev/null +++ b/docs/public/manifest/fr-FR.json @@ -0,0 +1,16 @@ +{ + "name": "koishi-plugin-booru", + "short_name": "Booru", + "description": "Recherche des images, c'est très bien !", + "start_url": "/zh-CN/", + "display": "standalone", + "background_color": "#ffffff", + "theme_color": "#5546a3", + "icons": [ + { + "src": "https://koishi.chat/logo.png", + "sizes": "384x384", + "type": "image/png" + } + ] +} diff --git a/docs/public/manifest/ja-JP.json b/docs/public/manifest/ja-JP.json new file mode 100644 index 000000000..21181fb07 --- /dev/null +++ b/docs/public/manifest/ja-JP.json @@ -0,0 +1,16 @@ +{ + "name": "koishi-plugin-booru", + "short_name": "Booru", + "description": "最高な画像検索プラグイン!", + "start_url": "/zh-CN/", + "display": "standalone", + "background_color": "#ffffff", + "theme_color": "#5546a3", + "icons": [ + { + "src": "https://koishi.chat/logo.png", + "sizes": "384x384", + "type": "image/png" + } + ] +} diff --git a/docs/public/manifest/ru-RU.json b/docs/public/manifest/ru-RU.json new file mode 100644 index 000000000..a72713f34 --- /dev/null +++ b/docs/public/manifest/ru-RU.json @@ -0,0 +1,16 @@ +{ + "name": "koishi-plugin-booru", + "short_name": "Booru", + "description": "Вы хотите немного рисунок?", + "start_url": "/zh-CN/", + "display": "standalone", + "background_color": "#ffffff", + "theme_color": "#5546a3", + "icons": [ + { + "src": "https://koishi.chat/logo.png", + "sizes": "384x384", + "type": "image/png" + } + ] +} diff --git a/docs/public/manifest/zh-TW.json b/docs/public/manifest/zh-TW.json new file mode 100644 index 000000000..423e61610 --- /dev/null +++ b/docs/public/manifest/zh-TW.json @@ -0,0 +1,16 @@ +{ + "name": "koishi-plugin-booru", + "short_name": "Booru", + "description": "最好的圖像檢索外掛程式!", + "start_url": "/zh-CN/", + "display": "standalone", + "background_color": "#ffffff", + "theme_color": "#5546a3", + "icons": [ + { + "src": "https://koishi.chat/logo.png", + "sizes": "384x384", + "type": "image/png" + } + ] +} diff --git a/docs/ru-RU/config.md b/docs/ru-RU/config.md new file mode 100644 index 000000000..7c4764e83 --- /dev/null +++ b/docs/ru-RU/config.md @@ -0,0 +1,56 @@ +# 配置项 + +## 搜索设置 + +### detectLanguage + +- 类型: `boolean` +- 默认值: `false` + +是否自动检测语言。 + +当启用此选项时,插件会自动检测输入的 tag 的语言,并选择提供了相应语言支持的图源进行检索。 + +### confidence + +- 类型: `number` +- 默认值: `0.5` + +当 `detectLanguage` 启用时,此选项用于设置语言检测的置信度阈值。 + +### maxCount + +- 类型: `number` +- 默认值: `10` + +设置全局检索允许的最大图片数量。 + +## 输出设置 + +## output + +- 类型: `enum` +- 可选值:`仅发送图片`、`发送图片和相关信息`、`发送图片、相关信息和链接`、`发送全部信息` +- 默认值: `发送图片和相关信息` + +设置输出的信息。 + +## 图源全局设置 + +:::tip +此项设置存在于图源插件中而非全局设置里,因此可以针对不同的图源设置不同的配置。 +::: + +### label + +- 类型: `string` +- 默认值: `图源名称` + +图源标签,可用于在指令中手动指定图源。 + +### weight + +- 类型: `number` +- 默认值: `1` + +图源权重。在多个符合标签的图源中,将按照各自的权重随机选择。 diff --git a/docs/ru-RU/develop/api.md b/docs/ru-RU/develop/api.md new file mode 100644 index 000000000..19a54b603 --- /dev/null +++ b/docs/ru-RU/develop/api.md @@ -0,0 +1,80 @@ +# API + +## 服务方法 + +### `ctx.booru.register()` + +```ts +ctx.booru.register(source: ImageSource): () => boolean +``` + +注册一个图源,返回一个 dispose 函数,调用此函数可以注销此图源。 + +### `ctx.booru.hasSource()` + +```ts +ctx.booru.hasSource(name?: string): boolean +``` + +当不传入参数时,判断是否存在激活的图源;当传入参数时,判断是否存在指定名称的图源。 + +### `ctx.booru.get()` + +```ts +ctx.booru.get(query: ImageService.Query): Promise +``` + +获取符合条件的图片,返回一个 Promise,resolve 时返回一个图片数组。 + +当 `query.tags` 为空时,应当返回随机的图片。 + +当获取不到图片时,应当返回 `undefined`。 + +## 类型定义 + +### `ImageSource` + +```ts +export abstract class ImageSource { + languages: string[] = ['en'] // 图源支持的语言 + + constructor(public ctx: Context, public config: Config) { + this.ctx.booru.register(this) + } + + // 对标签进行分词,返回一个标签数组 + tokenize(query: string): string[] + + // 获取图片 + abstract get(query: ImageSource.Query): Promise +} +``` + + +### `ImageSource.Query` + +```ts +export interface Query { + tags: string[] + /** raw query */ + raw: string + count: number +} +``` + +### `ImageSource.Result` + +```ts +export type NsfwType = 'furry' | 'guro' | 'shota' | 'bl' + +export interface Result { + url: string + pageUrl?: string + author?: string + authorUrl?: string + title?: string + desc?: string + tags?: string[] + nsfw?: boolean | NsfwType +} +``` diff --git a/docs/ru-RU/develop/service.md b/docs/ru-RU/develop/service.md new file mode 100644 index 000000000..6378cbc2d --- /dev/null +++ b/docs/ru-RU/develop/service.md @@ -0,0 +1,65 @@ +# 服务 + +`booru` 插件会注册名为 `booru` 的服务,可以被其他插件调用。 + +## 检测图源 + +`booru` 服务提供了 `hasSource()` 方法,可以用于判断是否存在任意图源,或是否存在指定的图源。 + +```ts +import { Context } from 'koishi' + +export function apply(ctx: Context) { + ctx.booru.hasSource() // 是否存在任意图源 + ctx.boooru.hasSource('pixiv') // 是否存在 pixiv 图源 +} +``` + +## 获取图片 + +`booru` 服务提供了 `get()` 方法,可以用于获取图片。 + +```tsx +import { Context } from 'koishi' + +export function apply(ctx: Context) { + ctx.command('恋恋最可爱').action(async () => { + const image = await ctx.booru.get({ tags: 'komeiji koishi', raw: 'komeiji koishi', count: 1 }) + return + }) +} +``` + + +恋恋最可爱 + + + + + + +
+
+
+ +## 注册图源 + +`booru` 服务提供了 `register()` 方法,可以用于注册图源。 + +```ts +import { Context } from 'koishi' + +class PixivSource extends ImageSource { + name = 'pixiv' + async get(query) { + // ... + } +} + +export function apply(ctx: Context, config: Config) { + // 注册图源 + const dispose = ctx.booru.register(new PixivSource(ctx, config)) + // 注销图源 + dispose() +} +``` diff --git a/docs/ru-RU/develop/source.md b/docs/ru-RU/develop/source.md new file mode 100644 index 000000000..ec6a62d59 --- /dev/null +++ b/docs/ru-RU/develop/source.md @@ -0,0 +1,98 @@ +# 图源 + +## 介绍 + +图源插件是用于获取图片的插件,它可以从网络、本地文件、剪贴板、数据库等地方获取图片。 + +由于图源插件本身也是一个标准的 [Koishi 插件](https://koishi.chat/zh-CN/guide/plugin/#%E6%8F%92%E4%BB%B6%E7%9A%84%E5%9F%BA%E6%9C%AC%E5%BD%A2%E5%BC%8F),这意味着它必须导出一个函数,或者一个带有 `apply` 方法的对象。为了方便开发,我们提供了一个抽象类 `ImageSource`,当你继承它并实现相应方法后以默认方式导出,就可以作为 Koishi 插件被加载,这有助于插件作者快速开发图源插件。 + +## 准备工作 + +在此,我们将假设你已经阅读了[认识插件](https://koishi.chat/zh-CN/guide/plugin/),并且配置好了 Koishi 插件的开发环境。 + +图源插件需要继承的 `ImageSource` 类定义在 `koishi-plugin-booru` 包中,因此你需要将 `koishi-plugin-booru` 插件列为你的图源插件的对等依赖 (peerDependencies)。 + +```json +{ + "peerDependencies": { + "booru": "^1.0.3" + } +} +``` + +**请根据你所需求的功能酌情升级对等依赖的 booru 插件的版本** + +## 开发图源插件 + +此处以简化版的 `lolicon` 插件为例,可以从 `https://api.lolicon.net/` 的 API 获取图片及元信息。 + +```ts +import { Context, Schema } from 'koishi' +import { ImageSource } from 'koishi-plugin-booru' + +class LoliconImageSource extends ImageSource { + // 定义图源支持的语言 + // 如 lolicon 支持日语、英语和汉语-简体中文等 + languages: string[] = ['en', 'zh-CN', 'ja'] + + constructor(ctx: Context, config: LoliconImageSource.Config) { + // 调用父类的拟构函数以注册图源 + super(ctx, config) + } + + // `booru` 默认将标签转换为类 `danbooru` 的形式,即「空格分割标签,下划线替代空格」。 + // 而 lolicon 支持的标签不带空格,因此此处需要将其重载为空格分割。 + override tokenize(query: string): string[] { + return query.split(/\s+/) + } + + async get(query: ImageSource.Query): Promise { + const param = { + // `tags` 是一个字符串数组,根据 Lolicon API 的文档,传入数组等于「与」操作。 + tag: query.tags, + // 指定获取数量 + num: query.count, + } + // 注:根据图源设计规范,当 `query.tags` 为空数组或空时,应当返回随机图片。 + // 由于 Lolicon API 默认对空标签会返回随机图,因此不需要做特别处理, + // 但对于其他图源可能需要传入特别的参数才能使用随机图片功能。 + const resp = await this.ctx.http.post('https://api.lolicon.app/setu/v2', param) + + if (!Array.isArray(resp.data)) { + return + } + + // 返回类型为 `Result` 的数组,可用字段可参考类型提示。 + // 其中 `url` 字段是图片的地址,也可以是 `base64` 编码。 + return resp.data.map((setu) => { + return { + url: setu.urls.original, + title: setu.title, + author: setu.author, + nsfw: setu.r18, + tags: setu.tags, + pageUrl: `https://pixiv.net/i/${setu.pid}`, + } + }) + } +} + +// 图源插件还需要导出配置项,因此我们采用 TypeScript 的 namespace +// 将配置项 Config 与上面的 class 定义合并。 +namespace LoliconImageSource { + export interface Config extends ImageSource.Config {} + + export const Config: Schema = Schema.intersect([ + // 结合使用 `Svchema.intersect` 和 `createSchema` 辅助函数, + // 向图源插件的配置项里添加全局的通用配置,`label` 一般为图源插件名。 + ImageSource.createSchema({ label: 'lolicon' }), + ]) +} + +// 以默认导出方式导出整个命名空间 +export default LoliconImageSource +``` + +:::tip +上述代码为介绍与解释 `booru` 图源的开发步骤有一定简化,你可以直接在 [GitHub](https://github.com/koishijs/koishi-plugin-booru/tree/main/packages/lolicon) 上阅读 lolicon 插件真正的源码。 +::: diff --git a/docs/ru-RU/index.md b/docs/ru-RU/index.md new file mode 100644 index 000000000..8afc8f7b8 --- /dev/null +++ b/docs/ru-RU/index.md @@ -0,0 +1,35 @@ +# 介绍 + +> 「最好的涩图插件!」 —— Shigma + +Booru 是一个基于 [Koishi](https://koishi.chat/) 的图片检索插件,支持多个图源站点。 + +:::tip +你需要安装至少一个图源插件才能使用 Booru 插件。 +::: + +## 特性 + +- 支持多个[图源站点](#图源插件) +- 支持多种发送方式 +- 支持随机检索 + +## 图源插件 + +Booru 插件支持多个图源站点,每个图源站点都有一个对应的插件。目前支持的图源站点有: + +| 图源 | 插件 | +| -------------------------------------------------- | --------------------------------------------------------- | +| [Danbooru](https://danbooru.donmai.us/) | [`koishi-plugin-booru-danbooru`](./plugins/danbooru.md) | +| [e621](https://e621.net/) | [`koishi-plugin-booru-e621`](./plugins/e621.md) | +| [e926](https://e926.net/) | [`koishi-plugin-booru-e621`](./plugins/e621.md) | +| [Gelbooru](https://gelbooru.com/) | [`koishi-plugin-booru-gelbooru`](./plugins/gelbooru.md) | +| [Konachan](https://konachan.com/) | [`koishi-plugin-booru-konachan`](./plugins/konachan.md) | +| [Konachan.net](https://konachan.net/) | [`koishi-plugin-booru-konachan`](./plugins/konachan.md) | +| [Lolibooru](https://lolibooru.moe/) | [`koishi-plugin-booru-lolibooru`](./plugins/lolibooru.md) | +| [Lolicon](https://lolicon.app/) | [`koishi-plugin-booru-lolicon`](./plugins/lolicon.md) | +| [Pixiv](https://www.pixiv.net/) | [`koishi-plugin-booru-pixiv`](./plugins/pixiv.md) | +| [Safebooru](https://safebooru.org/) | [`koishi-plugin-booru-safebooru`](./plugins/safebooru.md) | +| [SankakuComplex](https://chan.sankakucomplex.com/) | [`koishi-plugin-booru-sankaku`](./plugins/sankaku.md) | +| [Yande.re](https://yande.re/) | [`koishi-plugin-booru-yande`](./plugins/yande.md) | +| 本地文件夹 | [`koishi-plugin-booru-local`](./plugins/local.md) | diff --git a/docs/ru-RU/plugins/danbooru.md b/docs/ru-RU/plugins/danbooru.md new file mode 100644 index 000000000..d8ff4d321 --- /dev/null +++ b/docs/ru-RU/plugins/danbooru.md @@ -0,0 +1,24 @@ +# koishi-plugin-booru-danbooru + +## 安装 + +1. 在 Koishi 中下载并安装本插件,若你还未安装 [Booru 插件](../index.md),请先安装。 + +## 配置项 + +### 全局设置 + +:::tip +此处的配置项可参考[图源全局设置](../config#图源全局设置) +::: + +### 搜索设置 + +
+ +#### endpoint + +- 类型:`string` +- 默认值:`https://danbooru.donmai.us` + +Danbooru 的 API 地址。 diff --git a/docs/ru-RU/plugins/e621.md b/docs/ru-RU/plugins/e621.md new file mode 100644 index 000000000..11886a73e --- /dev/null +++ b/docs/ru-RU/plugins/e621.md @@ -0,0 +1,31 @@ +# koishi-plugin-booru-e621 + +## 安装 + +1. 在 Koishi 中下载并安装本插件,若你还未安装 [Booru 插件](../index.md),请先安装。 + +## 配置项 + +### 全局设置 + +:::tip +此处的配置项可参考[图源全局设置](../config#图源全局设置) +::: + +### 搜索设置 + +
+ +#### userAgent + +- 类型:`string` +- 默认值:`Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36 Edg/114.0.1823.37` + +请求时所使用的 User-Agent + +#### endpoint + +- 类型:`string` +- 默认值:`https://e621.net` + +e621/e926 的 API 地址。 diff --git a/docs/ru-RU/plugins/gelbooru.md b/docs/ru-RU/plugins/gelbooru.md new file mode 100644 index 000000000..71b0ed6d2 --- /dev/null +++ b/docs/ru-RU/plugins/gelbooru.md @@ -0,0 +1,24 @@ +# koishi-plugin-booru-gelbooru + +## 安装 + +1. 在 Koishi 中下载并安装本插件,若你还未安装 [Booru 插件](../index.md),请先安装。 + +## 配置项 + +### 全局设置 + +:::tip +此处的配置项可参考[图源全局设置](../config#图源全局设置) +::: + +### 搜索设置 + +
+ +#### endpoint + +- 类型:`string` +- 默认值:`https://gelbooru.com/index.php` + +Gelbooru 的 API 地址。 diff --git a/docs/ru-RU/plugins/konachan.md b/docs/ru-RU/plugins/konachan.md new file mode 100644 index 000000000..24533f002 --- /dev/null +++ b/docs/ru-RU/plugins/konachan.md @@ -0,0 +1,24 @@ +# koishi-plugin-booru-konachan + +## 安装 + +1. 在 Koishi 中下载并安装本插件,若你还未安装 [Booru 插件](../index.md),请先安装。 + +## 配置项 + +### 全局设置 + +:::tip +此处的配置项可参考[图源全局设置](../config#图源全局设置) +::: + +### 搜索设置 + +
+ +#### endpoint + +- 类型:`string` +- 默认值:`https://konachan.com/` + +Konachan 的 API 地址。 diff --git a/docs/ru-RU/plugins/local.md b/docs/ru-RU/plugins/local.md new file mode 100644 index 000000000..615901cb0 --- /dev/null +++ b/docs/ru-RU/plugins/local.md @@ -0,0 +1,100 @@ +# koishi-plugin-booru-local + +超快的本地图源支持 + +## 安装 + +1. 在 Koishi 中下载并安装本插件,若你还未安装 [Booru 插件](../index.md),请先安装。 + +## 配置项 + +### 全局设置 + +:::tip +此处的配置项可参考[图源全局设置](../config#图源全局设置) +::: + +### 图源设置 + +
+ +#### endpoint + +- 类型: `string[]` + +图源文件夹,支持多个不同的文件夹 + +#### languages + +- 类型: `string[]` +- 默认值: `['zh-CN', 'en']` + +图源支持的语言 + +#### extension + +- 类型: `string[]` +- 默认值: `['.jpg', '.png', '.jpeg', '.gif']` + +支持的图片扩展名 + +#### scraper + +- 类型: `string` +- 默认值: `{filename}-{tag}` + +文件元信息刮削器格式,详见 [刮削器](#刮削器) + +## 刮削器 + +:::tip +该方式需要图片文件名是特定的格式,且为减少边界情况,仅支持使用 `-` 分割 +::: + +这是一个在文件名中指定该图片元信息的方式,以便于插件能够正确的搜索符合需求的图片。 + +### 使用 + +插件设置中 `scraper` 默认值可得出大致的使用方式 + +### 标签 + +#### `#...#` + +- 类型: `string` +- 默认值: `name` +- 示例: `#name#{fliename}-{tag}` + +(仅在开头有效)指定刮削器的工作方式,目前支持以下几种方式: + +1. `name`: 文件名模式 +2. `meta`(WIP): 文件元信息模式(开发中) + +#### `{filename}` + +- 类型: `string` + +> 当 `{filename}` 被放置在最后时,`+` 将失效(即 `{foo}-{filename}+`) + +文件名 + +#### `{tag}` + +- 类型: `string[]` + +图片拥有的 tag + +#### `{nsfw}`(WIP) + +- 类型: `boolean | 'furry' | 'guro' | 'shota' | 'bl'` +- 默认值: `nsfw=false` + +限制级图片 + +#### `+` + +忽略后续的内容不作为元信息处理 + +#### `.` + +匹配 `.` 开头的隐藏文件,不设置的情况下将忽略隐藏文件 diff --git a/docs/ru-RU/plugins/lolibooru.md b/docs/ru-RU/plugins/lolibooru.md new file mode 100644 index 000000000..77a1c8f22 --- /dev/null +++ b/docs/ru-RU/plugins/lolibooru.md @@ -0,0 +1,24 @@ +# koishi-plugin-booru-lolibooru + +## 安装 + +1. 在 Koishi 中下载并安装本插件,若你还未安装 [Booru 插件](../index.md),请先安装。 + +## 配置项 + +### 全局设置 + +:::tip +此处的配置项可参考[图源全局设置](../config#图源全局设置) +::: + +### 搜索设置 + +
+ +#### endpoint + +- 类型:`string` +- 默认值:`https://lolibooru.moe/` + +Lolibooru 的 API 地址。 diff --git a/docs/ru-RU/plugins/lolicon.md b/docs/ru-RU/plugins/lolicon.md new file mode 100644 index 000000000..d4bbefc69 --- /dev/null +++ b/docs/ru-RU/plugins/lolicon.md @@ -0,0 +1,34 @@ +# koishi-plugin-booru-lolicon + +## 安装 + +1. 在 Koishi 中下载并安装本插件,若你还未安装 [Booru 插件](../index.md),请先安装。 + +## 配置项 + +### 全局设置 + +:::tip +此处的配置项可参考[图源全局设置](../config#图源全局设置) +::: + +### 搜索设置 + +
+ +#### endpoint + +- 类型: `string` +- 默认值: `https://api.lolicon.app/setu/v2` + +#### r18 + +- 类型: `enum` +- 可选值: `'非 R18' | '仅 R18' | '混合'` +- 默认值: `'非 R18'` + +#### proxy + +- 类型: `{ endpoint: string } | string` +- 可选值: `'i.pixiv.re' | 'i.pixiv.cat'` +- 默认值: `'i.pixiv.re'` diff --git a/docs/ru-RU/plugins/pixiv.md b/docs/ru-RU/plugins/pixiv.md new file mode 100644 index 000000000..b609b4875 --- /dev/null +++ b/docs/ru-RU/plugins/pixiv.md @@ -0,0 +1,40 @@ +# koishi-plugin-booru-pixiv + +## 安装 + +1. 在 Koishi 中下载并安装本插件,若你还未安装 [Booru 插件](../index.md),请先安装。 +2. 在 [Pixiv](https://www.pixiv.net/) 注册账号并登录。 +3. 使用 [Pixiv OAuth Script](https://gist.github.com/ZipFile/c9ebedb224406f4f11845ab700124362) 脚本获取 `Refresh Token`。 +4. 将 `Refresh Token` 填入配置项中的 `token` 项。 + +## 配置项 + +### 全局设置 + +:::tip +此处的配置项可参考[图源全局设置](../config#图源全局设置) +::: + +### 搜索设置 + +
+ +#### token + +- 类型:`string` +- 是否必填:是 + +Pixiv APP API 的 `Refresh Token`。 + +#### minBookmarks + +- 类型: `number` +- 默认值: `0` + +最少收藏数 + +#### proxy + +- 类型: `{ endpoint: string } | string` +- 可选值: `'i.pixiv.re' | 'i.pixiv.cat'` +- 默认值: `'i.pixiv.re'` diff --git a/docs/ru-RU/plugins/safebooru.md b/docs/ru-RU/plugins/safebooru.md new file mode 100644 index 000000000..c8ada6776 --- /dev/null +++ b/docs/ru-RU/plugins/safebooru.md @@ -0,0 +1,24 @@ +# koishi-plugin-booru-safebooru + +## 安装 + +1. 在 Koishi 中下载并安装本插件,若你还未安装 [Booru 插件](../index.md),请先安装。 + +## 配置项 + +### 全局设置 + +:::tip +此处的配置项可参考[图源全局设置](../config#图源全局设置) +::: + +### 搜索设置 + +
+ +#### endpoint + +- 类型:`string` +- 默认值:`https://safebooru.org/index.php` + +Safebooru 的 API 地址。 diff --git a/docs/ru-RU/plugins/sankaku.md b/docs/ru-RU/plugins/sankaku.md new file mode 100644 index 000000000..88c94ee7f --- /dev/null +++ b/docs/ru-RU/plugins/sankaku.md @@ -0,0 +1,24 @@ +# koishi-plugin-booru-sankaku + +## 安装 + +1. 在 Koishi 中下载并安装本插件,若你还未安装 [Booru 插件](../index.md),请先安装。 + +## 配置项 + +### 全局设置 + +:::tip +此处的配置项可参考[图源全局设置](../config#图源全局设置) +::: + +### 搜索设置 + +
+ +#### endpoint + +- 类型:`string` +- 默认值:`https://capi-v2.sankakucomplex.com/` + +SankakuComplex 的 API 地址。 diff --git a/docs/ru-RU/plugins/yande.md b/docs/ru-RU/plugins/yande.md new file mode 100644 index 000000000..192ebe914 --- /dev/null +++ b/docs/ru-RU/plugins/yande.md @@ -0,0 +1,24 @@ +# koishi-plugin-booru-yande + +## 安装 + +1. 在 Koishi 中下载并安装本插件,若你还未安装 [Booru 插件](../index.md),请先安装。 + +## 配置项 + +### 全局设置 + +:::tip +此处的配置项可参考[图源全局设置](../config#图源全局设置) +::: + +### 搜索设置 + +
+ +#### endpoint + +- 类型:`string` +- 默认值:`https://yande.re/` + +Yande 的 API 地址。 diff --git a/docs/ru-RU/usage.md b/docs/ru-RU/usage.md new file mode 100644 index 000000000..6a84d7ed1 --- /dev/null +++ b/docs/ru-RU/usage.md @@ -0,0 +1,23 @@ +# 使用 + +## 指令 + +`booru` 插件会注册名为 `booru` 的指令,用于搜索图片,只需在指令后面跟上搜索关键词即可。当搜索关键词为空时,会返回随机图片。 + +::: tip +每个图源插件都有适用语言,当你打开了 [`detectLanguage`](./config.md#detectlanguage) 选项时,`booru` 插件会自动检测你的语言并使用对应的图源插件。 + +如 [`danbooru`](./plugins/danbooru.md), [`gelbooru`](./plugins/gelbooru.md) 等图源插件仅支持英语 (en),而 [`pixiv`](./plugins/pixiv.md) 则支持日语 (ja)、英语 (en)、简体与繁体中文 (zh) 和韩语 (ko),但大部分情况下日语 (ja) 会有更好的效果。 +::: + + +booru komeiji koishi + + + + + + +
+
+
diff --git a/docs/zh-TW/config.md b/docs/zh-TW/config.md new file mode 100644 index 000000000..7c4764e83 --- /dev/null +++ b/docs/zh-TW/config.md @@ -0,0 +1,56 @@ +# 配置项 + +## 搜索设置 + +### detectLanguage + +- 类型: `boolean` +- 默认值: `false` + +是否自动检测语言。 + +当启用此选项时,插件会自动检测输入的 tag 的语言,并选择提供了相应语言支持的图源进行检索。 + +### confidence + +- 类型: `number` +- 默认值: `0.5` + +当 `detectLanguage` 启用时,此选项用于设置语言检测的置信度阈值。 + +### maxCount + +- 类型: `number` +- 默认值: `10` + +设置全局检索允许的最大图片数量。 + +## 输出设置 + +## output + +- 类型: `enum` +- 可选值:`仅发送图片`、`发送图片和相关信息`、`发送图片、相关信息和链接`、`发送全部信息` +- 默认值: `发送图片和相关信息` + +设置输出的信息。 + +## 图源全局设置 + +:::tip +此项设置存在于图源插件中而非全局设置里,因此可以针对不同的图源设置不同的配置。 +::: + +### label + +- 类型: `string` +- 默认值: `图源名称` + +图源标签,可用于在指令中手动指定图源。 + +### weight + +- 类型: `number` +- 默认值: `1` + +图源权重。在多个符合标签的图源中,将按照各自的权重随机选择。 diff --git a/docs/zh-TW/develop/api.md b/docs/zh-TW/develop/api.md new file mode 100644 index 000000000..19a54b603 --- /dev/null +++ b/docs/zh-TW/develop/api.md @@ -0,0 +1,80 @@ +# API + +## 服务方法 + +### `ctx.booru.register()` + +```ts +ctx.booru.register(source: ImageSource): () => boolean +``` + +注册一个图源,返回一个 dispose 函数,调用此函数可以注销此图源。 + +### `ctx.booru.hasSource()` + +```ts +ctx.booru.hasSource(name?: string): boolean +``` + +当不传入参数时,判断是否存在激活的图源;当传入参数时,判断是否存在指定名称的图源。 + +### `ctx.booru.get()` + +```ts +ctx.booru.get(query: ImageService.Query): Promise +``` + +获取符合条件的图片,返回一个 Promise,resolve 时返回一个图片数组。 + +当 `query.tags` 为空时,应当返回随机的图片。 + +当获取不到图片时,应当返回 `undefined`。 + +## 类型定义 + +### `ImageSource` + +```ts +export abstract class ImageSource { + languages: string[] = ['en'] // 图源支持的语言 + + constructor(public ctx: Context, public config: Config) { + this.ctx.booru.register(this) + } + + // 对标签进行分词,返回一个标签数组 + tokenize(query: string): string[] + + // 获取图片 + abstract get(query: ImageSource.Query): Promise +} +``` + + +### `ImageSource.Query` + +```ts +export interface Query { + tags: string[] + /** raw query */ + raw: string + count: number +} +``` + +### `ImageSource.Result` + +```ts +export type NsfwType = 'furry' | 'guro' | 'shota' | 'bl' + +export interface Result { + url: string + pageUrl?: string + author?: string + authorUrl?: string + title?: string + desc?: string + tags?: string[] + nsfw?: boolean | NsfwType +} +``` diff --git a/docs/zh-TW/develop/service.md b/docs/zh-TW/develop/service.md new file mode 100644 index 000000000..6378cbc2d --- /dev/null +++ b/docs/zh-TW/develop/service.md @@ -0,0 +1,65 @@ +# 服务 + +`booru` 插件会注册名为 `booru` 的服务,可以被其他插件调用。 + +## 检测图源 + +`booru` 服务提供了 `hasSource()` 方法,可以用于判断是否存在任意图源,或是否存在指定的图源。 + +```ts +import { Context } from 'koishi' + +export function apply(ctx: Context) { + ctx.booru.hasSource() // 是否存在任意图源 + ctx.boooru.hasSource('pixiv') // 是否存在 pixiv 图源 +} +``` + +## 获取图片 + +`booru` 服务提供了 `get()` 方法,可以用于获取图片。 + +```tsx +import { Context } from 'koishi' + +export function apply(ctx: Context) { + ctx.command('恋恋最可爱').action(async () => { + const image = await ctx.booru.get({ tags: 'komeiji koishi', raw: 'komeiji koishi', count: 1 }) + return + }) +} +``` + + +恋恋最可爱 + + + + + + +
+
+
+ +## 注册图源 + +`booru` 服务提供了 `register()` 方法,可以用于注册图源。 + +```ts +import { Context } from 'koishi' + +class PixivSource extends ImageSource { + name = 'pixiv' + async get(query) { + // ... + } +} + +export function apply(ctx: Context, config: Config) { + // 注册图源 + const dispose = ctx.booru.register(new PixivSource(ctx, config)) + // 注销图源 + dispose() +} +``` diff --git a/docs/zh-TW/develop/source.md b/docs/zh-TW/develop/source.md new file mode 100644 index 000000000..9cefb9b6f --- /dev/null +++ b/docs/zh-TW/develop/source.md @@ -0,0 +1,98 @@ +# 图源 + +## 介紹 + +图源插件是用于获取图片的插件,它可以从网络、本地文件、剪贴板、数据库等地方获取图片。 + +由于图源插件本身也是一个标准的 [Koishi 插件](https://koishi.chat/zh-CN/guide/plugin/#%E6%8F%92%E4%BB%B6%E7%9A%84%E5%9F%BA%E6%9C%AC%E5%BD%A2%E5%BC%8F),这意味着它必须导出一个函数,或者一个带有 `apply` 方法的对象。为了方便开发,我们提供了一个抽象类 `ImageSource`,当你继承它并实现相应方法后以默认方式导出,就可以作为 Koishi 插件被加载,这有助于插件作者快速开发图源插件。 + +## 准备工作 + +在此,我们将假设你已经阅读了[认识插件](https://koishi.chat/zh-CN/guide/plugin/),并且配置好了 Koishi 插件的开发环境。 + +图源插件需要继承的 `ImageSource` 类定义在 `koishi-plugin-booru` 包中,因此你需要将 `koishi-plugin-booru` 插件列为你的图源插件的对等依赖 (peerDependencies)。 + +```json +{ + "peerDependencies": { + "booru": "^1.0.3" + } +} +``` + +**请根据你所需求的功能酌情升级对等依赖的 booru 插件的版本** + +## 开发图源插件 + +此处以简化版的 `lolicon` 插件为例,可以从 `https://api.lolicon.net/` 的 API 获取图片及元信息。 + +```ts +import { Context, Schema } from 'koishi' +import { ImageSource } from 'koishi-plugin-booru' + +class LoliconImageSource extends ImageSource { + // 定义图源支持的语言 + // 如 lolicon 支持日语、英语和汉语-简体中文等 + languages: string[] = ['en', 'zh-CN', 'ja'] + + constructor(ctx: Context, config: LoliconImageSource.Config) { + // 调用父类的拟构函数以注册图源 + super(ctx, config) + } + + // `booru` 默认将标签转换为类 `danbooru` 的形式,即「空格分割标签,下划线替代空格」。 + // 而 lolicon 支持的标签不带空格,因此此处需要将其重载为空格分割。 + override tokenize(query: string): string[] { + return query.split(/\s+/) + } + + async get(query: ImageSource.Query): Promise { + const param = { + // `tags` 是一个字符串数组,根据 Lolicon API 的文档,传入数组等于「与」操作。 + tag: query.tags, + // 指定获取数量 + num: query.count, + } + // 注:根据图源设计规范,当 `query.tags` 为空数组或空时,应当返回随机图片。 + // 由于 Lolicon API 默认对空标签会返回随机图,因此不需要做特别处理, + // 但对于其他图源可能需要传入特别的参数才能使用随机图片功能。 + const resp = await this.ctx.http.post('https://api.lolicon.app/setu/v2', param) + + if (!Array.isArray(resp.data)) { + return + } + + // 返回类型为 `Result` 的数组,可用字段可参考类型提示。 + // 其中 `url` 字段是图片的地址,也可以是 `base64` 编码。 + return resp.data.map((setu) => { + return { + url: setu.urls.original, + title: setu.title, + author: setu.author, + nsfw: setu.r18, + tags: setu.tags, + pageUrl: `https://pixiv.net/i/${setu.pid}`, + } + }) + } +} + +// 图源插件还需要导出配置项,因此我们采用 TypeScript 的 namespace +// 将配置项 Config 与上面的 class 定义合并。 +namespace LoliconImageSource { + export interface Config extends ImageSource.Config {} + + export const Config: Schema = Schema.intersect([ + // 结合使用 `Svchema.intersect` 和 `createSchema` 辅助函数, + // 向图源插件的配置项里添加全局的通用配置,`label` 一般为图源插件名。 + ImageSource.createSchema({ label: 'lolicon' }), + ]) +} + +// 以默认导出方式导出整个命名空间 +export default LoliconImageSource +``` + +:::tip +上述代码为介绍与解释 `booru` 图源的开发步骤有一定简化,你可以直接在 [GitHub](https://github.com/koishijs/koishi-plugin-booru/tree/main/packages/lolicon) 上阅读 lolicon 插件真正的源码。 +::: diff --git a/docs/zh-TW/index.md b/docs/zh-TW/index.md new file mode 100644 index 000000000..866909c6b --- /dev/null +++ b/docs/zh-TW/index.md @@ -0,0 +1,35 @@ +# 介紹 + +> 「最好的涩图插件!」 —— Shigma + +Booru 是一个基于 [Koishi](https://koishi.chat/) 的图片检索插件,支持多个图源站点。 + +:::tip +你需要安装至少一个图源插件才能使用 Booru 插件。 +::: + +## 特性 + +- 支持多个[图源站点](#图源插件) +- 支持多种发送方式 +- 支持随机检索 + +## 图源插件 + +Booru 插件支持多个图源站点,每个图源站点都有一个对应的插件。目前支持的图源站点有: + +| 图源 | 插件 | +| -------------------------------------------------- | --------------------------------------------------------- | +| [Danbooru](https://danbooru.donmai.us/) | [`koishi-plugin-booru-danbooru`](./plugins/danbooru.md) | +| [e621](https://e621.net/) | [`koishi-plugin-booru-e621`](./plugins/e621.md) | +| [e926](https://e926.net/) | [`koishi-plugin-booru-e621`](./plugins/e621.md) | +| [Gelbooru](https://gelbooru.com/) | [`koishi-plugin-booru-gelbooru`](./plugins/gelbooru.md) | +| [Konachan](https://konachan.com/) | [`koishi-plugin-booru-konachan`](./plugins/konachan.md) | +| [Konachan.net](https://konachan.net/) | [`koishi-plugin-booru-konachan`](./plugins/konachan.md) | +| [Lolibooru](https://lolibooru.moe/) | [`koishi-plugin-booru-lolibooru`](./plugins/lolibooru.md) | +| [Lolicon](https://lolicon.app/) | [`koishi-plugin-booru-lolicon`](./plugins/lolicon.md) | +| [Pixiv](https://www.pixiv.net/) | [`koishi-plugin-booru-pixiv`](./plugins/pixiv.md) | +| [Safebooru](https://safebooru.org/) | [`koishi-plugin-booru-safebooru`](./plugins/safebooru.md) | +| [SankakuComplex](https://chan.sankakucomplex.com/) | [`koishi-plugin-booru-sankaku`](./plugins/sankaku.md) | +| [Yande.re](https://yande.re/) | [`koishi-plugin-booru-yande`](./plugins/yande.md) | +| 本地文件夹 | [`koishi-plugin-booru-local`](./plugins/local.md) | diff --git a/docs/zh-TW/plugins/danbooru.md b/docs/zh-TW/plugins/danbooru.md new file mode 100644 index 000000000..d8ff4d321 --- /dev/null +++ b/docs/zh-TW/plugins/danbooru.md @@ -0,0 +1,24 @@ +# koishi-plugin-booru-danbooru + +## 安装 + +1. 在 Koishi 中下载并安装本插件,若你还未安装 [Booru 插件](../index.md),请先安装。 + +## 配置项 + +### 全局设置 + +:::tip +此处的配置项可参考[图源全局设置](../config#图源全局设置) +::: + +### 搜索设置 + +
+ +#### endpoint + +- 类型:`string` +- 默认值:`https://danbooru.donmai.us` + +Danbooru 的 API 地址。 diff --git a/docs/zh-TW/plugins/e621.md b/docs/zh-TW/plugins/e621.md new file mode 100644 index 000000000..11886a73e --- /dev/null +++ b/docs/zh-TW/plugins/e621.md @@ -0,0 +1,31 @@ +# koishi-plugin-booru-e621 + +## 安装 + +1. 在 Koishi 中下载并安装本插件,若你还未安装 [Booru 插件](../index.md),请先安装。 + +## 配置项 + +### 全局设置 + +:::tip +此处的配置项可参考[图源全局设置](../config#图源全局设置) +::: + +### 搜索设置 + +
+ +#### userAgent + +- 类型:`string` +- 默认值:`Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36 Edg/114.0.1823.37` + +请求时所使用的 User-Agent + +#### endpoint + +- 类型:`string` +- 默认值:`https://e621.net` + +e621/e926 的 API 地址。 diff --git a/docs/zh-TW/plugins/gelbooru.md b/docs/zh-TW/plugins/gelbooru.md new file mode 100644 index 000000000..71b0ed6d2 --- /dev/null +++ b/docs/zh-TW/plugins/gelbooru.md @@ -0,0 +1,24 @@ +# koishi-plugin-booru-gelbooru + +## 安装 + +1. 在 Koishi 中下载并安装本插件,若你还未安装 [Booru 插件](../index.md),请先安装。 + +## 配置项 + +### 全局设置 + +:::tip +此处的配置项可参考[图源全局设置](../config#图源全局设置) +::: + +### 搜索设置 + +
+ +#### endpoint + +- 类型:`string` +- 默认值:`https://gelbooru.com/index.php` + +Gelbooru 的 API 地址。 diff --git a/docs/zh-TW/plugins/konachan.md b/docs/zh-TW/plugins/konachan.md new file mode 100644 index 000000000..24533f002 --- /dev/null +++ b/docs/zh-TW/plugins/konachan.md @@ -0,0 +1,24 @@ +# koishi-plugin-booru-konachan + +## 安装 + +1. 在 Koishi 中下载并安装本插件,若你还未安装 [Booru 插件](../index.md),请先安装。 + +## 配置项 + +### 全局设置 + +:::tip +此处的配置项可参考[图源全局设置](../config#图源全局设置) +::: + +### 搜索设置 + +
+ +#### endpoint + +- 类型:`string` +- 默认值:`https://konachan.com/` + +Konachan 的 API 地址。 diff --git a/docs/zh-TW/plugins/local.md b/docs/zh-TW/plugins/local.md new file mode 100644 index 000000000..615901cb0 --- /dev/null +++ b/docs/zh-TW/plugins/local.md @@ -0,0 +1,100 @@ +# koishi-plugin-booru-local + +超快的本地图源支持 + +## 安装 + +1. 在 Koishi 中下载并安装本插件,若你还未安装 [Booru 插件](../index.md),请先安装。 + +## 配置项 + +### 全局设置 + +:::tip +此处的配置项可参考[图源全局设置](../config#图源全局设置) +::: + +### 图源设置 + +
+ +#### endpoint + +- 类型: `string[]` + +图源文件夹,支持多个不同的文件夹 + +#### languages + +- 类型: `string[]` +- 默认值: `['zh-CN', 'en']` + +图源支持的语言 + +#### extension + +- 类型: `string[]` +- 默认值: `['.jpg', '.png', '.jpeg', '.gif']` + +支持的图片扩展名 + +#### scraper + +- 类型: `string` +- 默认值: `{filename}-{tag}` + +文件元信息刮削器格式,详见 [刮削器](#刮削器) + +## 刮削器 + +:::tip +该方式需要图片文件名是特定的格式,且为减少边界情况,仅支持使用 `-` 分割 +::: + +这是一个在文件名中指定该图片元信息的方式,以便于插件能够正确的搜索符合需求的图片。 + +### 使用 + +插件设置中 `scraper` 默认值可得出大致的使用方式 + +### 标签 + +#### `#...#` + +- 类型: `string` +- 默认值: `name` +- 示例: `#name#{fliename}-{tag}` + +(仅在开头有效)指定刮削器的工作方式,目前支持以下几种方式: + +1. `name`: 文件名模式 +2. `meta`(WIP): 文件元信息模式(开发中) + +#### `{filename}` + +- 类型: `string` + +> 当 `{filename}` 被放置在最后时,`+` 将失效(即 `{foo}-{filename}+`) + +文件名 + +#### `{tag}` + +- 类型: `string[]` + +图片拥有的 tag + +#### `{nsfw}`(WIP) + +- 类型: `boolean | 'furry' | 'guro' | 'shota' | 'bl'` +- 默认值: `nsfw=false` + +限制级图片 + +#### `+` + +忽略后续的内容不作为元信息处理 + +#### `.` + +匹配 `.` 开头的隐藏文件,不设置的情况下将忽略隐藏文件 diff --git a/docs/zh-TW/plugins/lolibooru.md b/docs/zh-TW/plugins/lolibooru.md new file mode 100644 index 000000000..77a1c8f22 --- /dev/null +++ b/docs/zh-TW/plugins/lolibooru.md @@ -0,0 +1,24 @@ +# koishi-plugin-booru-lolibooru + +## 安装 + +1. 在 Koishi 中下载并安装本插件,若你还未安装 [Booru 插件](../index.md),请先安装。 + +## 配置项 + +### 全局设置 + +:::tip +此处的配置项可参考[图源全局设置](../config#图源全局设置) +::: + +### 搜索设置 + +
+ +#### endpoint + +- 类型:`string` +- 默认值:`https://lolibooru.moe/` + +Lolibooru 的 API 地址。 diff --git a/docs/zh-TW/plugins/lolicon.md b/docs/zh-TW/plugins/lolicon.md new file mode 100644 index 000000000..d4bbefc69 --- /dev/null +++ b/docs/zh-TW/plugins/lolicon.md @@ -0,0 +1,34 @@ +# koishi-plugin-booru-lolicon + +## 安装 + +1. 在 Koishi 中下载并安装本插件,若你还未安装 [Booru 插件](../index.md),请先安装。 + +## 配置项 + +### 全局设置 + +:::tip +此处的配置项可参考[图源全局设置](../config#图源全局设置) +::: + +### 搜索设置 + +
+ +#### endpoint + +- 类型: `string` +- 默认值: `https://api.lolicon.app/setu/v2` + +#### r18 + +- 类型: `enum` +- 可选值: `'非 R18' | '仅 R18' | '混合'` +- 默认值: `'非 R18'` + +#### proxy + +- 类型: `{ endpoint: string } | string` +- 可选值: `'i.pixiv.re' | 'i.pixiv.cat'` +- 默认值: `'i.pixiv.re'` diff --git a/docs/zh-TW/plugins/pixiv.md b/docs/zh-TW/plugins/pixiv.md new file mode 100644 index 000000000..b609b4875 --- /dev/null +++ b/docs/zh-TW/plugins/pixiv.md @@ -0,0 +1,40 @@ +# koishi-plugin-booru-pixiv + +## 安装 + +1. 在 Koishi 中下载并安装本插件,若你还未安装 [Booru 插件](../index.md),请先安装。 +2. 在 [Pixiv](https://www.pixiv.net/) 注册账号并登录。 +3. 使用 [Pixiv OAuth Script](https://gist.github.com/ZipFile/c9ebedb224406f4f11845ab700124362) 脚本获取 `Refresh Token`。 +4. 将 `Refresh Token` 填入配置项中的 `token` 项。 + +## 配置项 + +### 全局设置 + +:::tip +此处的配置项可参考[图源全局设置](../config#图源全局设置) +::: + +### 搜索设置 + +
+ +#### token + +- 类型:`string` +- 是否必填:是 + +Pixiv APP API 的 `Refresh Token`。 + +#### minBookmarks + +- 类型: `number` +- 默认值: `0` + +最少收藏数 + +#### proxy + +- 类型: `{ endpoint: string } | string` +- 可选值: `'i.pixiv.re' | 'i.pixiv.cat'` +- 默认值: `'i.pixiv.re'` diff --git a/docs/zh-TW/plugins/safebooru.md b/docs/zh-TW/plugins/safebooru.md new file mode 100644 index 000000000..c8ada6776 --- /dev/null +++ b/docs/zh-TW/plugins/safebooru.md @@ -0,0 +1,24 @@ +# koishi-plugin-booru-safebooru + +## 安装 + +1. 在 Koishi 中下载并安装本插件,若你还未安装 [Booru 插件](../index.md),请先安装。 + +## 配置项 + +### 全局设置 + +:::tip +此处的配置项可参考[图源全局设置](../config#图源全局设置) +::: + +### 搜索设置 + +
+ +#### endpoint + +- 类型:`string` +- 默认值:`https://safebooru.org/index.php` + +Safebooru 的 API 地址。 diff --git a/docs/zh-TW/plugins/sankaku.md b/docs/zh-TW/plugins/sankaku.md new file mode 100644 index 000000000..88c94ee7f --- /dev/null +++ b/docs/zh-TW/plugins/sankaku.md @@ -0,0 +1,24 @@ +# koishi-plugin-booru-sankaku + +## 安装 + +1. 在 Koishi 中下载并安装本插件,若你还未安装 [Booru 插件](../index.md),请先安装。 + +## 配置项 + +### 全局设置 + +:::tip +此处的配置项可参考[图源全局设置](../config#图源全局设置) +::: + +### 搜索设置 + +
+ +#### endpoint + +- 类型:`string` +- 默认值:`https://capi-v2.sankakucomplex.com/` + +SankakuComplex 的 API 地址。 diff --git a/docs/zh-TW/plugins/yande.md b/docs/zh-TW/plugins/yande.md new file mode 100644 index 000000000..192ebe914 --- /dev/null +++ b/docs/zh-TW/plugins/yande.md @@ -0,0 +1,24 @@ +# koishi-plugin-booru-yande + +## 安装 + +1. 在 Koishi 中下载并安装本插件,若你还未安装 [Booru 插件](../index.md),请先安装。 + +## 配置项 + +### 全局设置 + +:::tip +此处的配置项可参考[图源全局设置](../config#图源全局设置) +::: + +### 搜索设置 + +
+ +#### endpoint + +- 类型:`string` +- 默认值:`https://yande.re/` + +Yande 的 API 地址。 diff --git a/docs/zh-TW/usage.md b/docs/zh-TW/usage.md new file mode 100644 index 000000000..6a84d7ed1 --- /dev/null +++ b/docs/zh-TW/usage.md @@ -0,0 +1,23 @@ +# 使用 + +## 指令 + +`booru` 插件会注册名为 `booru` 的指令,用于搜索图片,只需在指令后面跟上搜索关键词即可。当搜索关键词为空时,会返回随机图片。 + +::: tip +每个图源插件都有适用语言,当你打开了 [`detectLanguage`](./config.md#detectlanguage) 选项时,`booru` 插件会自动检测你的语言并使用对应的图源插件。 + +如 [`danbooru`](./plugins/danbooru.md), [`gelbooru`](./plugins/gelbooru.md) 等图源插件仅支持英语 (en),而 [`pixiv`](./plugins/pixiv.md) 则支持日语 (ja)、英语 (en)、简体与繁体中文 (zh) 和韩语 (ko),但大部分情况下日语 (ja) 会有更好的效果。 +::: + + +booru komeiji koishi + + + + + + +
+
+
diff --git a/packages/core/src/locales/de-DE.yml b/packages/core/src/locales/de-DE.yml new file mode 100644 index 000000000..dea88caa6 --- /dev/null +++ b/packages/core/src/locales/de-DE.yml @@ -0,0 +1,27 @@ +commands: + booru: + description: 搜索图片 + options: + label: 指定图源标签 + messages: + no-source: 当前未找到可用图源。请从插件市场添加 booru 系图源插件并启用 (插件名通常以 booru- 开头)。 + no-result: 没有找到符合条件的图片 + no-image: 获取图片失败 + output: + image: + info: | + +

{title}

+

作者: {author}

+

{desc}

+
+ link: | + +

页面地址: {pageUrl}

+

作者主页: {authorUrl}

+
+ source: | + +

图源: {source}

+

标签: {tags}

+
diff --git a/packages/core/src/locales/en-US.yml b/packages/core/src/locales/en-US.yml index cdacc6c6c..5d688147d 100644 --- a/packages/core/src/locales/en-US.yml +++ b/packages/core/src/locales/en-US.yml @@ -6,6 +6,7 @@ commands: messages: no-source: No available sources were found. Please install and/or enable any booru source plugins from the marketplace (The names of those plugins usually starts with booru-). no-result: No pictures match your query were found. + no-image: 获取图片失败 output: image: info: | diff --git a/packages/core/src/locales/fr-FR.yml b/packages/core/src/locales/fr-FR.yml index 2a7db260e..979e09dba 100644 --- a/packages/core/src/locales/fr-FR.yml +++ b/packages/core/src/locales/fr-FR.yml @@ -6,6 +6,7 @@ commands: messages: no-source: Aucune source images n'est disponible actuellement. Veuillez ajouter et activer plugins source du booru depuis la place de marché (les noms de plugins commencent généralement par « booru- »). no-result: Aucune image correspondante trouvée + no-image: 获取图片失败 output: image: info: | diff --git a/packages/core/src/locales/ja-JP.yml b/packages/core/src/locales/ja-JP.yml index 82c427e3b..4d28bec56 100644 --- a/packages/core/src/locales/ja-JP.yml +++ b/packages/core/src/locales/ja-JP.yml @@ -6,6 +6,7 @@ commands: messages: no-source: ソースプラグインが見つかりませんでした。プラグインマーケットプレイスから booru ソースプラグインを追加及び有効にしてください (一般的に、booru ソースプラグイン名は「booru₋」で始まります)。 no-result: クエリが一致する画像が見つかりません。 + no-image: 获取图片失败 output: image: info: | diff --git a/packages/core/src/locales/ru-RU.yml b/packages/core/src/locales/ru-RU.yml new file mode 100644 index 000000000..bced3736f --- /dev/null +++ b/packages/core/src/locales/ru-RU.yml @@ -0,0 +1,27 @@ +commands: + booru: + description: Поискать картинок + options: + label: 指定图源标签 + messages: + no-source: 当前未找到可用图源。请从插件市场添加 booru 系图源插件并启用 (插件名通常以 booru- 开头)。 + no-result: 没有找到符合条件的图片 + no-image: 获取图片失败 + output: + image: + info: | + +

{title}

+

作者: {author}

+

{desc}

+
+ link: | + +

页面地址: {pageUrl}

+

作者主页: {authorUrl}

+
+ source: | + +

图源: {source}

+

标签: {tags}

+
diff --git a/packages/core/src/locales/zh-TW.yml b/packages/core/src/locales/zh-TW.yml new file mode 100644 index 000000000..dea88caa6 --- /dev/null +++ b/packages/core/src/locales/zh-TW.yml @@ -0,0 +1,27 @@ +commands: + booru: + description: 搜索图片 + options: + label: 指定图源标签 + messages: + no-source: 当前未找到可用图源。请从插件市场添加 booru 系图源插件并启用 (插件名通常以 booru- 开头)。 + no-result: 没有找到符合条件的图片 + no-image: 获取图片失败 + output: + image: + info: | + +

{title}

+

作者: {author}

+

{desc}

+
+ link: | + +

页面地址: {pageUrl}

+

作者主页: {authorUrl}

+
+ source: | + +

图源: {source}

+

标签: {tags}

+