koishi-plugin-custom-image
v0.3.0
Published
Koishi 自定义图片API插件,内置黑丝/动漫举牌
Maintainers
Readme
koishi-plugin-custom-image
项目介绍 (Project Introduction)
中文
这是一个为 Koishi 机器人框架开发的图片获取与趣味生成插件。支持从自定义 API 列表随机获取图片,内置黑丝举牌 (hsjp) 和动漫举牌 (dmjp) 功能,并提供多种发送模式、多引擎下载、智能缓存、请求去重、发送重试、代理设置与自定义请求头等高级特性。
English
A feature-rich image fetching and fun generation plugin for Koishi. It randomly picks one API from your custom list to fetch images, with built-in hsjp and dmjp generation. Advanced features include multiple sending modes, multi-engine downloads, smart caching, deduplication, retry on failure, proxy support, and custom headers.
项目仓库 (Repository)
- GitHub: https://github.com/Minecraft-1314/koishi-plugin-custom-image
- Issues: https://github.com/Minecraft-1314/koishi-plugin-custom-image/issues
核心指令 (Core Commands)
| 指令 (Command) | 说明 (Description) | 示例 (Example) |
|----------------|--------------------|----------------|
| random-image [apis...] | 从自定义 API 列表随机获取一张图片 | random-image 或 random-image https://api.example.com |
| hsjp <msg> [msg1] [msg2] | 生成黑丝举牌图片 | hsjp 我喜欢你 |
| dmjp <text> | 生成动漫举牌图片 | dmjp Koishi 真棒 |
| clear-image-cache | 清空图片缓存 | clear-image-cache |
配置项说明 (Configuration)
配置已按功能分组显示,方便查找:
基本设置
| 配置项 | 类型 | 默认值 | 说明 |
|--------|------|--------|------|
| enable | boolean | true | 启用插件 |
| showWaitingTip | boolean | true | 请求时显示等待提示 |
| hsjpEnabled | boolean | true | 启用黑丝举牌功能 |
| dmjpEnabled | boolean | true | 启用动漫举牌功能 |
| customImageApis | string[] | [] | 自定义图片 API 列表 |
| customImageEnabled | boolean | true | 启用自定义图片功能 |
发送设置
| 配置项 | 类型 | 默认值 | 说明 |
|--------|------|--------|------|
| imageSendMode | 'image' / 'link' / 'file' | 'image' | 图片发送方式:直接发送图片 / 仅发送链接 / 下载后发送文件 |
| showSuccessTip | boolean | true | 请求成功时显示提示 |
| showTimeoutTip | boolean | true | API 超时后给用户提示 |
发送与重试
| 配置项 | 类型 | 默认值 | 说明 |
|--------|------|--------|------|
| ignoreSendError | boolean | true | 忽略发送失败(不抛出异常) |
| retryTimes | number | 3 | 发送失败重试次数 |
| retryInterval | number | 1000 | 重试间隔(毫秒) |
网络与请求
| 配置项 | 类型 | 默认值 | 说明 |
|--------|------|--------|------|
| timeout | number | 180000 | API 请求超时 (ms) |
| imageSendTimeout | number | 180000 | 消息发送超时 (ms) |
| userAgent | string | (Mozilla/5.0 ... Chrome/125.0) | 自定义 User-Agent |
| proxyEnabled | boolean | false | 启用代理 |
| proxyProtocol | 'http' / 'https' | 'http' | 代理协议 |
| proxyHost | string | '127.0.0.1' | 代理地址 |
| proxyPort | number | 7890 | 代理端口 |
| proxyUsername | string | '' | 代理用户名 |
| proxyPassword | string | '' | 代理密码 |
| customHeaders | {name, value}[] | [] | 自定义请求头列表 |
下载引擎与性能
| 配置项 | 类型 | 默认值 | 说明 |
|--------|------|--------|------|
| downloadEngine | 'internal' / 'aria2' / 'downloads' | 'internal' | 下载引擎(仅 file 模式使用) |
| downloadConcurrency | number | 3 | 下载线程数 |
| downloadTimeout | number | 120000 | 统一下载超时 (ms) |
| maxMediaSize | number | 0 | 最大下载文件大小 (MB),0 为不限制 |
| aria2Host | string | '127.0.0.1' | aria2 RPC 地址 |
| aria2Port | number | 6800 | aria2 RPC 端口 |
| aria2Secret | string | '' | aria2 RPC 密钥 |
| resumeDownload | boolean | true | 启用断点续传(仅 aria2 模式) |
缓存与临时文件
| 配置项 | 类型 | 默认值 | 说明 |
|--------|------|--------|------|
| dedupInterval | number | 0 | 去重间隔 (秒),0 表示不去重 |
| cacheDuration | number | 0 | 结果缓存时间 (秒),0 表示不缓存 |
| autoClearCacheInterval | number | 60 | 自动清理缓存间隔(分钟) |
| tempDir | string | ./temp_images | 临时文件目录 |
界面文本
所有提示信息均可自定义,留空则使用内置默认文本。
| 配置项 | 类型 | 默认值 | 说明 |
|--------|------|--------|------|
| waitingTipText | string | '' | 等待提示 |
| successTipText | string | '' | 成功提示 |
| timeoutTipText | string | '' | 超时提示 |
| networkErrorText | string | '' | 网络错误提示 |
| fetchFailedText | string | '' | 获取失败提示 |
| inputErrorText | string | '' | 输入为空提示 |
| inputTooLongText | string | '' | 输入过长提示 |
| cacheClearedText | string | '' | 缓存清理提示 |
| repeatRequestText | string | '' | 重复请求提示 |
项目贡献者 (Contributors)
| 贡献者 (Contributor) | 贡献内容 (Contribution) | |----------------------|-------------------------| | Minecraft-1314 | 插件完整开发 (Complete plugin development) | | 素颜API | 提供 API 接口支持 | | (欢迎提交 PR 加入贡献者列表) | (Welcome to submit PR to join the contributor list) |
许可协议 (License)
本项目采用 MIT 许可证,详情参见 LICENSE 文件。
This project is licensed under the MIT License, see the LICENSE file for details.
支持我们 (Support Us)
如果这个项目对您有帮助,欢迎点亮右上角的 Star ⭐ 支持我们,这将是对所有贡献者最大的鼓励!
If this project is helpful to you, please feel free to star it in the upper right corner ⭐ to support us, which will be the greatest encouragement to all contributors!
