#!/bin/bash echo "==========================================" echo " 📊 @ktfund_bot 管理员后台" echo "==========================================" echo "" echo "1️⃣ 统计信息" echo "----------------------------------------" user_count=$(grep -oE "用户 [0-9]+" logs/integrated_bot_detailed.log 2>/dev/null | grep -oE "[0-9]+" | sort -u | wc -l) search_count=$(grep -c "镜像.*已转发" logs/integrated_bot_detailed.log 2>/dev/null) ai_count=$(grep -c "AI对话" logs/integrated_bot_detailed.log 2>/dev/null) bot_pid=$(pgrep -f "integrated_bot_ai.py") echo "👥 总访问用户数: $user_count" echo "🔍 搜索执行次数: $search_count" echo "💬 AI对话次数: $ai_count" if [ -n "$bot_pid" ]; then uptime=$(ps -p $bot_pid -o etime= | tr -d " ") echo "⏱ 运行时长: $uptime" else echo "❌ 机器人未运行" fi echo "" echo "2️⃣ 访问用户列表 (Top 10)" echo "----------------------------------------" grep -oE "用户 [0-9]+" logs/integrated_bot_detailed.log 2>/dev/null | grep -oE "[0-9]+" | sort | uniq -c | sort -rn | head -10 | awk "{printf \"%2d. 用户 %s - %d次交互\n\", NR, \$2, \$1}" echo "" echo "3️⃣ 最近用户活动 (最后5条)" echo "----------------------------------------" grep "用户 [0-9]" logs/integrated_bot_detailed.log 2>/dev/null | tail -5 | sed "s/^/ /" echo "" echo "4️⃣ 缓存统计" echo "----------------------------------------" if [ -f "/home/atai/bot_data/cache.db" ]; then cache_count=$(sqlite3 /home/atai/bot_data/cache.db "SELECT COUNT(*) FROM search_cache;" 2>/dev/null || echo "0") cache_size=$(du -h /home/atai/bot_data/cache.db 2>/dev/null | cut -f1 || echo "0") echo "📦 缓存记录数: $cache_count" echo "💿 数据库大小: $cache_size" fi echo "" echo "=========================================="