修改
This commit is contained in:
parent
a3503e0be5
commit
32af41f09f
108
.gitignore
vendored
108
.gitignore
vendored
@ -377,3 +377,111 @@ check_disk_usage.py
|
||||
# === 允许跟踪二进制扩展模块(用于分发)===
|
||||
!utils/xianyu_slider_stealth*.pyd
|
||||
!utils/xianyu_slider_stealth*.so
|
||||
|
||||
# ==================== 新增项目特定规则 ====================
|
||||
|
||||
# 用户数据和隐私文件
|
||||
user_data/
|
||||
personal_configs/
|
||||
*.personal.yml
|
||||
*.private.yml
|
||||
|
||||
# 运行时生成的文件
|
||||
*.runtime
|
||||
*.session
|
||||
session_*
|
||||
runtime_*
|
||||
|
||||
# 第三方服务配置
|
||||
*.service.yml
|
||||
*.webhook.yml
|
||||
external_configs/
|
||||
|
||||
# 性能分析和调试文件
|
||||
*.perf
|
||||
*.trace
|
||||
memory_*.dump
|
||||
cpu_*.profile
|
||||
|
||||
# 机器学习模型文件(如果有AI功能扩展)
|
||||
models/
|
||||
*.model
|
||||
*.weights
|
||||
*.checkpoint
|
||||
|
||||
# 容器相关文件
|
||||
.docker/
|
||||
docker-data/
|
||||
container_logs/
|
||||
|
||||
# 监控和统计文件
|
||||
metrics/
|
||||
analytics/
|
||||
*.metrics
|
||||
*.analytics
|
||||
|
||||
# 自动生成的文档
|
||||
auto_docs/
|
||||
generated_docs/
|
||||
|
||||
# 临时API文件
|
||||
api_temp/
|
||||
temp_api/
|
||||
|
||||
# 插件和扩展
|
||||
plugins/
|
||||
extensions/
|
||||
addons/
|
||||
|
||||
# 测试覆盖率报告
|
||||
coverage_html/
|
||||
.coverage.*
|
||||
coverage.xml
|
||||
|
||||
# IDE和编辑器特定文件
|
||||
.vscode/settings.json
|
||||
.vscode/launch.json
|
||||
.idea/workspace.xml
|
||||
.idea/tasks.xml
|
||||
|
||||
# 系统特定文件
|
||||
.DS_Store
|
||||
Thumbs.db
|
||||
desktop.ini
|
||||
*.lnk
|
||||
|
||||
# 网络和代理配置
|
||||
proxy_configs/
|
||||
*.proxy
|
||||
network_configs/
|
||||
|
||||
# ==================== 项目清理后新增规则 ====================
|
||||
|
||||
# 临时文档和说明文件
|
||||
*功能说明.md
|
||||
*修改说明.md
|
||||
*分析报告.md
|
||||
*使用说明.md
|
||||
|
||||
# 轨迹历史文件
|
||||
trajectory_history/
|
||||
*.trajectory
|
||||
|
||||
# 实时日志文件
|
||||
realtime.log
|
||||
*.realtime
|
||||
|
||||
# Nuitka编译报告
|
||||
nuitka-crash-report.xml
|
||||
*.crash-report.xml
|
||||
|
||||
# 项目压缩包
|
||||
*.zip
|
||||
*.tar.gz
|
||||
*.rar
|
||||
*.7z
|
||||
|
||||
# 临时数据库文件
|
||||
*.db-journal
|
||||
*.db-wal
|
||||
*.db-shm
|
||||
|
||||
46
README.md
46
README.md
@ -220,31 +220,39 @@ docker run -d -p 8080:8080 -v %cd%/xianyu-auto-reply/:/app/data/ --name xianyu-a
|
||||
|
||||
### 方式二:从源码构建部署
|
||||
|
||||
#### 🌍 国际版(推荐海外用户)
|
||||
```bash
|
||||
# 1. 克隆项目
|
||||
git clone https://github.com/zhinianboke/xianyu-auto-reply.git
|
||||
cd xianyu-auto-reply
|
||||
|
||||
# 2. 设置脚本执行权限(Linux/macOS)
|
||||
chmod +x docker-deploy.sh
|
||||
# 2. 使用完整版配置(包含Redis缓存等增强功能)
|
||||
docker-compose up -d --build
|
||||
|
||||
# 3. 一键部署(自动构建镜像)
|
||||
./docker-deploy.sh
|
||||
# 3. 访问系统
|
||||
# http://localhost:8080
|
||||
```
|
||||
|
||||
# 4. 访问系统
|
||||
#### 🇨🇳 中国版(推荐国内用户)
|
||||
```bash
|
||||
# 1. 克隆项目
|
||||
git clone https://github.com/zhinianboke/xianyu-auto-reply.git
|
||||
cd xianyu-auto-reply
|
||||
|
||||
# 2. 使用中国镜像源配置(下载速度更快)
|
||||
docker-compose -f docker-compose-cn.yml up -d --build
|
||||
|
||||
# 3. 访问系统
|
||||
# http://localhost:8080
|
||||
```
|
||||
|
||||
**Windows用户**:
|
||||
```cmd
|
||||
# 使用Windows批处理脚本(推荐)
|
||||
docker-deploy.bat
|
||||
|
||||
# 或者使用Git Bash/WSL
|
||||
bash docker-deploy.sh
|
||||
|
||||
# 或者直接使用Docker Compose
|
||||
# 国际版
|
||||
docker-compose up -d --build
|
||||
|
||||
# 中国版(推荐)
|
||||
docker-compose -f docker-compose-cn.yml up -d --build
|
||||
```
|
||||
|
||||
### 方式三:本地开发部署
|
||||
@ -284,6 +292,20 @@ python Start.py
|
||||
- **Docker**: 20.10+ (Docker部署)
|
||||
- **Docker Compose**: 2.0+ (Docker部署)
|
||||
|
||||
### ⚙️ 环境变量配置(可选)
|
||||
|
||||
如需自定义配置,可以使用环境变量:
|
||||
|
||||
```bash
|
||||
# 复制环境变量模板(可选)
|
||||
cp .env.example .env
|
||||
|
||||
# 主要配置项
|
||||
WEB_PORT=8080 # Web服务端口
|
||||
ADMIN_PASSWORD=your-password # 管理员密码
|
||||
DEBUG=false # 调试模式
|
||||
```
|
||||
|
||||
|
||||
|
||||
### 🌐 访问系统
|
||||
|
||||
@ -25,9 +25,56 @@ def ensure_nuitka():
|
||||
return False
|
||||
|
||||
|
||||
def clean_old_files():
|
||||
"""清理旧的编译产物"""
|
||||
import os
|
||||
import glob
|
||||
|
||||
patterns = [
|
||||
"utils/xianyu_slider_stealth.*.pyd",
|
||||
"utils/xianyu_slider_stealth.*.so",
|
||||
"utils/xianyu_slider_stealth.build",
|
||||
"utils/xianyu_slider_stealth.dist"
|
||||
]
|
||||
|
||||
for pattern in patterns:
|
||||
for file_path in glob.glob(pattern):
|
||||
try:
|
||||
if os.path.isfile(file_path):
|
||||
os.remove(file_path)
|
||||
print(f"✓ 已删除旧文件: {file_path}")
|
||||
elif os.path.isdir(file_path):
|
||||
import shutil
|
||||
shutil.rmtree(file_path)
|
||||
print(f"✓ 已删除旧目录: {file_path}")
|
||||
except Exception as e:
|
||||
print(f"⚠️ 无法删除 {file_path}: {e}")
|
||||
|
||||
|
||||
def check_permissions():
|
||||
"""检查目录权限"""
|
||||
try:
|
||||
test_file = OUT_DIR / "test_write.tmp"
|
||||
test_file.write_text("test")
|
||||
test_file.unlink()
|
||||
return True
|
||||
except Exception as e:
|
||||
print(f"✗ 目录权限检查失败: {e}")
|
||||
print("💡 请尝试以管理员身份运行此脚本")
|
||||
return False
|
||||
|
||||
|
||||
def build():
|
||||
OUT_DIR.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
# 检查权限
|
||||
if not check_permissions():
|
||||
return 1
|
||||
|
||||
# 清理旧文件
|
||||
print("🧹 清理旧的编译产物...")
|
||||
clean_old_files()
|
||||
|
||||
cmd = [
|
||||
sys.executable, "-m", "nuitka",
|
||||
"--module",
|
||||
@ -45,9 +92,20 @@ def build():
|
||||
]
|
||||
|
||||
print("执行编译命令:\n ", " ".join(cmd))
|
||||
result = subprocess.run(cmd, text=True)
|
||||
if result.returncode != 0:
|
||||
print("✗ 编译失败 (Nuitka 返回非零)")
|
||||
try:
|
||||
result = subprocess.run(cmd, text=True, timeout=300) # 5分钟超时
|
||||
if result.returncode != 0:
|
||||
print("✗ 编译失败 (Nuitka 返回非零)")
|
||||
print("💡 可能的解决方案:")
|
||||
print(" 1. 以管理员身份运行此脚本")
|
||||
print(" 2. 关闭杀毒软件的实时保护")
|
||||
print(" 3. 检查是否有其他Python进程在运行")
|
||||
return 1
|
||||
except subprocess.TimeoutExpired:
|
||||
print("✗ 编译超时 (5分钟)")
|
||||
return 1
|
||||
except Exception as e:
|
||||
print(f"✗ 编译过程中发生错误: {e}")
|
||||
return 1
|
||||
|
||||
# 列出 utils 目录下的产物
|
||||
@ -65,11 +123,30 @@ def build():
|
||||
|
||||
|
||||
def main():
|
||||
print("🔨 开始编译 xianyu_slider_stealth 模块...")
|
||||
print("📁 项目目录:", Path.cwd())
|
||||
|
||||
if not SRC.exists():
|
||||
print(f"✗ 源文件不存在: {SRC}")
|
||||
return 1
|
||||
|
||||
print(f"📄 源文件: {SRC}")
|
||||
print(f"📂 输出目录: {OUT_DIR}")
|
||||
|
||||
if not ensure_nuitka():
|
||||
return 2
|
||||
|
||||
# 检查是否以管理员身份运行(Windows)
|
||||
import os
|
||||
if os.name == 'nt': # Windows
|
||||
try:
|
||||
import ctypes
|
||||
is_admin = ctypes.windll.shell32.IsUserAnAdmin()
|
||||
if not is_admin:
|
||||
print("⚠️ 建议以管理员身份运行此脚本以避免权限问题")
|
||||
except:
|
||||
pass
|
||||
|
||||
return build()
|
||||
|
||||
|
||||
|
||||
@ -60,9 +60,9 @@ email-validator>=2.0.0
|
||||
# ==================== 数据处理和验证 ====================
|
||||
xlsxwriter>=3.1.0
|
||||
|
||||
|
||||
# ==================== 构建二进制扩展模块(Nuitka) ====================
|
||||
# 用于运行 build_binary_module.py 将 utils/xianyu_slider_stealth.py 编译为 .pyd/.so
|
||||
# ==================== 构建二进制扩展模块(可选) ====================
|
||||
# 用于编译性能关键模块,提升运行效率
|
||||
# 如果不需要编译功能,可以注释掉以下依赖
|
||||
nuitka>=2.7
|
||||
ordered-set>=4.1.0
|
||||
zstandard>=0.22.0
|
||||
|
||||
Binary file not shown.
@ -2,19 +2,34 @@
|
||||
|
||||
# Stubs included by default
|
||||
from __future__ import annotations
|
||||
from config import config
|
||||
from playwright.sync_api import ElementHandle, sync_playwright
|
||||
from typing import Any, Dict, List, Optional, Tuple
|
||||
from typing_extensions import Self
|
||||
import asyncio
|
||||
import json
|
||||
import logging
|
||||
import os
|
||||
import random
|
||||
import shutil
|
||||
import tempfile
|
||||
import threading
|
||||
import time
|
||||
|
||||
SLIDER_MAX_CONCURRENT = 3
|
||||
SLIDER_WAIT_TIMEOUT = 60
|
||||
class SliderConcurrencyManager:
|
||||
def __new__(cls: cls) -> Any: ...
|
||||
def __init__(self: Self) -> None: ...
|
||||
def can_start_instance(self: Self, user_id: str) -> bool: ...
|
||||
def wait_for_slot(self: Self, user_id: str, timeout: int) -> bool: ...
|
||||
def register_instance(self: Self, user_id: str, instance: Any) -> Any: ...
|
||||
def unregister_instance(self: Self, user_id: str) -> Any: ...
|
||||
def get_stats(self: Self) -> Any: ...
|
||||
|
||||
class XianyuSliderStealth:
|
||||
def __init__(self: Self, user_id: str, enable_learning: bool) -> None: ...
|
||||
def init_browser(self: Self) -> Any: ...
|
||||
def _cleanup_on_init_failure(self: Self) -> Any: ...
|
||||
def _load_success_history(self: Self) -> List[Dict[str, Any]]: ...
|
||||
def _save_success_record(self: Self, trajectory_data: Dict[str, Any]) -> Any: ...
|
||||
def _optimize_trajectory_params(self: Self) -> Dict[str, Any]: ...
|
||||
@ -33,7 +48,7 @@ class XianyuSliderStealth:
|
||||
def close_browser(self: Self) -> Any: ...
|
||||
def run(self: Self, url: str) -> Any: ...
|
||||
|
||||
def process_user_url(user_id: str, url: str, enable_learning: bool) -> Any:
|
||||
def get_slider_stats() -> Any:
|
||||
...
|
||||
|
||||
|
||||
@ -45,13 +60,16 @@ __name__ = ...
|
||||
import time
|
||||
import random
|
||||
import logging
|
||||
import asyncio
|
||||
import json
|
||||
import os
|
||||
import threading
|
||||
import tempfile
|
||||
import shutil
|
||||
import playwright
|
||||
import playwright.sync_api
|
||||
import playwright.sync_api.sync_playwright
|
||||
import playwright.sync_api.ElementHandle
|
||||
import typing
|
||||
import config
|
||||
import re
|
||||
import sys
|
||||
Loading…
Reference in New Issue
Block a user