feat: 新增 clawdbot 兼容支持
This commit is contained in:
16
clawdbot.plugin.json
Normal file
16
clawdbot.plugin.json
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
{
|
||||||
|
"id": "qqbot",
|
||||||
|
"name": "QQ Bot Channel",
|
||||||
|
"description": "QQ Bot channel plugin with message support, cron jobs, and proactive messaging",
|
||||||
|
"channels": ["qqbot"],
|
||||||
|
"skills": ["skills/qqbot-cron", "skills/qqbot-media"],
|
||||||
|
"capabilities": {
|
||||||
|
"proactiveMessaging": true,
|
||||||
|
"cronJobs": true
|
||||||
|
},
|
||||||
|
"configSchema": {
|
||||||
|
"type": "object",
|
||||||
|
"additionalProperties": false,
|
||||||
|
"properties": {}
|
||||||
|
}
|
||||||
|
}
|
||||||
16
moltbot.plugin.json
Normal file
16
moltbot.plugin.json
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
{
|
||||||
|
"id": "qqbot",
|
||||||
|
"name": "QQ Bot Channel",
|
||||||
|
"description": "QQ Bot channel plugin with message support, cron jobs, and proactive messaging",
|
||||||
|
"channels": ["qqbot"],
|
||||||
|
"skills": ["skills/qqbot-cron", "skills/qqbot-media"],
|
||||||
|
"capabilities": {
|
||||||
|
"proactiveMessaging": true,
|
||||||
|
"cronJobs": true
|
||||||
|
},
|
||||||
|
"configSchema": {
|
||||||
|
"type": "object",
|
||||||
|
"additionalProperties": false,
|
||||||
|
"properties": {}
|
||||||
|
}
|
||||||
|
}
|
||||||
17
package.json
17
package.json
@@ -1,14 +1,17 @@
|
|||||||
{
|
{
|
||||||
"name": "@openclaw/qqbot",
|
"name": "qqbot",
|
||||||
"version": "2026.1.31",
|
"version": "1.3.0",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"types": "dist/index.d.ts",
|
"types": "dist/index.d.ts",
|
||||||
"description": "OpenClaw QQ Bot channel plugin with streaming message support",
|
"clawdbot": {
|
||||||
|
"extensions": ["./index.ts"]
|
||||||
|
},
|
||||||
|
"moltbot": {
|
||||||
|
"extensions": ["./index.ts"]
|
||||||
|
},
|
||||||
"openclaw": {
|
"openclaw": {
|
||||||
"extensions": [
|
"extensions": ["./index.ts"]
|
||||||
"./index.ts"
|
|
||||||
]
|
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "tsc || true",
|
"build": "tsc || true",
|
||||||
@@ -27,6 +30,8 @@
|
|||||||
"typescript": "^5.9.3"
|
"typescript": "^5.9.3"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
|
"clawdbot": "*",
|
||||||
|
"moltbot": "*",
|
||||||
"openclaw": "*"
|
"openclaw": "*"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,62 +1,106 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# QQBot 插件升级脚本
|
# QQBot 插件升级脚本
|
||||||
# 用于清理旧版本插件并重新安装
|
# 用于清理旧版本插件并重新安装
|
||||||
|
# 兼容 clawdbot 和 openclaw 两种安装
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
OPENCLAW_DIR="$HOME/.openclaw"
|
|
||||||
CONFIG_FILE="$OPENCLAW_DIR/openclaw.json"
|
|
||||||
EXTENSION_DIR="$OPENCLAW_DIR/extensions/qqbot"
|
|
||||||
|
|
||||||
echo "=== QQBot 插件升级脚本 ==="
|
echo "=== QQBot 插件升级脚本 ==="
|
||||||
|
|
||||||
# 1. 删除旧的扩展目录
|
# 检测使用的是 clawdbot 还是 openclaw
|
||||||
if [ -d "$EXTENSION_DIR" ]; then
|
detect_installation() {
|
||||||
echo "删除旧版本插件: $EXTENSION_DIR"
|
if [ -d "$HOME/.clawdbot" ]; then
|
||||||
rm -rf "$EXTENSION_DIR"
|
echo "clawdbot"
|
||||||
else
|
elif [ -d "$HOME/.openclaw" ]; then
|
||||||
echo "未找到旧版本插件目录,跳过删除"
|
echo "openclaw"
|
||||||
|
else
|
||||||
|
echo ""
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# 清理指定目录的函数
|
||||||
|
cleanup_installation() {
|
||||||
|
local APP_NAME="$1"
|
||||||
|
local APP_DIR="$HOME/.$APP_NAME"
|
||||||
|
local CONFIG_FILE="$APP_DIR/$APP_NAME.json"
|
||||||
|
local EXTENSION_DIR="$APP_DIR/extensions/qqbot"
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo ">>> 处理 $APP_NAME 安装..."
|
||||||
|
|
||||||
|
# 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
|
||||||
|
}
|
||||||
|
|
||||||
|
# 检测并处理所有可能的安装
|
||||||
|
FOUND_INSTALLATION=""
|
||||||
|
|
||||||
|
# 检查 clawdbot
|
||||||
|
if [ -d "$HOME/.clawdbot" ]; then
|
||||||
|
cleanup_installation "clawdbot"
|
||||||
|
FOUND_INSTALLATION="clawdbot"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# 2. 清理配置文件中的 qqbot 相关字段
|
# 检查 openclaw
|
||||||
if [ -f "$CONFIG_FILE" ]; then
|
if [ -d "$HOME/.openclaw" ]; then
|
||||||
echo "清理配置文件中的 qqbot 字段..."
|
cleanup_installation "openclaw"
|
||||||
|
FOUND_INSTALLATION="openclaw"
|
||||||
# 使用 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
|
fi
|
||||||
|
|
||||||
|
# 如果都没找到
|
||||||
|
if [ -z "$FOUND_INSTALLATION" ]; then
|
||||||
|
echo "未找到 clawdbot 或 openclaw 安装目录"
|
||||||
|
echo "请确认已安装 clawdbot 或 openclaw"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 使用检测到的安装类型作为命令
|
||||||
|
CMD="$FOUND_INSTALLATION"
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
echo "=== 清理完成 ==="
|
echo "=== 清理完成 ==="
|
||||||
echo ""
|
echo ""
|
||||||
echo "接下来请执行以下命令重新安装插件:"
|
echo "接下来请执行以下命令重新安装插件:"
|
||||||
echo " cd /path/to/qqbot"
|
echo " cd /path/to/qqbot"
|
||||||
echo " openclaw plugins install ."
|
echo " $CMD plugins install ."
|
||||||
echo " openclaw channels add --channel qqbot --token \"AppID:AppSecret\""
|
echo " $CMD channels add --channel qqbot --token \"AppID:AppSecret\""
|
||||||
echo " openclaw gateway restart"
|
echo " $CMD gateway restart"
|
||||||
|
|||||||
Reference in New Issue
Block a user