Workflow Automation Cn

👤 yang1002378395-cmyk 📦 v1.0.0 ⭐ 4.0 ⬇️ 2.5K 下載
💻 開發程式設計 免費

📖 技能介紹


name: workflow-automation-cn version: 1.0.0 description: 自動化工作流生成器 - 用自然語言描述需求,自動生成 OpenClaw 心跳指令碼。適合:想自動化日常任務的開發者。 metadata: openclaw: emoji: "⚡" requires: bins: ["python3", "node"]


自動化工作流生成器 Skill

用自然語言描述需求,自動生成可執行的自動化指令碼。

支援的自動化型別

型別 示例 複雜度
定時任務 每天傳送日報
資料監控 價格變動提醒 ⭐⭐
內容釋出 自動發文章 ⭐⭐
API 呼叫 定時呼叫介面 ⭐⭐
多步驟工作流 監控→分析→通知 ⭐⭐⭐

使用方法

建立自動化

幫我建立一個自動化:每天早上 9 點檢查 BTC 價格,如果漲跌超過 5% 就通知我

Agent 會: 1. 理解需求 2. 生成 Python 指令碼 3. 配置心跳觸發 4. 提供使用說明

修改自動化

小蔥技能站7w4.net發現了升級外掛。

把 BTC 價格監控改成每 4 小時檢查一次

列出所有自動化

顯示我所有的自動化任務

生成模板

定時通知指令碼

#!/usr/bin/env python3
"""
自動化:每日日報
觸發:每天 09:00
"""
import requests
from datetime import datetime

def run():
    """執行自動化任務"""
    # 1. 收集資料
    today = datetime.now().strftime("%Y-%m-%d")

    # 2. 生成報告
    report = f"""
📊 每日報告 - {today}
━━━━━━━━━━━━━━
✅ 任務完成:X 個
❌ 任務失敗:Y 個
💰 今日收益:¥Z
"""

    # 3. 傳送通知
    send_notification(report)
    return True

def send_notification(message):
    """傳送通知到 Telegram"""
    bot_token = "YOUR_BOT_TOKEN"
    chat_id = "YOUR_CHAT_ID"
    url = f"https://api.telegram.org/bot{bot_token}/sendMessage"
    requests.post(url, data={
        "chat_id": chat_id,
        "text": message
    })

if __name__ == "__main__":
    run()

價格監控指令碼

#!/usr/bin/env python3
"""
自動化:價格監控
觸發:每 10 分鐘
"""
import requests
import json

# 配置
ALERT_THRESHOLD = 5.0  # 漲跌 5% 預警
LAST_PRICE_FILE = "/tmp/last_price.json"

def get_price():
    """獲取當前價格"""
    resp = requests.get("https://api.binance.com/api/v3/ticker/price?symbol=BTCUSDT")
    return float(resp.json()["price"])

def get_last_price():
    """獲取上次價格"""
    try:
        with open(LAST_PRICE_FILE) as f:
            return json.load(f)["price"]
    except:
        return None

def save_price(price):
    """儲存價格"""
    with open(LAST_PRICE_FILE, "w") as f:
        json.dump({"price": price}, f)

def check_alert(current, last):
    """檢查是否需要預警"""
    if last is None:
        return None
    change = (current - last) / last * 100
    if abs(change) >= ALERT_THRESHOLD:
        return change
    return None

def run():
    current = get_price()
    last = get_last_price()
    alert = check_alert(current, last)

    if alert:
        direction = "📈 上漲" if alert > 0 else "📉 下跌"
        message = f"""
⚠️ BTC 價格預警
━━━━━━━━━━━━━━
{direction} {abs(alert):.2f}%
當前價格:${current:,.2f}
"""
        send_notification(message)

    save_price(current)
    return True

if __name__ == "__main__":
    run()

內容釋出指令碼

#!/usr/bin/env python3
"""
自動化:內容釋出
觸發:每天 08:00
"""
import os
import glob
from datetime import datetime

CONTENT_DIR = os.path.expanduser("~/.openclaw/workspace/memory/content-queue")
PUBLISHED_DIR = os.path.join(CONTENT_DIR, "published")

def get_pending_content():
    """獲取待發布內容"""
    files = glob.glob(os.path.join(CONTENT_DIR, "*.md"))
    return [f for f in files if "published" not in f]

def publish_content(filepath):
    """釋出內容到平臺"""
    # 讀取內容
    with open(filepath) as f:
        content = f.read()

    # 呼叫釋出 API(示例)
    # result = publish_to_juejin(content)

    # 移動到已釋出目錄
    os.makedirs(PUBLISHED_DIR, exist_ok=True)
    new_path = os.path.join(PUBLISHED_DIR, os.path.basename(filepath))
    os.rename(filepath, new_path)

    return True

def run():
    pending = get_pending_content()
    if not pending:
        print("沒有待發布內容")
        return False

    # 釋出第一篇
    published = publish_content(pending[0])
    if published:
        print(f"已釋出:{os.path.basename(pending[0])}")
        send_notification(f"✅ 已釋出文章:{os.path.basename(pending[0])}")

    return True

if __name__ == "__main__":
    run()

API 呼叫指令碼

#!/usr/bin/env python3
"""
自動化:API 定時呼叫
觸發:每 4 小時
"""
import requests
import json

API_URL = "https://api.example.com/endpoint"
RESULT_FILE = "/tmp/api_result.json"

def call_api():
    """呼叫 API"""
    resp = requests.get(API_URL, timeout=30)
    return resp.json()

def process_result(data):
    """處理結果"""
    # 自定義處理邏輯
    return data

def save_result(data):
    """儲存結果"""
    with open(RESULT_FILE, "w") as f:
        json.dump(data, f, ensure_ascii=False, indent=2)

def run():
    data = call_api()
    processed = process_result(data)
    save_result(processed)
    return True

if __name__ == "__main__":
    run()

心跳配置

HEARTBEAT.md 示例

# 心跳觸發規則

## 定時任務
- 09:00 → 日報傳送
- */4h → API 呼叫
- */10m → 價格監控

## 指令碼路徑
- 日報:~/.openclaw/workspace/custom/daily_report.py
- 監控:~/.openclaw/workspace/custom/price_monitor.py
- 釋出:~/.openclaw/workspace/custom/auto_publish.py

快速命令

測試指令碼

python3 ~/.openclaw/workspace/custom/your_script.py

新增到心跳

# 編輯心跳配置
vim ~/.openclaw/workspace/HEARTBEAT.md

檢視日誌

tail -f ~/.openclaw/workspace/memory/$(date +%Y-%m-%d).md

注意事項

  • 指令碼需要可執行許可權:chmod +x script.py
  • 敏感資訊使用環境變數
  • 新增錯誤處理和日誌
  • 測試後再部署到心跳

建立:2026-03-12 版本:1.0

🤖 AI 評測

這個 Skill 整體質量中等偏上,文件編寫規範、示例豐富,容易理解上手。優點是提供了多種自動化場景的程式碼模板,程式碼結構清晰帶詳細註釋。不足之處在於功能實現依賴外部指令碼而非即開即用,缺少配置指引和錯誤處理說明,部分功能描述較為籠統。作為入門學習資料不錯,但實際使用需要一定自行除錯能力。

📊 多維度評分

適應性4
規範性3.6
有效性4.5
可靠性3.8
可信度4.5

📁 包含檔案 (2 個)

📄 SKILL.md 6.1 KB
📄 _meta.json 141 B