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-image-selecter

v0.3.4

Published

A powerful Koishi plugin for random image/video sending and user image storage with alias system support

Readme

koishi-plugin-image-selecter

npm

功能特性

🎲 随机发图

  • 根据完整别名片段随机发送图片或视频
  • 支持多别名系统(用 - 分割)
  • 别名重复时提示冲突,并要求使用特有别名
  • 自动识别图片和视频格式

📁 用户存图

  • 支持多种存图方式:直接传图、回复消息、交互式输入
  • 自定义文件名模板
  • 支持多种图片和视频格式
  • 基于 MIME 类型的智能文件扩展名检测

🔧 高度可配置

  • 自定义存图指令名称
  • 灵活的文件名模板系统
  • 可配置的超时时间
  • 调试模式支持

文件名模板变量

文件名模板支持以下变量:

| 变量 | 说明 | 示例 | | -------------- | ------------------- | ---------------------- | | ${userId} | 用户ID(QQ号) | 123456789 | | ${username} | 用户名 | 张三 | | ${timestamp} | 时间戳 | 1640995200001 | | ${date} | 日期(YYYY-MM-DD) | 2024-01-01 | | ${time} | 时间(HH-MM-SS) | 14-30-25 | | ${index} | 文件序号(从1开始) | 1, 2, 3 | | ${ext} | 文件扩展名 | .jpg, .png, .mp4 | | ${guildId} | 群组ID | 987654321 | | ${channelId} | 频道ID | 111222333 |

文件名模板示例

${userId}-${timestamp}-${index}${ext}
→ 123456789-1640995200001-1.jpg

${nickname}_${date}_${time}${ext}
→ 张三_2024-01-01_14-30-25.png

${guildId}_${userId}_${index}${ext}
→ 987654321_123456789_1.gif

文件结构

推荐的目录结构

项目根目录/
├── images/                    # 图片库目录(imagePath 配置)
│   ├── 角色1-别名1-别名2/      # 文件夹名用 - 分割别名
│   │   ├── image1.jpg
│   │   ├── image2.png
│   │   └── video1.mp4
│   ├── 角色2-萌妹-可爱/
│   │   ├── cute1.gif
│   │   └── cute2.webp
│   ├── 风景-自然-山水/
│   │   ├── nature1.jpg
│   │   └── nature2.png
│   └── 动物-猫咪-喵星人/
│       ├── cat1.jpg
│       ├── cat2.gif
│       └── cat_video.mp4
└── temp/                      # 临时存储目录(tempPath 配置)
    ├── 123456789-1640995200001-1.jpg
    ├── 123456789-1640995200002-2.png
    └── 987654321-1640995200003-1.mp4

别名系统说明

文件夹名称使用 - 分割多个别名。发图时必须完整匹配某个别名片段或完整文件夹名,不能使用片段中的部分文字:

文件夹名: 角色1-别名1-别名2
用户输入: 角色1  ✅ 匹配
用户输入: 别名1  ✅ 匹配
用户输入: 别名2  ✅ 匹配
用户输入: 其他   ❌ 不匹配

例如文件夹名为 第一-第二-第三,输入 第一第二第三 或完整文件夹名可以匹配,输入 不可以匹配。

别名重名处理

当多个文件夹包含相同别名时,发图不会随机选择文件夹,而是:

  1. 列出所有匹配的文件夹
  2. 找出每个文件夹独有的别名
  3. 提示用户使用独有别名重新发图
文件夹:
├── 第一-第二-第三/
└── 第二-第三-第四/

用户输入: 第三
→ 提示匹配到两个文件夹
→ 提示使用特有别名:第一、第四

使用方法

存图功能

1. 直接传图

存图 [图片1] [图片2] [图片3]

2. 回复消息存图

用户A: [发送图片]
用户B: 存图  # 回复用户A的消息

3. 交互式存图

用户: 存图
机器人: 请发送图片或视频
用户: [发送图片]
机器人: 已保存 1 个文件到临时文件夹

发图功能

直接发送完整且不重复的别名片段即可触发随机发图:

用户: 角色1
机器人: [发送随机图片]

用户: 萌妹
机器人: [发送随机图片]

用户: 猫咪
机器人: [发送随机图片或视频]

如果输入的是重复别名,例如 第三,机器人会列出匹配到的文件夹,并提示使用 第一第四。如果输入 等不完整名称,则提示没有匹配到对应的名称。

查文件夹

使用 查文件夹 关键词 进行模糊查询。系统会列出所有包含关键词的文件夹,并显示每个文件夹中的图片或视频数量;输入多个关键词时,文件夹需要同时包含这些关键词。

支持的文件格式

图片格式

  • JPEG/JPG
  • PNG
  • GIF
  • WebP
  • BMP
  • TIFF

视频格式

  • MP4
  • MOV
  • AVI

调试模式

启用 debugMode 后,插件会输出详细的调试信息:

[INFO] 收到消息: { userId: '123456789', content: '角色1' }
[INFO] 匹配到的文件夹: ['角色1-别名1-别名2']
[INFO] 选择文件夹: 角色1-别名1-别名2
[INFO] 找到媒体文件数量: 5
[INFO] 随机选择文件: image1.jpg
[INFO] 输入"第三"匹配到多个文件夹,并提示使用特有别名

注意事项

  1. 文件夹命名:使用 - 分割别名,避免使用特殊字符
  2. 路径配置:确保 imagePathtempPath 目录存在且有读写权限
  3. 别名重名:注意查看警告日志,及时调整重名的别名
  4. 文件格式:确保图片和视频文件格式正确
  5. 存储空间:定期清理临时文件夹,避免占用过多存储空间

许可证

MIT License