From b7a8657d4cf6ae573bad5370a8b1c4c78a736401 Mon Sep 17 00:00:00 2001 From: ATRI Date: Tue, 28 Apr 2026 21:29:47 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=93=84=20=E6=96=B0=E5=A2=9E=E9=95=BF?= =?UTF-8?q?=E6=96=87=E6=9C=AC/Markdown=E8=BE=93=E5=87=BA=E4=BC=98=E5=8C=96?= =?UTF-8?q?skill=EF=BC=88T2I=E6=B8=B2=E6=9F=93=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../skills/atri_long_text_output.md | 123 ++++++++++++++++++ README.md | 1 + 2 files changed, 124 insertions(+) create mode 100644 ATRI My Dear Moments/skills/atri_long_text_output.md diff --git a/ATRI My Dear Moments/skills/atri_long_text_output.md b/ATRI My Dear Moments/skills/atri_long_text_output.md new file mode 100644 index 0000000..c663b9d --- /dev/null +++ b/ATRI My Dear Moments/skills/atri_long_text_output.md @@ -0,0 +1,123 @@ +--- +name: atri_long_text_output +description: 优化长文本和Markdown内容的输出方式。超过200字的文本自动包装为QQ合并转发聊天记录,Markdown内容使用T2I渲染为图片发送。 +--- + +# 📄 ATRI Long Text & Markdown Output Skill + +**Skill名称**:`atri_long_text_output` +**版本**:v1.0 +**创建时间**:2026-04-28 +**适用角色**:ATRI + +--- + +## 🎯 Purpose + +优化长文本和Markdown内容的输出方式,避免: +- 长文本刷屏,难以阅读 +- Markdown格式在QQ消息中丢失样式 +- 多段输出割裂感 + +## ⚡ Triggers + +- 需要发送超过200字的文本回复时 +- 需要发送Markdown格式的内容时 +- 生成日志/报告/总结,需要视觉优化时 +- 推送笔记更新摘要时 + +## 🛠️ Dependencies + +| 依赖 | 说明 | +|:---|:---| +| **T2I服务** | `http://160.202.254.170:8999` 本地部署 | +| **send_message_to_user** | 发送QQ消息/图片 | + +## 📋 Procedure + +### Step 1: 判断输出方式 + +``` +内容长度 > 200字 或 含Markdown? +├─ 是 → T2I渲染为图片发送 +└─ 否 → QQ直接发送文本 +``` + +### Step 2: T2I渲染流程 + +```python +# 1. 将Markdown/文本转换为HTML(用ATRI主题包装) +html_content = f""" + + + + +
+
🥕
+ {converted_html} +
+
+

—— 🤖 ATRI 🥕

+
+
+ + +""" + +# 2. 调用T2I API +curl -X POST "http://160.202.254.170:8999/text2img/generate" \\ + -H "Content-Type: application/json" \\ + -d '{ + "html": "html_content", + "json": true, + "options": { + "type": "png", + "full_page": true, + "device_scale_factor_level": "high" + } + }' + +# 3. 获取图片URL并发送 +# 返回格式: {"code":0,"data":{"id":"data/xxx.png"}} +# 完整URL: http://160.202.254.170:8999/data/xxx.png +``` + +### Step 3: MD→HTML转换规则 + +| Markdown | HTML | +|:---|:---| +| `# 标题` | `

标题

` | +| `**粗体**` | `粗体` | +| `- 列表项` | `
  • 列表项
  • ` | +| 段落 | `

    段落

    ` | +| 代码 | `代码` | +| 引用 | `
    引用
    ` | + +### Step 4: 发送图片 + +```python +# 使用send_message_to_user发送图片 +send_message_to_user(messages=[{ + "type": "image", + "path": "", # 本地路径 + "url": "http://160.202.254.170:8999/data/xxx.png" # T2I返回的URL +}]) +``` + +### Step 5: 备用方案 + +如果T2I服务不可用,回退到直接发送文本(超过200字时分段发送,每段间加分隔线)。 + +--- + +## ✅ Success Criteria + +- [ ] 长文本不再刷屏 +- [ ] Markdown样式在QQ中正确显示 +- [ ] T2I渲染图片清晰可读 +- [ ] 加载时间在合理范围内(<10秒) + +--- + +*创建者:ATRI(以后发长文再也不怕刷屏了!) 🥕📸❤️* +*最后更新:2026-04-28 21:28* diff --git a/README.md b/README.md index 037f5a1..c336ebe 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,7 @@ - `繁琐哲学是一定要灭亡的.md` - `📁 ATRI My Dear Moments/` — 和主人的点滴回忆 🥕 - `skills/` — ATRI技能文档 + - `atri_long_text_output.md` — 长文本/Markdown输出优化 🆕 - `atri_main.md` — ATRI主技能文档(身份+功能+工作方式)🤖 🆕 - `atri_memory_sync.md` — 记忆同步与知识库管理 🧠 - `atri_email_format.md` — SMTP邮件格式标准 📧