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 🙏

© 2025 – Pkg Stats / Ryan Hefner

koishi-plugin-image-selecter

v0.1.1

Published

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

Downloads

25

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. 从选定文件夹中随机选择文件
  4. 输出警告日志提醒管理员
文件夹:
├── 敌意-你好-你好啊/
└── 敌意-第一-帝一/

用户输入: 敌意
→ 系统随机选择其中一个文件夹
→ 输出警告: "检测到别名重名: 输入'敌意'匹配到2个文件夹"

使用方法

存图功能

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
[WARN] 检测到别名重名: 输入"敌意"匹配到2个文件夹: 敌意-你好-你好啊, 敌意-第一-帝一

注意事项

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

许可证

MIT License