#!/bin/bash # scripts/wechat-activate.sh — 微信插件激活 (优化版) # 插件包已在 Dockerfile BUILD 阶段预安装,运行时只做 enable + 凭证检查 set -e STATE_DIR="${OPENCLAW_STATE_DIR:-/root/.openclaw}" WEIXIN_DIR="${STATE_DIR}/openclaw-weixin" ACCOUNTS_DIR="${WEIXIN_DIR}/accounts" echo "🔄 WeChat plugin activation..." # ── Step 1: 启用插件(BUILD 阶段已安装,这里只是 enable)── echo " [1/2] Enabling plugin..." openclaw config set plugins.entries.openclaw-weixin.enabled true 2>/dev/null || true openclaw plugins enable openclaw-weixin 2>/dev/null || { echo " -> Plugin enable failed, attempting install..." openclaw plugins install "@tencent-weixin/openclaw-weixin" 2>/dev/null || true openclaw plugins enable openclaw-weixin 2>/dev/null || true } # ── Step 2: 检查凭证,决定是否需要扫码 ── echo " [2/2] Checking saved credentials..." if [[ -d "$ACCOUNTS_DIR" && -n "$(ls -A "$ACCOUNTS_DIR" 2>/dev/null)" ]]; then echo " ✅ Credentials restored from backup — auto-activate (no QR needed)" else echo " ⚠️ No saved credentials found — QR scan login required" echo " -> Run: openclaw channels login --channel openclaw-weixin" openclaw channels login --channel openclaw-weixin 2>/dev/null || \ echo " WARNING: QR login failed or skipped" fi echo "✅ WeChat plugin done"