# koishi-plugin-quote-debug-msg-json-image **Repository Path**: vincent-zyu/koishi-plugin-quote-debug-msg-json-image ## Basic Information - **Project Name**: koishi-plugin-quote-debug-msg-json-image - **Description**: 📋把一条消息的数据结构用json/yaml/toml的格式渲染成图片,🎨支持typst或者markdown。还支持用puppeteer渲染onebot的合并转发成图片🖼️ - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: main - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 1 - **Forks**: 0 - **Created**: 2025-12-12 - **Last Updated**: 2026-03-11 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README  # 📋 koishi-plugin-quote-debug-msg-json-image [](https://www.npmjs.com/package/koishi-plugin-quote-debug-msg-json-image) [](https://www.npmjs.com/package/koishi-plugin-quote-debug-msg-json-image) [](https://github.com/VincentZyuApps/koishi-plugin-quote-debug-msg-json-image) [](https://gitee.com/vincent-zyu/koishi-plugin-quote-debug-msg-json-image)
💬 插件使用问题 / 🐛 Bug反馈 / 👨💻 插件开发交流,欢迎加入QQ群:1085190201 🎉
💡 在群里直接艾特我,回复的更快哦~ ✨
回复一条消息,将其渲染为精美的 JSON/YAML/TOML 格式图片(防止超出聊天平台的文字长度上限)。还支持渲染 OneBot 的合并转发消息为图片。 ## ✨ 功能特性 - 📋 **dump 指令**:将消息对象序列化为 JSON/YAML/TOML 格式,渲染成图片 - 📨 **render-forward 指令**:将合并转发消息渲染成精美的图片 - 🎨 **双渲染引擎**:支持 Typst(推荐)和 Markdown 两种渲染模式 - 🌈 **代码语法高亮**:JSON/YAML/TOML 自动语法着色 - 🧵 **嵌套转发支持**:智能处理多层嵌套的合并转发消息 ## 📦 依赖服务 ```yaml required: - markdownToImage # koishi-plugin-markdown-to-image-service - toImageService # koishi-plugin-to-image-service - node # koishi-plugin-w-node - puppeteer # koishi-plugin-puppeteer ``` 可选依赖(推荐安装以获得最佳 Typst 渲染效果): - `@myriaddreamin/typst-ts-node-compiler` >= 0.7.0-rc2 ### 📋 package.json 依赖详解 以下是本插件的依赖配置及其用途说明: ```json { // === peerDependencies: 宿主环境必须提供的依赖 === // 这些依赖由 Koishi 主程序或其他插件提供,插件不会自己安装 "peerDependencies": { // Typst 编译器 - 将 Typst 源码编译为 SVG/PDF // 用于 dump 指令的 Typst 渲染模式,实现精美排版和代码语法高亮 "@myriaddreamin/typst-ts-node-compiler": ">=0.7.0-rc2", // Koishi 核心框架 - 插件运行的基础环境 "koishi": "^4.18.7", // 图片服务 - 提供 SVG → PNG 转换(resvg)和字体管理 // Typst 编译输出 SVG,需要此服务转换为最终的 PNG 图片 "koishi-plugin-to-image-service": ">=0.1.0", // Node.js 模块加载器 - 动态加载 npm 包 // 用于运行时安全加载 @myriaddreamin/typst-ts-node-compiler "koishi-plugin-w-node": ">=1.0.0" }, // === peerDependenciesMeta: peerDependencies 的元数据 === "peerDependenciesMeta": { // Typst 编译器标记为可选 // 如果用户只使用 Markdown 渲染模式,可以不安装此依赖 "@myriaddreamin/typst-ts-node-compiler": { "optional": true } }, // === dependencies: 插件自带的运行时依赖 === // 这些依赖会随插件一起安装到 node_modules "dependencies": { // TOML 解析器 - 将消息对象序列化为 TOML 格式 // 支持 dump-toml 指令输出 TOML 格式的消息数据 "@iarna/toml": "^2.2.5", // YAML 解析/序列化库 - 将消息对象序列化为 YAML 格式 // 支持 dump-yaml 指令输出 YAML 格式的消息数据 "js-yaml": "^4.1.1", // Markdown 转图片服务 - 将 Markdown 渲染为图片 // 作为 Typst 渲染的备选方案,适合简单快速的场景 "koishi-plugin-markdown-to-image-service": "^1.3.6" }, // === devDependencies: 仅开发时需要的依赖 === // 发布后不会包含在 npm 包中 "devDependencies": { // Typst 编译器(开发版本)- 用于本地开发测试 "@myriaddreamin/typst-ts-node-compiler": "^0.7.0-rc2", // js-yaml 的 TypeScript 类型定义 // 提供 IDE 智能提示和类型检查 "@types/js-yaml": "^4.0.9", // 以下两个服务的开发版本,用于本地测试 "koishi-plugin-to-image-service": "^0.1.5", "koishi-plugin-w-node": "^1.0.1" } } ``` #### 依赖关系图 ``` ┌─────────────────────────────────────────────────────────┐ │ dump 指令渲染流程 │ ├─────────────────────────────────────────────────────────┤ │ │ │ 消息对象 ──┬──▶ JSON (内置) │ │ ├──▶ YAML (js-yaml) │ │ └──▶ TOML (@iarna/toml) │ │ │ │ │ ▼ │ │ ┌─────────────┴─────────────┐ │ │ │ │ │ │ [Typst 模式] [Markdown 模式] │ │ │ │ │ │ typst-ts-node-compiler markdown-to-image-service │ │ (via w-node 动态加载) │ │ │ │ │ │ │ ▼ │ │ │ SVG 输出 │ │ │ │ │ │ │ to-image-service │ │ │ (resvg: SVG → PNG) │ │ │ │ │ │ │ └───────────┬───────────────┘ │ │ ▼ │ │ PNG 图片 │ └─────────────────────────────────────────────────────────┘ ┌─────────────────────────────────────────────────────────┐ │ render-forward 指令渲染流程 │ ├─────────────────────────────────────────────────────────┤ │ │ │ 合并转发消息 ──▶ HTML 生成 ──▶ Puppeteer 截图 ──▶ PNG │ │ │ └─────────────────────────────────────────────────────────┘ ``` ## 🚀 使用方法 ### dump 指令 回复一条消息并发送指令: ``` dump-json # 渲染为 JSON 格式图片 dump-yaml # 渲染为 YAML 格式图片 dump-toml # 渲染为 TOML 格式图片 ``` **可用选项**: - `-m, --mode