测试阶段,先执行微信安装在执行QQ机器人安装,就是1和2的代码
npx -y @tencent-weixin/openclaw-weixin-cli@latest install# 1. 初始化环境与编码
[Console]::OutputEncoding = [System.Text.Encoding]::UTF8
$OutputEncoding = [System.Text.Encoding]::UTF8
$pluginName = "@tencent-connect/openclaw-qqbot"
$targetPath = "$HOME\.openclaw\extensions\openclaw-qqbot"
Write-Host "`n🚀 开始增强模式安装: QQ Bot 插件" -ForegroundColor Cyan
Write-Host "=========================================="
# 2. 优化 npm 网络环境 (切换至国内镜像)
Write-Host "[1/5] 正在配置 npm 加速镜像..." -ForegroundColor Yellow
npm config set registry https://registry.npmmirror.com
Write-Host "✅ 已切换至 npmmirror 镜像站" -ForegroundColor Green
# 3. 清理可能存在的残留文件
if (Test-Path $targetPath) {
Write-Host "[2/5] 发现旧插件残留,正在清理..." -ForegroundColor Yellow
Remove-Item -Recurse -Force $targetPath -ErrorAction SilentlyContinue
}
# 4. 执行 OpenClaw 插件安装指令
Write-Host "[3/5] 正在通过 OpenClaw 安装插件..." -ForegroundColor Yellow
openclaw plugins install "$pluginName@latest"
# 5. 手动强制补齐依赖 (防止 openclaw 内部调用失败)
Write-Host "[4/5] 检查并强制修复依赖..." -ForegroundColor Yellow
if (Test-Path $targetPath) {
Push-Location $targetPath
# 强制重新安装所有依赖,忽略审计以加快速度
npm install --no-audit --no-fund --loglevel error
Pop-Location
Write-Host "✅ 依赖包手动校验完成" -ForegroundColor Green
} else {
Write-Host "❌ 错误: 插件目录未生成,请检查网络或权限。" -ForegroundColor Red
exit
}
# 6. 自动配置信任列表 (消除 plugins.allow 警告)
Write-Host "[5/5] 正在尝试将插件加入信任名单..." -ForegroundColor Yellow
# 这里尝试模拟 openclaw 的配置更新(如果 openclaw 支持命令行配置请修改此处)
# 建议手动检查 .openclaw/config.toml 或 config.json
Write-Host "`n✨ 安装流程执行完毕!" -ForegroundColor Cyan
Write-Host "------------------------------------------"
Write-Host "接下来请执行以下命令验证:" -ForegroundColor White
Write-Host "1. 查看状态: openclaw plugins list" -ForegroundColor Gray
Write-Host "2. 配置账号: openclaw channels add --channel qqbot --token 'APPID:APPSECRET'" -ForegroundColor Gray# 微信插件首次安装脚本
$ErrorActionPreference = "Continue"
Write-Host "`n╔══════════════════════════════════════╗" -ForegroundColor Cyan
Write-Host "║ 微信插件首次安装 ║" -ForegroundColor Cyan
Write-Host "╚══════════════════════════════════════╝" -ForegroundColor Cyan
# 1. 确认 OpenClaw 已安装
Write-Host "`n[1/4] 确认 OpenClaw..." -ForegroundColor Yellow
try {
openclaw --version
Write-Host "OpenClaw 已就绪" -ForegroundColor Green
} catch {
Write-Host "错误: 未找到 OpenClaw" -ForegroundColor Red
Write-Host "请先运行: npm install -g openclaw" -ForegroundColor Gray
exit 1
}
# 2. 初始化配置目录
Write-Host "`n[2/4] 初始化配置..." -ForegroundColor Yellow
$openclawPath = "$env:USERPROFILE\.openclaw"
if (-not (Test-Path $openclawPath)) {
Write-Host "创建配置目录" -ForegroundColor Gray
New-Item -ItemType Directory -Path $openclawPath -Force | Out-Null
}
# 3. 安装微信插件
Write-Host "`n[3/4] 安装微信插件..." -ForegroundColor Yellow
$pluginPath = "$env:USERPROFILE\.openclaw\extensions\openclaw-weixin"
if (Test-Path $pluginPath) {
Write-Host "检测到旧版本,正在删除..." -ForegroundColor Gray
Remove-Item -Recurse -Force $pluginPath
}
openclaw plugins install @tencent-weixin/openclaw-weixin
# 4. 启动并扫码登录
Write-Host "`n[4/4] 启动 Gateway 并扫码..." -ForegroundColor Yellow
openclaw gateway restart
Write-Host "`n即将显示二维码,请用微信扫码登录" -ForegroundColor Cyan
Start-Sleep -Seconds 2
openclaw channels login --channel openclaw-weixin
# 验证
Write-Host "`n`n=== 验证安装 ===" -ForegroundColor Cyan
openclaw plugins list | Select-String "weixin"
Write-Host "`n`n✅ 安装完成!" -ForegroundColor Green
Write-Host "`n📱 在微信上扫码登录后即可聊天" -ForegroundColor Cyan# QQ Bot 插件首次安装脚本(精简版)
# 修复控制台编码问题
[Console]::OutputEncoding = [System.Text.Encoding]::UTF8
$OutputEncoding = [System.Text.Encoding]::UTF8
$ErrorActionPreference = "Continue"
Write-Host "`n╔══════════════════════════════════════╗" -ForegroundColor Cyan
Write-Host "║ QQ Bot 插件首次安装 ║" -ForegroundColor Cyan
Write-Host "╚══════════════════════════════════════╝" -ForegroundColor Cyan
# 1. 确认 OpenClaw 已安装
Write-Host "`n[1/2] 确认 OpenClaw..." -ForegroundColor Yellow
try {
openclaw --version
Write-Host "OpenClaw 已就绪" -ForegroundColor Green
} catch {
Write-Host "错误: 未找到 OpenClaw" -ForegroundColor Red
Write-Host "请先运行: npm install -g openclaw" -ForegroundColor Gray
exit 1
}
# 2. 安装 QQ Bot 插件
Write-Host "`n[2/2] 安装 QQ Bot 插件..." -ForegroundColor Yellow
openclaw plugins install @tencent-connect/openclaw-qqbot@latest
Write-Host "`n`n✅ QQ Bot 插件安装完成!" -ForegroundColor Green
Write-Host "`n⚙️ 手动配置步骤:" -ForegroundColor Yellow
Write-Host " 1. 获取 QQ Bot 凭证: https://bot.q.qq.com/" -ForegroundColor Gray
Write-Host " 2. 添加 channel: openclaw channels add --channel qqbot --token `"appid:appsecret`"" -ForegroundColor Gray
Write-Host " 3. 重启 Gateway: openclaw gateway restart" -ForegroundColor Gray# 微信插件首次安装脚本(精简版)
# 修复控制台编码问题
[Console]::OutputEncoding = [System.Text.Encoding]::UTF8
$OutputEncoding = [System.Text.Encoding]::UTF8
$ErrorActionPreference = "Continue"
Write-Host "`n╔══════════════════════════════════════╗" -ForegroundColor Cyan
Write-Host "║ 微信插件首次安装 ║" -ForegroundColor Cyan
Write-Host "╚══════════════════════════════════════╝" -ForegroundColor Cyan
# 1. 确认 OpenClaw 已安装
Write-Host "`n[1/2] 确认 OpenClaw..." -ForegroundColor Yellow
try {
openclaw --version
Write-Host "OpenClaw 已就绪" -ForegroundColor Green
} catch {
Write-Host "错误: 未找到 OpenClaw" -ForegroundColor Red
Write-Host "请先运行: npm install -g openclaw" -ForegroundColor Gray
exit 1
}
# 2. 安装微信插件
Write-Host "`n[2/2] 安装微信插件..." -ForegroundColor Yellow
openclaw plugins install @tencent-weixin/openclaw-weixin
Write-Host "`n`n✅ 微信插件安装完成!" -ForegroundColor Green
Write-Host "`n⚙️ 手动配置步骤:" -ForegroundColor Yellow
Write-Host " 1. 重启 Gateway: openclaw gateway restart" -ForegroundColor Gray
Write-Host " 2. 扫码登录: openclaw channels login --channel openclaw-weixin" -ForegroundColor Gray原创文章,作者:开心电脑网,如若转载,请注明出处。