- start.sh: Linux/Mac one-click launcher - start.bat: Windows one-click launcher - Both scripts auto-detect/install: - Python 3.13+ - uv package manager - Chrome/Chromium browser - Sync Python dependencies - Create .env/config.json from templates if missing - Default to unlimited accounts (--count 0) - Pass through CLI args for custom runs
189 lines
4.6 KiB
Batchfile
189 lines
4.6 KiB
Batchfile
@echo off
|
|
chcp 65001 >nul 2>&1
|
|
setlocal enabledelayedexpansion
|
|
title Grok 注册机 - 一键启动
|
|
|
|
echo ============================================
|
|
echo Grok 注册机 - 一键启动 (Windows)
|
|
echo ============================================
|
|
echo.
|
|
|
|
cd /d "%~dp0"
|
|
|
|
:: ── 1. 检测 Python 3.13+ ──
|
|
echo [1/5] 检测 Python 环境...
|
|
set PYTHON_BIN=
|
|
|
|
:: 尝试常见 Python 路径
|
|
for %%P in (
|
|
"%LOCALAPPDATA%\Programs\Python\Python313\python.exe"
|
|
"%LOCALAPPDATA%\Programs\Python\Python314\python.exe"
|
|
"python3.13"
|
|
"python3"
|
|
"python"
|
|
"py"
|
|
) do (
|
|
if not defined PYTHON_BIN (
|
|
where %%~P >nul 2>&1
|
|
if !errorlevel! equ 0 (
|
|
call :check_python_version %%~P
|
|
)
|
|
)
|
|
)
|
|
|
|
:: 检查 .venv
|
|
if not defined PYTHON_BIN (
|
|
if exist ".venv\Scripts\python.exe" (
|
|
call :check_python_version ".venv\Scripts\python.exe"
|
|
)
|
|
)
|
|
|
|
if not defined PYTHON_BIN (
|
|
echo [X] 未找到 Python 3.13+
|
|
echo.
|
|
echo 请通过以下任一方式安装 Python 3.13:
|
|
echo.
|
|
echo 方式 1: 官方安装包 (推荐)
|
|
echo https://www.python.org/downloads/
|
|
echo 下载 Python 3.13.x,安装时勾选 "Add Python to PATH"
|
|
echo.
|
|
echo 方式 2: 使用 uv 自动获取
|
|
echo powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
|
|
echo uv python install 3.13
|
|
echo.
|
|
echo 方式 3: winget
|
|
echo winget install Python.Python.3.13
|
|
echo.
|
|
pause
|
|
exit /b 1
|
|
)
|
|
|
|
echo [OK] Python: %PYTHON_BIN%
|
|
echo.
|
|
|
|
:: ── 2. 检测/安装 uv ──
|
|
echo [2/5] 检测 uv 包管理器...
|
|
where uv >nul 2>&1
|
|
if %errorlevel% equ 0 (
|
|
for /f "tokens=*" %%V in ('uv --version 2^>nul') do echo [OK] uv: %%V
|
|
goto :uv_ok
|
|
)
|
|
|
|
echo [!] 未检测到 uv,正在自动安装...
|
|
powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
|
|
if %errorlevel% neq 0 (
|
|
echo [X] uv 安装失败,请手动安装:
|
|
echo powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
|
|
pause
|
|
exit /b 1
|
|
)
|
|
|
|
:: 刷新 PATH
|
|
call :refresh_path
|
|
|
|
where uv >nul 2>&1
|
|
if %errorlevel% equ 0 (
|
|
for /f "tokens=*" %%V in ('uv --version 2^>nul') do echo [OK] uv 安装成功: %%V
|
|
) else (
|
|
echo [X] uv 安装后仍未找到,请重启终端后重试
|
|
pause
|
|
exit /b 1
|
|
)
|
|
:uv_ok
|
|
echo.
|
|
|
|
:: ── 3. 同步依赖 ──
|
|
echo [3/5] 同步 Python 依赖...
|
|
uv sync
|
|
if %errorlevel% neq 0 (
|
|
echo [X] 依赖同步失败
|
|
pause
|
|
exit /b 1
|
|
)
|
|
echo [OK] 依赖同步完成
|
|
echo.
|
|
|
|
:: ── 4. 检测浏览器 ──
|
|
echo [4/5] 检测浏览器...
|
|
set BROWSER_FOUND=0
|
|
|
|
for %%B in (
|
|
"C:\Program Files\Google\Chrome\Application\chrome.exe"
|
|
"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe"
|
|
"%LOCALAPPDATA%\Google\Chrome\Application\chrome.exe"
|
|
"chrome"
|
|
"chromium"
|
|
) do (
|
|
if !BROWSER_FOUND! equ 0 (
|
|
if exist %%B (
|
|
echo [OK] 浏览器: %%B
|
|
set BROWSER_FOUND=1
|
|
)
|
|
)
|
|
)
|
|
|
|
if %BROWSER_FOUND% equ 0 (
|
|
echo [!] 未检测到 Chrome/Chromium 浏览器
|
|
echo.
|
|
echo DrissionPage 需要 Chrome 才能运行。
|
|
echo 请安装 Google Chrome: https://www.google.com/chrome/
|
|
echo.
|
|
echo 脚本将继续,但注册可能因缺少浏览器而失败。
|
|
)
|
|
echo.
|
|
|
|
:: ── 5. 配置文件模板 ──
|
|
echo [5/5] 检查配置文件...
|
|
|
|
if not exist ".env" (
|
|
if exist ".env.example" (
|
|
copy ".env.example" ".env" >nul
|
|
echo [!] 已从 .env.example 创建 .env,请编辑填入真实配置
|
|
)
|
|
) else (
|
|
echo [OK] .env 已存在
|
|
)
|
|
|
|
if not exist "config.json" (
|
|
if exist "config.example.json" (
|
|
copy "config.example.json" "config.json" >nul
|
|
echo [!] 已从 config.example.json 创建 config.json,请编辑填入真实配置
|
|
)
|
|
) else (
|
|
echo [OK] config.json 已存在
|
|
)
|
|
echo.
|
|
|
|
echo ============================================
|
|
echo 环境就绪,启动 register_cli.py
|
|
echo ============================================
|
|
echo.
|
|
|
|
:: 默认不限数量(--count 0),除非用户显式传参
|
|
if "%~1"=="" (
|
|
echo [*] 默认模式:不限数量,持续注册(Ctrl+C 停止)
|
|
echo.
|
|
uv run python -u register_cli.py --count 0
|
|
) else (
|
|
uv run python -u register_cli.py %*
|
|
)
|
|
|
|
echo.
|
|
pause
|
|
exit /b 0
|
|
|
|
:: ── 辅助函数 ──
|
|
|
|
:check_python_version
|
|
:: 检查指定 Python 版本是否 >= 3.13
|
|
set "PY_PATH=%~1"
|
|
"%PY_PATH%" -c "import sys; sys.exit(0 if sys.version_info >= (3,13) else 1)" >nul 2>&1
|
|
if %errorlevel% equ 0 (
|
|
set "PYTHON_BIN=%PY_PATH%"
|
|
)
|
|
exit /b 0
|
|
|
|
:refresh_path
|
|
:: 刷新 PATH,加入 uv 安装路径
|
|
set "PATH=%USERPROFILE%\.local\bin;%USERPROFILE%\.cargo\bin;%PATH%"
|
|
exit /b 0 |