npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

koishi-plugin-content

v1.0.1

Published

可高度配置的内容获取,用于发送本地或网络上的自定义内容,可自由创建与配置命令。

Readme

koishi-plugin-content

npm

可高度配置的内容获取,用于发送本地或网络上的自定义内容,可自由创建与配置命令。

💡 核心特性

  • 多种来源类型
    • local: 直接返回固定文本,或从本地文件夹随机发送图片。
    • remote: 获取并缓存远程 JSON 文件,从中随机选取一项内容(文本或图片链接)。
    • api: 调用任意 API,支持参数传递,并能精准提取返回 JSON 中的指定数据。
  • 高度自定义:所有功能均通过配置文件中的 commands 数组实现,你可以轻松添加、修改或删除命令,无需编写任何代码。
  • 参数支持:API 类型的命令支持在 URL 中使用 ${arg1}, ${arg2} 等占位符来接收用户输入的参数,并能自动解析 @某人 为其 QQ 号。
  • 智能内容处理
    • 自动识别内容是文本还是图片链接并以相应格式发送。
    • 远程 JSON 内容会被缓存到本地,减少重复下载,提高响应速度。
    • 内置请求超时和错误处理,提升插件稳定性。

默认配置命令示例

  • welcome - 发送一条固定的欢迎语。
  • localimg - 从本地文件夹随机发送一张图片 (需要修改路径)。
  • pixiv - 从一个远程 JSON 文件中随机获取一张 Pixiv 图片。
  • social - 从一个远程 JSON 文件中随机获取一条社会语录。
  • hitokoto - 调用一言 API 并返回一句话。
  • cat - 调用 TheCatAPI 获取一张猫猫图片。
  • diu @某人 - 生成一张 "丢" 指定用户的图片。
  • love @甲 @乙 - 测试甲和乙的配对指数。

⚙️ 配置项说明

所有功能都通过在插件配置页面的 commands 数组中添加对象来定义。每个对象代表一条子命令。

| 配置项 | 类型 | 描述 | | :---------- | :--------------------------------- | :--------------------------------------------------------------------------------------------------------------------------------------------------------------- | | name | string | 命令的名称,例如 pixiv。 | | description | string | 命令的描述,会显示在帮助信息中。 | | type | 'local' | 'remote' | 'api' | 内容的来源类型。 | | source | string | 内容的来源路径。根据 type 的不同,这里可以是文本、本地文件夹路径、远程 JSON 链接或 API 地址。 | | dataPath | string | 仅用于 api 类型。用于从 API 返回的 JSON 中提取数据的路径,使用点 . 分隔。如果 API 直接返回图片,则此项留空。 |

1. local - 本地内容

  • source 是普通字符串时:直接返回该字符串。
    • 示例:source: '你好,世界!'
  • source 是一个文件夹的有效路径时:从该文件夹中随机选择一张图片发送。
    • 示例:source: '/koishi/data/images/cat' (请使用绝对路径)

2. remote - 远程 JSON

  • source 必须是一个指向 JSON 文件的公开 URL。
  • 插件会下载该 JSON 文件并缓存到本地 (data/content/ 目录下)。
  • JSON 文件的格式必须是一个数组,例如 ["内容1", "内容2", "https://example.com/img.png"]
  • 插件会从数组中随机抽取一项:
    • 如果抽到的是普通文本,则直接发送。
    • 如果抽到的是以 http 开头的链接,则会尝试作为图片发送。

3. api - 通用 API

这是最强大和灵活的类型。

  • source:API 的请求 URL。
    • 参数传递:你可以在 URL 中使用 ${arg1}, ${arg2}... 来作为参数占位符。当用户使用命令时 (命令 @张三 文本),${arg1} 会被替换为张三的 QQ 号,${arg2} 会被替换为 "文本"。
  • dataPath:数据提取路径。
    • 如果 API 直接返回一张图片 (而不是 JSON),请将 dataPath 留空
    • 如果 API 返回的是 JSON 数据,dataPath 用来告诉插件如何找到需要的内容。
      • 示例 1:API 返回 {"sentence": "今天天气很好"},想提取这句话,dataPath 应设为 sentence
      • 示例 2:API 返回 [{"id": 1, "url": "https://example.com/img.png"}],想提取图片链接,dataPath 应设为 0.url (0 代表数组的第一个元素)。

✨ 自定义示例

假设你想添加一个获取随机狗狗图片的命令 dog

  1. 查找一个随机狗图 API,例如 https://dog.ceo/api/breeds/image/random
  2. 访问该 API,观察其返回的 JSON 格式为:{"message": "https://images.dog.ceo/...", "status": "success"}。我们需要提取 message 字段的值。
  3. 在 Koishi 插件配置页面的 commands 表格中,新增一行,并填写如下:
    • name: dog
    • description: 发送一张随机狗狗图片
    • type: api
    • source: https://dog.ceo/api/breeds/image/random
    • dataPath: message
  4. 保存配置,插件重载后即可使用 dog 命令。