~nickwinston123/armagetronad/arma_chatbot_config

« back to all changes in this revision

Viewing changes to manage_chatbot.bat

  • Committer: hackermans
  • Date: 2025-05-28 18:34:25 UTC
  • Revision ID: nickwinston123@gmail.com-20250528183425-z5cssgt5eeqyqox3

consolidated arma chatbot config programs

- arma_terminal: live console viewer with input passthrough
- game_manager: manages bans, IP rotation, and keeping the game open
- game_updater: syncs updated game files from shared folder
- ollama_chat: ai chatbot 

- launcher: launches all not already opened programs with positioning and window checks

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
@echo off
2
 
setlocal EnableDelayedExpansion
3
 
@echo off
4
 
:: Check for admin privileges
5
 
net session >nul 2>&1
6
 
if %errorLevel% == 0 (
7
 
    echo Running as administrator.
8
 
) else (
9
 
    echo Not running as administrator. Trying to elevate...
10
 
    goto UACPrompt
11
 
)
12
 
 
13
 
:: If the script has admin rights, continue with the rest of the script
14
 
goto startScript
15
 
 
16
 
:UACPrompt
17
 
    echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs"
18
 
    echo UAC.ShellExecute "%~s0", "", "", "runas", 1 >> "%temp%\getadmin.vbs"
19
 
 
20
 
    "%temp%\getadmin.vbs"
21
 
    exit /B
22
 
 
23
 
:startScript
24
 
 
25
 
set OPENVPN_PATH="C:\Program Files\OpenVPN\bin\openvpn.exe"
26
 
set REAL_IP=""
27
 
set CONNECTING_TO_VPN=0
28
 
set /a "counter=0"
29
 
 
30
 
if !counter! geq 10 (
31
 
    echo.
32
 
    echo ------------------ LOOP WRAP ------------------
33
 
    for /L %%i in (1,1,20) do echo.  REM adds 20 blank lines
34
 
    set /a "counter=0"
35
 
)
36
 
 
37
 
tasklist /FI "IMAGENAME eq armagetronad.exe" 2>NUL | find /I /N "armagetronad.exe">NUL
38
 
if "%ERRORLEVEL%"=="0" (
39
 
    echo Armagetronad is running.
40
 
) else (
41
 
    echo Armagetronad is not running.
42
 
    timeout /t 1 > NUL
43
 
    call :Update
44
 
)
45
 
 
46
 
timeout /t 5 /nobreak > NUL
47
 
set /a "counter+=1"
48
 
goto loop
49
 
 
50
 
:ConnectVPN
51
 
    echo. > "C:\Users\itsne\Desktop\arma_chatbot_config\openvpn.log"
52
 
    taskkill /F /FI "WINDOWTITLE eq OpenVPNConnection" 2>NUL
53
 
    set CONNECTING_TO_VPN=1
54
 
 
55
 
    taskkill /F /IM openvpn.exe 2>NUL
56
 
    timeout /t 2 > NUL
57
 
 
58
 
    set OVPN_DIR=C:\Users\itsne\Desktop\arma_chatbot_config\VPN\OVPN
59
 
    set /a "count=0"
60
 
    for %%f in (%OVPN_DIR%\*.ovpn) do (
61
 
        set /a "count+=1"
62
 
        set "file[!count!]=%%f"
63
 
    )
64
 
 
65
 
    set /a "randIndex=(%random% %% count) + 1"
66
 
    set "randFile=!file[%randIndex%]!"
67
 
 
68
 
    echo Using VPN configuration file: !randFile!
69
 
 
70
 
    start "OpenVPNConnection" cmd /c "%OPENVPN_PATH% --config "!randFile!" > "C:\Users\itsne\Desktop\arma_chatbot_config\openvpn.log" 2>&1"
71
 
 
72
 
    REM wait for VPN to connect
73
 
    set VPN_CONNECTED=0
74
 
    for /L %%x in (1,1,6) do (  REM try for up to 6 times with a 5 sec interval to 30 seconds
75
 
        timeout /t 5 > NUL
76
 
        findstr /C:"Initialization Sequence Completed" "C:\Users\itsne\Desktop\arma_chatbot_config\openvpn.log" > NUL
77
 
        if !errorlevel! == 0 (
78
 
            set VPN_CONNECTED=1
79
 
            goto VPNConnected
80
 
        )
81
 
        REM check for auth fail
82
 
        findstr /C:"AUTH: Received control message: AUTH_FAILED" "C:\Users\itsne\Desktop\arma_chatbot_config\openvpn.log" > NUL
83
 
        if !errorlevel! == 0 (
84
 
            echo Authentication failure detected. Retrying...
85
 
            taskkill /F /FI "WINDOWTITLE eq OpenVPNConnection" 2>NUL
86
 
            taskkill /F /IM openvpn.exe 2>NUL
87
 
            REM try to reconnect 
88
 
            goto ConnectVPN
89
 
        )
90
 
    )
91
 
 
92
 
:VPNConnected
93
 
    if !VPN_CONNECTED! == 0 (
94
 
        echo VPN connection failed or took too long.
95
 
    )
96
 
 
97
 
    set CONNECTING_TO_VPN=0
98
 
exit /b
99
 
 
100
 
 
101
 
:CheckVPN
102
 
    if "%CONNECTING_TO_VPN%"=="1" (
103
 
        exit /b
104
 
    )
105
 
 
106
 
    for /f "tokens=2 delims=: " %%i in ('curl -s https://httpbin.org/ip') do (
107
 
        set CURRENT_IP=%%i
108
 
    )
109
 
 
110
 
    ECHO COMPARING %CURRENT_IP% VS %REAL_IP%
111
 
    if "%CURRENT_IP%"=="%REAL_IP%" (
112
 
        echo Not connected to a VPN. Connecting...
113
 
        call :ConnectVPN
114
 
    ) else (
115
 
        echo Connected to a VPN. (%CURRENT_IP%)
116
 
    )
117
 
exit /b
118
 
 
119
 
:Update
120
 
    call :CheckVPN
121
 
    echo Checking if banned..
122
 
    copy /Y "C:\Users\itsne\AppData\Roaming\Armagetron\var\banned.txt" "C:\temp\banned_copy.txt" >NUL 2>&1
123
 
    for /f %%i in (C:\temp\banned_copy.txt) do (
124
 
        echo Banned! Changing IP...
125
 
        call :ConnectVPN
126
 
        goto IPChecked
127
 
    )
128
 
 
129
 
:IPChecked
130
 
 
131
 
echo Killing old process if any
132
 
taskkill /F /IM "armagetronad.exe" 2>NUL
133
 
 
134
 
REM NETWORK LOC ACCESSABLE?
135
 
pushd "\\tsclient\C\" 2>NUL
136
 
if ERRORLEVEL 1 (
137
 
    echo The network location is not accessible!
138
 
    goto StartGame
139
 
)
140
 
 
141
 
popd
142
 
 
143
 
echo Deleting old dist folder
144
 
rmdir /s /q "C:\Users\itsne\Desktop\dist" 2>NUL
145
 
 
146
 
echo Copying new dist folder
147
 
xcopy "\\tsclient\C\Games\ArmagetronProject2.0\dist" "C:\Users\itsne\Desktop\dist" /E /I /Y
148
 
 
149
 
:GenerateTimestamp
150
 
for /f "delims=" %%a in ('wmic OS Get localdatetime ^| find "."') do set datetime=%%a
151
 
set timestamp=%datetime:~0,4%-%datetime:~4,2%-%datetime:~6,2%-%datetime:~8,2%%datetime:~10,2%%datetime:~12,2%
152
 
exit /b
153
 
 
154
 
call :GenerateTimestamp
155
 
 
156
 
echo Creating backup of stats.db...
157
 
copy "C:\Users\itsne\AppData\Roaming\Armagetron\var\stats.db" "C:\Users\itsne\Desktop\arma_chatbot_config\Backups\stats-%timestamp%.db"
158
 
 
159
 
:StartGame
160
 
echo Running new Armagetronad
161
 
start "" "C:\Users\itsne\Desktop\dist\armagetronad.exe"
 
 
b'\\ No newline at end of file'