bear-blog-publisher
将博文发布到小熊博客平台。支持用户提供的 Markdown、AI 生成的内容和自动生成的图表。
安装 / 下载方式
TotalClaw CLI推荐
totalclaw skills install shop:totalclaw:totalclaw~cattalk2-bear-blog-publishercURL直接下载,无需登录
curl -fsSL https://skills.taituai.com/api/skills/totalclaw%3Atotalclaw~cattalk2-bear-blog-publisher/file -o cattalk2-bear-blog-publisher.md# Bear Blog Publisher
Publish blog posts to Bear Blog (https://bearblog.dev/).
## Overview
This skill provides automated publishing capabilities for Bear Blog, including optional AI content generation and diagram generation.
## Authentication Methods (Choose One)
### Method 1: OpenClaw Config (Recommended for Personal Use)
Add to your `~/.openclaw/openclaw.json`:
```json
{
"skills": {
"bear-blog-publisher": {
"email": "your@email.com",
"password": "yourpassword"
}
}
}
```
**Security**: File permissions should be set to 600 (readable only by owner).
### Method 2: Environment Variables (Recommended for CI/CD)
```bash
export BEAR_BLOG_EMAIL="your@email.com"
export BEAR_BLOG_PASSWORD="yourpassword"
```
**Security**: Credentials exist only in memory, not written to disk.
### Method 3: Runtime Parameters (Recommended for Multi-User)
Provide credentials when calling the skill:
```python
publisher = BearBlogPublisher(email="user@example.com", password="secret")
```
**Security**: Caller (chat bot, web app, etc.) manages credential lifecycle.
## AI Content Generation (Optional)
To use AI content generation, configure one of the following:
### OpenAI
```bash
export OPENAI_API_KEY="sk-..."
```
### Kimi
```bash
export KIMI_API_KEY="your-kimi-api-key"
```
### Usage
```python
publisher = BearBlogPublisher()
content = publisher.generate_content(
topic="Python best practices",
provider="openai", # or "kimi"
tone="professional",
length="medium"
)
result = publisher.publish(title="My Post", content=content)
```
## Priority Order
1. Runtime parameters (highest priority)
2. Environment variables
3. OpenClaw config (lowest priority)
## Capabilities
### 1. Publish Blog Post
**Input:**
- `title` (string): Blog post title
- `content` (string): Markdown content
- `email` (string, optional): Bear Blog email
- `password` (string, optional): Bear Blog password
**Output:**
- Published URL or error message
### 2. AI Content Generation (Optional)
Generate blog content using OpenAI or Kimi API.
### 3. Generate Diagram (Optional)
For technical topics, generates architecture diagrams using HTML/CSS + Playwright.
## Security Best Practices
1. **Never commit credentials to git**
2. **Use environment variables in production**
3. **Set file permissions to 600 for config files**
4. **Use runtime parameters for multi-user scenarios**
## Security Considerations
This skill makes several operational choices that users should be aware of:
### 1. Playwright Browser Download
- **Why**: Required for generating architecture diagrams as PNG images
- **Size**: ~100MB Chromium browser
- **Alternative**: Skip diagram generation if not needed
### 2. Temporary Files
- **Location**: `/tmp/diagram.html` and `/tmp/diagram.png`
- **Purpose**: Intermediate files for diagram generation
- **Cleanup**: Files are overwritten on each run, not explicitly deleted
### 3. `--no-sandbox` Flag
- **Why**: Required for running Chromium in containerized/Docker environments
- **Risk**: Slightly reduced browser isolation
- **Mitigation**: Only used for local HTML-to-image conversion, no external URLs loaded
### 4. Plaintext Password Storage (Optional)
- **Config file**: Only if user chooses Method 1
- **Recommendation**: Use environment variables (Method 2) or runtime parameters (Method 3) instead
- **If using config**: Always set file permissions to 600
## Example Usage
### With Config File
```bash
# ~/.openclaw/openclaw.json configured
You: "Publish a blog about Python tips"
AI: [Uses config credentials, publishes]
```
### With Environment Variables
```bash
export BEAR_BLOG_EMAIL="user@example.com"
export BEAR_BLOG_PASSWORD="secret"
You: "Publish a blog about Python tips"
AI: [Uses env vars, publishes]
```
### With AI Content Generation
```bash
export BEAR_BLOG_EMAIL="user@example.com"
export BEAR_BLOG_PASSWORD="secret"
export OPENAI_API_KEY="sk-..."
You: "Write and publish a blog about Python asyncio"
AI: [Generates content with OpenAI, publishes]
```
### With Runtime Parameters
```python
# In your chat bot code
email = get_user_email() # Ask user
password = get_user_password() # Ask user
publisher = BearBlogPublisher(email=email, password=password)
result = publisher.publish(title="My Post", content="# Content")
```
## Implementation
- Uses Bear Blog web API
- CSRF token authentication
- Session-based (no persistent storage)
- Playwright for diagram generation
- OpenAI/Kimi API for content generation
## License
MIT
---
## 中文说明
# Bear Blog Publisher
将博文发布到 Bear Blog (https://bearblog.dev/)。
## 概述
此技能为 Bear Blog 提供自动化发布能力,包括可选的 AI 内容生成和图表生成。
## 认证方式(任选其一)
### 方式 1:OpenClaw 配置(推荐用于个人使用)
添加到你的 `~/.openclaw/openclaw.json`:
```json
{
"skills": {
"bear-blog-publisher": {
"email": "your@email.com",
"password": "yourpassword"
}
}
}
```
**安全性**:文件权限应设置为 600(仅所有者可读)。
### 方式 2:环境变量(推荐用于 CI/CD)
```bash
export BEAR_BLOG_EMAIL="your@email.com"
export BEAR_BLOG_PASSWORD="yourpassword"
```
**安全性**:凭据仅存在于内存中,不会写入磁盘。
### 方式 3:运行时参数(推荐用于多用户)
在调用技能时提供凭据:
```python
publisher = BearBlogPublisher(email="user@example.com", password="secret")
```
**安全性**:由调用方(聊天机器人、Web 应用等)管理凭据的生命周期。
## AI 内容生成(可选)
要使用 AI 内容生成,请配置以下其中之一:
### OpenAI
```bash
export OPENAI_API_KEY="sk-..."
```
### Kimi
```bash
export KIMI_API_KEY="your-kimi-api-key"
```
### 用法
```python
publisher = BearBlogPublisher()
content = publisher.generate_content(
topic="Python best practices",
provider="openai", # or "kimi"
tone="professional",
length="medium"
)
result = publisher.publish(title="My Post", content=content)
```
## 优先级顺序
1. 运行时参数(最高优先级)
2. 环境变量
3. OpenClaw 配置(最低优先级)
## 功能
### 1. 发布博文
**输入:**
- `title` (string):博文标题
- `content` (string):Markdown 内容
- `email` (string, optional):Bear Blog 邮箱
- `password` (string, optional):Bear Blog 密码
**输出:**
- 已发布的 URL 或错误信息
### 2. AI 内容生成(可选)
使用 OpenAI 或 Kimi API 生成博客内容。
### 3. 生成图表(可选)
针对技术主题,使用 HTML/CSS + Playwright 生成架构图。
## 安全最佳实践
1. **切勿将凭据提交到 git**
2. **在生产环境中使用环境变量**
3. **将配置文件的文件权限设置为 600**
4. **在多用户场景中使用运行时参数**
## 安全注意事项
此技能做出了若干操作上的选择,用户应予以注意:
### 1. Playwright 浏览器下载
- **原因**:生成 PNG 格式的架构图所必需
- **大小**:约 100MB 的 Chromium 浏览器
- **替代方案**:如不需要可跳过图表生成
### 2. 临时文件
- **位置**:`/tmp/diagram.html` 和 `/tmp/diagram.png`
- **用途**:图表生成的中间文件
- **清理**:文件在每次运行时被覆盖,不会被显式删除
### 3. `--no-sandbox` 标志
- **原因**:在容器化/Docker 环境中运行 Chromium 所必需
- **风险**:浏览器隔离性略有降低
- **缓解**:仅用于本地 HTML 转图像,不加载外部 URL
### 4. 明文密码存储(可选)
- **配置文件**:仅当用户选择方式 1 时
- **建议**:改用环境变量(方式 2)或运行时参数(方式 3)
- **若使用配置文件**:务必将文件权限设置为 600
## 用法示例
### 使用配置文件
```bash
# ~/.openclaw/openclaw.json configured
You: "Publish a blog about Python tips"
AI: [Uses config credentials, publishes]
```
### 使用环境变量
```bash
export BEAR_BLOG_EMAIL="user@example.com"
export BEAR_BLOG_PASSWORD="secret"
You: "Publish a blog about Python tips"
AI: [Uses env vars, publishes]
```
### 使用 AI 内容生成
```bash
export BEAR_BLOG_EMAIL="user@example.com"
export BEAR_BLOG_PASSWORD="secret"
export OPENAI_API_KEY="sk-..."
You: "Write and publish a blog about Python asyncio"
AI: [Generates content with OpenAI, publishes]
```
### 使用运行时参数
```python
# In your chat bot code
email = get_user_email() # Ask user
password = get_user_password() # Ask user
publisher = BearBlogPublisher(email=email, password=password)
result = publisher.publish(title="My Post", content="# Content")
```
## 实现
- 使用 Bear Blog Web API
- CSRF 令牌认证
- 基于会话(无持久化存储)
- 使用 Playwright 生成图表
- 使用 OpenAI/Kimi API 生成内容
## 许可证
MIT