Skill: zaohon/openqq (version 0.0.5)

--- name: openqq description: QQ bot integration for OpenClaw with session isolation, logging, and AI auto-reply. Supports private chat and group @messages. --- # OpenQQ Bot QQ bot integration for OpenClaw. Enables AI auto-reply for QQ private chats and group @mentions with session isolation and comprehensive logging. ## Quick Start ```bash # Initialize config npm run setup # Install dependencies npm install # Edit config vim ~/.openclaw/workspace/open-qq-config.json # Start bot npm start ``` ## Configuration Edit `~/.openclaw/workspace/open-qq-config.json`: ```json { "qq": { "appId": "YOUR_APP_ID", "token": "YOUR_TOKEN", "appSecret": "YOUR_APP_SECRET" } } ``` Get credentials from [QQ Open Platform](https://bot.q.qq.com/). ## Usage ```bash npm start # Start bot npm run health # Health check npm run logs # View today's logs npm run status # Check running status ``` ## Features - **Session Isolation**: Each user/group has independent conversation history - Private: `qq-private-{user_openid}` - Group: `qq-group-{group_openid}` - **Comprehensive Logging**: China timezone, log rotation, sensitive data filtering - **Auto Reconnect**: WebSocket auto-reconnect with heartbeat - **Message Retry**: Auto-retry failed messages (up to 2 times) - **Graceful Shutdown**: Clean shutdown on SIGTERM/SIGINT ## Files | File | Description | |------|-------------| | `qq-bot.js` | Main program (WebSocket + OpenClaw integration) | | `logger.js` | Logging system (China timezone + rotation) | | `scripts/health-check.sh` | Health check script | | `package.json` | Dependencies (axios, ws) | ## npm Commands | Command | Description | |---------|-------------| | `npm start` | Start bot | | `npm run health` | Health check | | `npm run logs` | View logs | | `npm run setup` | Initialize config | | `npm run status` | Check status | | `npm run clean` | Clean node_modules | ## Security - Do not commit `open-qq-config.json` to version control - Set permissions: `chmod 600 ~/.openclaw/workspace/open-qq-config.json` - Uses `spawn` instead of `exec` to prevent command injection - Session IDs are whitelisted (alphanumeric + hyphen only) ## Troubleshooting | Issue | Solution | |-------|----------| | Config not found | Run `npm run setup` | | Missing credentials | Edit config file with appId/token/appSecret | | WebSocket failed | Check Token and network | | No reply | Test with `openclaw agent --message "test"` | ## Changelog See [CHANGELOG.md](CHANGELOG.md) ### v0.0.3 (Latest) - 7 new npm commands - FAQ section - Message retry mechanism - Graceful shutdown ## License MIT License ## Links - [ClawHub](https://clawhub.com/skills/openqq) - [QQ Open Platform](https://bot.q.qq.com/) - [OpenClaw Docs](https://docs.openclaw.ai/)

path: package.json
content: {
  "name": "openqq",
  "version": "0.0.4",
  "description": "QQ bot integration for OpenClaw with session isolation and logging",
  "main": "qq-bot.js",
  "bin": {
    "openqq": "./qq-bot.js"
  },
  "scripts": {
    "start": "node qq-bot.js",
    "dev": "node --watch qq-bot.js",
    "test": "echo \"No tests specified\" && exit 0",
    "setup": "cp open-qq-config.json.example ~/.openclaw/workspace/open-qq-config.json && echo '✅ Config created! Edit ~/.openclaw/workspace/open-qq-config.json'",
    "install-deps": "npm install",
    "clean": "rm -rf node_modules package-lock.json",
    "logs": "tail -f ../../logs/qq-bot/qq-bot-$(date +%Y-%m-%d).log",
    "status": "pgrep -f 'node qq-bot.js' > /dev/null && echo '✅ Running' || echo '❌ Not running'",
    "health": "bash scripts/health-check.sh",
    "version": "echo \"openqq v$(node -p \"require('./package.json').version\")\"",
    "test-msg": "node -e \"const {spawn}=require('child_process'); const m=process.argv.slice(3).join(' ')||'你好'; const p=spawn('openclaw',['agent','--session-id','qq-test','--message',m]); p.stdout.on('data',d=>console.log(d.toString())); p.stderr.on('data',d=>console.error(d.toString()));\"",
    "restart": "echo '❌ Use systemctl restart qq-bot (if installed as service)'",
    "stop": "echo '❌ Use systemctl stop qq-bot (if installed as service)' || pkill -f 'node qq-bot.js'"
  },
  "keywords": ["qq", "bot", "openclaw", "websocket"],
  "author": "番茄",
  "license": "MIT",
  "repository": {
    "type": "git",
    "url": "https://clawhub.com/skills/openqq"
  },
  "dependencies": {
    "axios": "^1.13.5",
    "ws": "^8.19.0"
  },
  "engines": {
    "node": ">=16.0.0"
  }
}


path: scripts/health-check.sh
content: #!/bin/bash

# QQ Bot 健康检查脚本

LOG_DIR="$HOME/.openclaw/workspace/logs/qq-bot"
TODAY=$(date +%Y-%m-%d)
LOG_FILE="$LOG_DIR/qq-bot-$TODAY.log"

echo "🔍 QQ Bot 健康检查"
echo "=================="

# 检查进程
if pgrep -f "node qq-bot.js" > /dev/null; then
  echo "✅ 进程状态：运行中"
else
  echo "❌ 进程状态：未运行"
  exit 1
fi

# 检查日志文件
if [ -f "$LOG_FILE" ]; then
  echo "✅ 日志文件：存在"
  
  # 检查最近 5 分钟是否有日志
  if find "$LOG_FILE" -mmin -5 2>/dev/null | grep -q .; then
    echo "✅ 日志更新：正常"
  else
    echo "⚠️  日志更新：可能停滞"
  fi
  
  # 检查最近的错误
  ERRORS=$(tail -100 "$LOG_FILE" 2>/dev/null | grep -c "ERROR" || true)
  ERRORS=${ERRORS:-0}
  if [ "$ERRORS" -gt 0 ] 2>/dev/null; then
    echo "⚠️  最近错误：$ERRORS 条"
  else
    echo "✅ 最近错误：无"
  fi
else
  echo "❌ 日志文件：不存在"
fi

# 检查配置文件
CONFIG_FILE="$HOME/.openclaw/workspace/open-qq-config.json"
if [ -f "$CONFIG_FILE" ]; then
  echo "✅ 配置文件：存在"
else
  echo "❌ 配置文件：不存在"
  exit 1
fi

echo "=================="
echo "✅ 健康检查完成"


path: start-qq-bot.sh
content: #!/bin/bash

CONFIG_FILE="$HOME/.openclaw/workspace/open-qq-config.json"

if [ ! -f "$CONFIG_FILE" ]; then
  echo "❌ 配置文件不存在：$CONFIG_FILE"
  exit 1
fi

cd /root/.openclaw/workspace/skills/openqq
echo "🚀 Starting QQ Bot..."
node qq-bot.js


path: _meta.json
content: ownerId: kn73ngf0s02mcqawszh8pgzcmh8140sg
slug: openqq
version: 0.0.4
publishedAt: 1772077717829

Security scan verdicts — ClawScan: suspicious | static analysis: suspicious | VirusTotal: suspicious | SkillSpector: suspicious (HIGH)