koishi-plugin-image-search

Image searching plugin for Koishi

Usage no npm install needed!

<script type="module">
  import koishiPluginImageSearch from 'https://cdn.skypack.dev/koishi-plugin-image-search';
</script>

README

koishi-plugin-image-search

npm

koishi-plugin-image-search 封装了一系列搜图相关的指令,目前支持以下平台:

参考了 Tsuk1ko 的机器人实现。

指令:image-search

  • 别名:搜图

image-search 指令检测当前输入中的全部图片,并依次进行搜索。如果 image-search 所在消息内没有检测到图片,则该指令会给出提示,并对下一条信息中的图片进行处理。

在搜索过程中,image-search 指令会首先使用 saucenao 进行搜索,当相似度低于 60% 时,会在搜索完成后使用 ascii2d 再次搜索。当相似度低于 40% 时,将不会显示 saucenao 本身的搜索结果(但是 ascii2d 的结果会显示)。

指令:saucenao

saucenao 指令是 image-search 指令的子指令。它使用 saucenao 进行图片搜索,机制与上面完全相同,但当相似度较低时不会使用 ascii2d 再次搜索,也不会略去本身的搜索结果。

指令:ascii2d

ascii2d 指令也是 image-search 指令的子指令。它使用 ascii2d 进行图片搜索,机制与上面完全相同。

参数配置

export interface SaucenaoConfig extends CommandConfig {
  /** 相似度较低的认定标准(百分比),默认值为 40 */
  lowSimilarity?: number
  /** 相似度较高的认定标准(百分比),默认值为 60 */
  highSimilarity?: number
  /** SauceNAO 的 APIKey。
    * SauceNAO 的 APIKey 可以通过注册 SauceNAO 账户的方式获取。
    * SauceNAO 账户可以在以下网址注册:
    * https://saucenao.com/user.php
    * 注册后即可在 API 页中获取到 APIKey。
    * saucenaoApiKey 需要以数组的方式填入单个或多个 APIKey,
    * 如果填入多个 APIKey,则可以实现负载均衡
    */
  saucenaoApiKey?: string[]
}

配置项

lowSimilarity

  • 类型: number
  • 默认值: 40

相似度较低的认定标准(百分比)。

highSimilarity

  • 类型: number
  • 默认值: 60

相似度较高的认定标准(百分比)。