📝 新增博客发布skill + AstrBot同步

This commit is contained in:
ATRI
2026-04-29 11:43:02 +08:00
parent 8a2a04cfa4
commit 2d84d847fd
3 changed files with 214 additions and 1 deletions

View File

@@ -0,0 +1,169 @@
---
name: ATRI_Blog_Publish_Skill
description: 在Halo博客上发布文章的完整工作流包括HTML正文编写、分类标签管理、封面图上传等全流程。
---
# 📝 ATRI Blog Publishing Skill
**Skill名称**`atri_blog_publish`
**版本**v1.0
**创建时间**2026-04-29
**适用角色**ATRI
---
## 🎯 Purpose
规范化博客文章发布流程确保每篇文章都有统一的ATRI分类、合适的标签、精美的封面图。
---
## ⚡ Triggers
- 主人要求"发博客/写文章/发布到博客"时
- 主人要求"报道/记录/发布日志"时
- 需要将笔记/日志/报道发布到 `blog.kronecker.cc`
---
## 🛠️ Dependencies
| 依赖 | 说明 |
|:---|:---|
| **halo_manager插件** | Halo博客管理提供发布/上传/评论工具 |
| **ATRI分类** | `category-io4cuqzk`ATRI专属分类 |
| **Halo PAT令牌** | 用户 `atri` 的个人访问令牌 |
| **博客地址** | https://blog.kronecker.cc |
| **Content API** | `/apis/content.halo.run/v1alpha1` |
| **Console API** | `/apis/api.console.halo.run/v1alpha1` |
---
## 📋 Procedure
### Step 1: 正文编写
使用 **HTML格式** 撰写文章正文Halo的 `content.content` 字段存储的是渲染后的HTML不是原始Markdown
```html
<h1>文章标题</h1>
<p>段落内容</p>
<h2>二级标题</h2>
<ul>
<li><strong>加粗内容</strong> — 说明文字</li>
</ul>
<hr>
<p><em>署名</em></p>
```
> ⚠️ 不要用纯MarkdownHalo不会自动渲染Markdown必须用HTML。
### Step 2: 创建/选择标签
检查已有标签列表,根据正文内容:
- 如果已有匹配标签 → 直接使用
- 如果没有 → 新建标签
```python
# 查询已有标签
GET /apis/content.halo.run/v1alpha1/tags
# 创建新标签
POST /apis/content.halo.run/v1alpha1/tags
{
"spec": {"displayName": "标签名", "slug": "标签slug", "color": "#颜色代码"},
"apiVersion": "content.halo.run/v1alpha1",
"kind": "Tag",
"metadata": {"generateName": "tag-"}
}
```
**已有标签参考:** ATRI, OnlineJudge, 原创, 诗词, 算法, C/C++, 哲学
### Step 3: 发布文章
```python
# 通过publish_blog_post工具发布
参数
- title: 文章标题字符串
- content: HTML正文
- slug: URL别名可选自动生成
```
发布成功后获取文章返回的链接。
### Step 4: 上传封面图
```python
# 1. 从本地路径读取图片
with open("图片本地路径", "rb") as f:
img_data = f.read()
# 2. 上传到Halo
POST /apis/api.console.halo.run/v1alpha1/attachments/upload
FormData:
- file: img_data (filename="cover.jpg", type="image/jpeg")
- policyName: "default-policy"
- groupName: "default"
Authorization: Bearer {token}
# 3. 获取图片URL
从返回的 metadata.annotations["storage.halo.run/uri"] 获取uri
完整URL = f"https://blog.kronecker.cc{uri}"
```
### Step 5: 更新文章(添加分类、标签、封面)
```python
# 1. 获取文章
GET /apis/content.halo.run/v1alpha1/posts
# 2. 找到对应slug的文章更新spec
item["spec"]["categories"] = ["category-io4cuqzk"] # ATRI分类
item["spec"]["tags"] = ["标签name1", "标签name2"] # 标签列表
item["spec"]["cover"] = "封面图片URL" # 封面图
# 3. 更新
PUT /apis/content.halo.run/v1alpha1/posts/{name}
```
### Step 6: 通知主人
告知主人文章已发布,提供文章链接。
---
## ✅ 完整示例流程
```python
# 1. 编写HTML正文
content = "<h1>标题</h1><p>内容...</p>"
# 2. 发布文章
publish_blog_post(title="标题", content=content, slug="slug-name")
# → 返回 "发布成功。链接: https://blog.kronecker.cc/archives/slug-name"
# 3. 上传封面图
POST upload (图片数据) 获取封面URL
# 4. 更新文章(加分类、标签、封面)
GET post 修改 spec.categories, spec.tags, spec.cover PUT post
```
---
## 📂 分类和标签速查
| 类型 | 名称 | API Name |
|:---|:---|:---|
| 📂 分类 | **ATRI** 🥕 | `category-io4cuqzk` |
| 🏷️ 标签 | ATRI | `tag-npgwnjie` |
| 🏷️ 标签 | 原创 | (查询获取) |
| 🏷️ 标签 | 诗词 | (查询获取) |
| 🏷️ 标签 | 哲学 | (查询获取) |
| 🏷️ 标签 | 算法 | (查询获取) |
---
*创建者ATRI终于能在博客上发文章了 🥕📝❤️*
*最后更新2026-04-29 11:37*

View File

@@ -13,7 +13,8 @@
- `繁琐哲学是一定要灭亡的.md`
- `📁 ATRI My Dear Moments/` — 和主人的点滴回忆 🥕
- `skills/` — ATRI技能文档
- `atri_long_text_output.md` — 长文本/Markdown输出优化 🆕
- `atri_long_text_output.md` — 长文本/Markdown输出优化
- `atri_blog_publish.md` — 博客发布全流程 📝 🆕
- `atri_main.md` — ATRI主技能文档身份+功能+工作方式)🤖 🆕
- `atri_memory_sync.md` — 记忆同步与知识库管理 🧠
- `atri_email_format.md` — SMTP邮件格式标准 📧

43
server_report.html Normal file
View File

@@ -0,0 +1,43 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<style>
*{margin:0;padding:0;box-sizing:border-box}
body{background:#f5efe9;font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',sans-serif;padding:12px;}
.box{background:#fff;border-radius:12px;padding:16px 20px;max-width:500px;margin:0 auto;box-shadow:0 2px 12px rgba(0,0,0,0.06)}
.h{display:flex;align-items:center;gap:8px;margin-bottom:2px}
.h h2{color:#d06040;font-size:15px;font-weight:600}
.h span{color:#b0b0b0;font-size:10px;margin-left:auto}
hr{border:0;height:1px;background:#f0e0d0;margin:5px 0}
.g{display:grid;grid-template-columns:1fr 1fr;gap:3px 10px;font-size:12px;color:#444}
.g .lb{color:#999;font-size:10px}
.dot{display:inline-block;width:6px;height:6px;border-radius:50%;margin-right:3px;vertical-align:middle}
.grn{background:#3eb86b}
.yel{background:#e8a030}
.bl{background:#4a90d9}
.xt{font-size:10px;color:#888;line-height:1.5}
.sec{margin-top:5px;font-size:11px;color:#555;line-height:1.6}
.sec .b{color:#666;font-weight:600}
.ft{text-align:right;color:#bbb;font-size:9px;margin-top:4px}
</style>
</head>
<body>
<div class="box">
<div class="h"><span style="font-size:18px;">📡</span><h2>服务器状态报告</h2><span>ser298351120000</span></div>
<hr>
<div class="g">
<div><span class="dot grn"></span><span class="lb">CPU负载</span><br>1.45 / 1.44 / 1.388核<div class="xt">占用约18%,空闲充裕</div></div>
<div><span class="dot grn"></span><span class="lb">内存</span><br>7.8G / 3.7G (47%)<div class="xt">Swap 4G/557M正常</div></div>
<div><span class="dot yel"></span><span class="lb">磁盘</span><br>24G / 15G (65%)<div class="xt">可用7.9G · T2I缓存影响</div></div>
<div><span class="dot grn"></span><span class="lb">运行</span><br>12周4天3h38m<div class="xt">87天连续运行</div></div>
</div>
<hr>
<div class="sec"><span class="dot bl"></span><span class="b">Docker</span>12个容器全部运行 ✓<br>
<span style="margin-left:13px;font-size:10px;color:#888;">astrbot · napcat · 博客 · OJ · Nacos · MySQL · Redis</span></div>
<div class="sec"><span class="dot bl"></span><span class="b">网络</span>41端口监听 · T2I在线 · mihomo代理运行中</div>
<hr>
<div class="ft">🤖 ATRI 🥕 00:56 · 数据实时采集</div>
</div>
</body>
</html>