Files
my-project/config/openclaw/scripts/novel-learning/novel-master.sh
T

148 lines
5.1 KiB
Bash
Executable File
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/bin/bash
# ============================================================================
# 小说学习反思写作系统主控 v1.1
# ============================================================================
# 功能:整合所有模块,统一执行入口
# 设计改进:移除粘连代码,改用模块调用
# ============================================================================
NOVEL_DIR="/root/.openclaw/workspace/平安书"
SCRIPT_DIR="/root/.openclaw/scripts/novel-learning"
TIMESTAMP=$(date '+%Y-%m-%d %H:%M')
# ============================================================================
# 1. 自动学习模块
# ============================================================================
run_auto_learn() {
echo ""
echo "📚 === 自动学习模块 ==="
"$SCRIPT_DIR"/novel-auto-learn.sh
}
# ============================================================================
# 2. 反思触发模块
# ============================================================================
run_reflection() {
echo ""
echo "🔄 === 反思触发模块 ==="
"$SCRIPT_DIR"/novel-reflection-trigger.sh
}
# ============================================================================
# 3. 格式检查模块
# ============================================================================
run_format_check() {
echo ""
echo "🔍 === 格式检查模块 ==="
if [ -z "$1" ]; then
# 检查最新章节
local latest=$(ls -t "$NOVEL_DIR"/*第*章*.txt 2>/dev/null | head -1)
if [ -n "$latest" ]; then
"$SCRIPT_DIR"/novel-format-check.sh "$(basename "$latest")"
else
echo "ℹ️ 未发现章节文件"
fi
else
"$SCRIPT_DIR"/novel-format-check.sh "$1"
fi
}
# ============================================================================
# 4. 同步模块
# ============================================================================
run_sync() {
echo ""
echo "🚀 === 同步模块 ==="
if [ -z "$1" ]; then
"$SCRIPT_DIR"/novel-sync.sh chapter
else
"$SCRIPT_DIR"/novel-sync.sh chapter "$1"
fi
}
# ============================================================================
# 5. 进度追踪模块(调用外部脚本)
# ============================================================================
run_progress() {
echo ""
echo "📈 === 进度追踪模块 ==="
"$SCRIPT_DIR"/novel-progress-tracker.sh
}
# ============================================================================
# 6. 一键执行所有模块
# ============================================================================
run_all() {
echo "╔════════════════════════════════════════════════════╗"
echo "║ 小说学习反思写作系统 v1.1 ║"
echo "╚════════════════════════════════════════════════════╝"
echo ""
run_auto_learn
run_reflection
run_format_check
run_progress
echo ""
echo "╔════════════════════════════════════════════════════╗"
echo "║ 系统执行完成 ║"
echo "╚════════════════════════════════════════════════════╝"
}
# ============================================================================
# 帮助
# ============================================================================
help() {
echo "用法: $0 {all|learn|reflection|format|sync|progress} [参数]"
echo ""
echo "命令:"
echo " all 执行所有模块"
echo " learn 执行自动学习模块"
echo " reflection 执行反思触发模块"
echo " format 执行格式检查模块 [章节名]"
echo " sync 执行同步模块 [章节名]"
echo " progress 执行进度追踪模块"
echo ""
echo "示例:"
echo " $0 all # 一键执行所有"
echo " $0 format 第三章_红尘路 # 检查指定章节"
echo " $0 sync 第四章_初露锋芒 # 同步指定章节"
}
# ============================================================================
# 主程序
# ============================================================================
main() {
case "${1:-all}" in
all)
run_all
;;
learn)
run_auto_learn
;;
reflection)
run_reflection
;;
format)
run_format_check "$2"
;;
sync)
run_sync "$2"
;;
progress)
run_progress
;;
help|--help|-h)
help
;;
*)
echo "未知命令: $1"
help
;;
esac
}
main "$@"