新增webhook url参数
This commit is contained in:
150
start.bat
Normal file
150
start.bat
Normal file
@@ -0,0 +1,150 @@
|
||||
@echo off
|
||||
REM WPS Bot Game Windows启动脚本
|
||||
|
||||
setlocal enabledelayedexpansion
|
||||
|
||||
REM 默认配置
|
||||
set DEFAULT_WEBHOOK_URL=
|
||||
set DEFAULT_HOST=0.0.0.0
|
||||
set DEFAULT_PORT=11000
|
||||
set DEFAULT_WORKERS=1
|
||||
set DEFAULT_LOG_LEVEL=info
|
||||
|
||||
REM 显示帮助信息
|
||||
:show_help
|
||||
echo WPS Bot Game Windows启动脚本
|
||||
echo.
|
||||
echo 用法: %0 [选项]
|
||||
echo.
|
||||
echo 选项:
|
||||
echo -w, --webhook-url URL 设置WPS Webhook URL
|
||||
echo -H, --host HOST 服务器主机地址 (默认: %DEFAULT_HOST%)
|
||||
echo -p, --port PORT 服务器端口 (默认: %DEFAULT_PORT%)
|
||||
echo -W, --workers NUM 工作进程数 (默认: %DEFAULT_WORKERS%)
|
||||
echo -l, --log-level LEVEL 日志级别 (默认: %DEFAULT_LOG_LEVEL%)
|
||||
echo -h, --help 显示此帮助信息
|
||||
echo.
|
||||
echo 示例:
|
||||
echo %0 -w "https://xz.wps.cn/api/v1/webhook/send?key=your_key"
|
||||
echo %0 -w "https://xz.wps.cn/api/v1/webhook/send?key=your_key" -p 8080
|
||||
echo %0 --webhook-url "https://xz.wps.cn/api/v1/webhook/send?key=your_key" --port 8080 --log-level debug
|
||||
goto :eof
|
||||
|
||||
REM 初始化变量
|
||||
set WEBHOOK_URL=%DEFAULT_WEBHOOK_URL%
|
||||
set HOST=%DEFAULT_HOST%
|
||||
set PORT=%DEFAULT_PORT%
|
||||
set WORKERS=%DEFAULT_WORKERS%
|
||||
set LOG_LEVEL=%DEFAULT_LOG_LEVEL%
|
||||
|
||||
REM 解析命令行参数
|
||||
:parse_args
|
||||
if "%~1"=="" goto :start_app
|
||||
if "%~1"=="-w" (
|
||||
set WEBHOOK_URL=%~2
|
||||
shift
|
||||
shift
|
||||
goto :parse_args
|
||||
)
|
||||
if "%~1"=="--webhook-url" (
|
||||
set WEBHOOK_URL=%~2
|
||||
shift
|
||||
shift
|
||||
goto :parse_args
|
||||
)
|
||||
if "%~1"=="-H" (
|
||||
set HOST=%~2
|
||||
shift
|
||||
shift
|
||||
goto :parse_args
|
||||
)
|
||||
if "%~1"=="--host" (
|
||||
set HOST=%~2
|
||||
shift
|
||||
shift
|
||||
goto :parse_args
|
||||
)
|
||||
if "%~1"=="-p" (
|
||||
set PORT=%~2
|
||||
shift
|
||||
shift
|
||||
goto :parse_args
|
||||
)
|
||||
if "%~1"=="--port" (
|
||||
set PORT=%~2
|
||||
shift
|
||||
shift
|
||||
goto :parse_args
|
||||
)
|
||||
if "%~1"=="-W" (
|
||||
set WORKERS=%~2
|
||||
shift
|
||||
shift
|
||||
goto :parse_args
|
||||
)
|
||||
if "%~1"=="--workers" (
|
||||
set WORKERS=%~2
|
||||
shift
|
||||
shift
|
||||
goto :parse_args
|
||||
)
|
||||
if "%~1"=="-l" (
|
||||
set LOG_LEVEL=%~2
|
||||
shift
|
||||
shift
|
||||
goto :parse_args
|
||||
)
|
||||
if "%~1"=="--log-level" (
|
||||
set LOG_LEVEL=%~2
|
||||
shift
|
||||
shift
|
||||
goto :parse_args
|
||||
)
|
||||
if "%~1"=="-h" (
|
||||
call :show_help
|
||||
exit /b 0
|
||||
)
|
||||
if "%~1"=="--help" (
|
||||
call :show_help
|
||||
exit /b 0
|
||||
)
|
||||
echo 未知参数: %~1
|
||||
call :show_help
|
||||
exit /b 1
|
||||
|
||||
:start_app
|
||||
REM 检查Python环境
|
||||
python --version >nul 2>&1
|
||||
if errorlevel 1 (
|
||||
echo 错误: 未找到Python
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
REM 检查依赖
|
||||
python -c "import fastapi, uvicorn" >nul 2>&1
|
||||
if errorlevel 1 (
|
||||
echo 错误: 缺少必要的Python依赖
|
||||
echo 请运行: pip install -r requirements.txt
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
REM 构建启动命令
|
||||
set CMD=python app.py --host %HOST% --port %PORT% --workers %WORKERS% --log-level %LOG_LEVEL%
|
||||
|
||||
if not "%WEBHOOK_URL%"=="" (
|
||||
set CMD=%CMD% --webhook-url "%WEBHOOK_URL%"
|
||||
)
|
||||
|
||||
REM 显示启动信息
|
||||
echo 启动WPS Bot Game...
|
||||
echo 主机: %HOST%
|
||||
echo 端口: %PORT%
|
||||
echo 工作进程: %WORKERS%
|
||||
echo 日志级别: %LOG_LEVEL%
|
||||
if not "%WEBHOOK_URL%"=="" (
|
||||
echo Webhook URL: %WEBHOOK_URL%
|
||||
)
|
||||
echo.
|
||||
|
||||
REM 启动应用
|
||||
%CMD%
|
||||
Reference in New Issue
Block a user