-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathstart_windows.cmd
82 lines (74 loc) · 2.11 KB
/
start_windows.cmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
@echo off
setlocal enabledelayedexpansion
:: check if git exists
where git >nul 2>nul
if %errorlevel% neq 0 (
echo Git is not installed or not in PATH. Please install Git and try again.
echo to install git, visit https://git-scm.com/download/win
exit /b 1
)
:: Check if Python and pip are installed
where python >nul 2>nul
if %errorlevel% neq 0 (
echo Python is not installed or not in PATH. Please install Python and try again.
echo To install Python, visit https://www.python.org/downloads/
exit /b 1
)
:: check if py.exe exists
where py >nul 2>nul
if %errorlevel% neq 0 (
:: set python.exe as executer
set python_alias=python
)
:: set py.exe as executor
set python_alias=py
where pip >nul 2>nul
if %errorlevel% neq 0 (
echo pip is not installed or not in PATH. Please install pip and try again.
exit /b 1
)
:: Display initial messages
echo ==========================================
echo Press CTRL+C to stop the bot
echo ==========================================
timeout /t 3
:loop
:: Update the bot
echo ==========================================
echo Updating bot...
echo ==========================================
git pull origin main
if %errorlevel% neq 0 (
echo Failed to update the bot. Retrying in 5 seconds...
timeout /t 5
goto loop
)
echo Project updated successfully
timeout /t 2
echo ==========================================
echo Updating dependencies...
echo ==========================================
%python_alias% -m pip install -r requirements.txt >nul 2>nul
if %errorlevel% neq 0 (
echo Failed to update dependencies. Retrying in 5 seconds...
timeout /t 5
goto loop
)
echo Dependencies updated successfully
:: Start the bot
echo ==========================================
echo Starting bot...
echo ==========================================
py main.py
if %errorlevel% neq 0 (
echo Bot encountered an error. Restarting in 5 seconds...
) else (
echo Bot stopped. Restarting in 5 seconds...
)
timeout /t 5
goto loop
:ctrlc
echo ==========================================
echo CTRL+C pressed. Exiting...
echo ==========================================
exit /b