From af31a001e94944c31a03ccea850ecaaba01099e8 Mon Sep 17 00:00:00 2001 From: sliverp Date: Thu, 29 Jan 2026 14:55:31 +0800 Subject: [PATCH] =?UTF-8?q?docs:=20=E6=B7=BB=E5=8A=A0=E5=8D=87=E7=BA=A7?= =?UTF-8?q?=E8=84=9A=E6=9C=AC=E5=92=8C=E5=8D=87=E7=BA=A7=E8=AF=B4=E6=98=8E?= =?UTF-8?q?=E6=96=87=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 24 ++++++++++++++++++ scripts/upgrade.sh | 62 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 86 insertions(+) create mode 100755 scripts/upgrade.sh diff --git a/README.md b/README.md index 89022fb..d6abf61 100644 --- a/README.md +++ b/README.md @@ -114,6 +114,28 @@ clawdbot onboard 3. **群消息**:需要在群内 @机器人 才能触发回复 4. **沙箱模式**:新创建的机器人默认在沙箱模式,需要添加测试用户 +## 升级 + +如果需要升级插件,先运行升级脚本清理旧版本: + +```bash +# 运行升级脚本(清理旧版本和配置) +./scripts/upgrade.sh + +# 重新安装插件 +clawdbot plugins install . + +# 重新配置 +clawdbot channels add --channel qqbot --token "AppID:AppSecret" + +# 重启网关 +clawdbot gateway restart +``` + +升级脚本会自动: +- 删除 `~/.clawdbot/extensions/qqbot` 目录 +- 清理 `clawdbot.json` 中的 qqbot 相关配置 + ## 开发 ```bash @@ -141,6 +163,8 @@ qqbot/ │ ├── outbound.ts # 出站消息处理 │ ├── runtime.ts # 运行时状态 │ └── types.ts # 类型定义 +├── scripts/ +│ └── upgrade.sh # 升级脚本 ├── package.json └── tsconfig.json ``` diff --git a/scripts/upgrade.sh b/scripts/upgrade.sh new file mode 100755 index 0000000..39feff8 --- /dev/null +++ b/scripts/upgrade.sh @@ -0,0 +1,62 @@ +#!/bin/bash +# QQBot 插件升级脚本 +# 用于清理旧版本插件并重新安装 + +set -e + +CLAWDBOT_DIR="$HOME/.clawdbot" +CONFIG_FILE="$CLAWDBOT_DIR/clawdbot.json" +EXTENSION_DIR="$CLAWDBOT_DIR/extensions/qqbot" + +echo "=== QQBot 插件升级脚本 ===" + +# 1. 删除旧的扩展目录 +if [ -d "$EXTENSION_DIR" ]; then + echo "删除旧版本插件: $EXTENSION_DIR" + rm -rf "$EXTENSION_DIR" +else + echo "未找到旧版本插件目录,跳过删除" +fi + +# 2. 清理配置文件中的 qqbot 相关字段 +if [ -f "$CONFIG_FILE" ]; then + echo "清理配置文件中的 qqbot 字段..." + + # 使用 node 处理 JSON(比 jq 更可靠处理复杂结构) + node -e " + const fs = require('fs'); + const config = JSON.parse(fs.readFileSync('$CONFIG_FILE', 'utf8')); + + // 删除 channels.qqbot + if (config.channels && config.channels.qqbot) { + delete config.channels.qqbot; + console.log(' - 已删除 channels.qqbot'); + } + + // 删除 plugins.entries.qqbot + if (config.plugins && config.plugins.entries && config.plugins.entries.qqbot) { + delete config.plugins.entries.qqbot; + console.log(' - 已删除 plugins.entries.qqbot'); + } + + // 删除 plugins.installs.qqbot + if (config.plugins && config.plugins.installs && config.plugins.installs.qqbot) { + delete config.plugins.installs.qqbot; + console.log(' - 已删除 plugins.installs.qqbot'); + } + + fs.writeFileSync('$CONFIG_FILE', JSON.stringify(config, null, 2)); + console.log('配置文件已更新'); + " +else + echo "未找到配置文件: $CONFIG_FILE" +fi + +echo "" +echo "=== 清理完成 ===" +echo "" +echo "接下来请执行以下命令重新安装插件:" +echo " cd /path/to/qqbot" +echo " clawdbot plugins install ." +echo " clawdbot channels add --channel qqbot --token \"AppID:AppSecret\"" +echo " clawdbot gateway restart"