Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to the Windows Batchs #4212

Closed
danielsdian opened this issue Aug 18, 2016 · 3 comments
Closed

Update to the Windows Batchs #4212

danielsdian opened this issue Aug 18, 2016 · 3 comments

Comments

@danielsdian
Copy link
Contributor

Guys, before I screw up GitHub, I decided to attach the updated batches here. Can someone please create a PR and merge it please?

Delete both PyYAML files from PokemonGo-Bot\windows_bat

[INSTALL BATCH]

TITLE PokemonGo-Bot Installer
CLS
@echo OFF

:init
setlocal EnableDelayedExpansion
path c:\Program Files\Git\cmd;%PATH%
path C:\Python27;%PATH%
path C:\Python27\Scripts;%PATH%
set DownPathPython=https://www.python.org/ftp/python/2.7.12/
set DownPathGit=https://github.com/git-for-windows/git/releases/download/v2.9.3.windows.1/
set DownPathVisual=https://download.microsoft.com/download/7/9/6/796EF2E4-801B-4FC4-AB28-B59FBF6D907B/
set VisualFName=VCForPython27.msi
set PythonFName86=python-2.7.12.msi
set PythonFName64=python-2.7.12.amd64.msi
set GitFName86=Git-2.9.3-32-bit.exe
set GitFName64=Git-2.9.3-64-bit.exe
set "batchPath=%~0"
for %%k in (%0) do set batchName=%%~nk
set "vbsGetPrivileges=%temp%\OEgetPriv_%batchName%.vbs"

:checkPrivileges
NET FILE 1>NUL 2>NUL
if '%errorlevel%' == '0' ( goto gotPrivileges ) else ( goto getPrivileges )

:getPrivileges
if '%1'=='ELEV' (echo ELEV & shift /1 & goto gotPrivileges)
@echo Set UAC = CreateObject^("Shell.Application"^) > "%vbsGetPrivileges%"
@echo args = "ELEV " >> "%vbsGetPrivileges%"
@echo For Each strArg in WScript.Arguments >> "%vbsGetPrivileges%"
@echo args = args ^& strArg ^& " " >> "%vbsGetPrivileges%"
@echo Next >> "%vbsGetPrivileges%"
@echo UAC.ShellExecute "!batchPath!", args, "", "runas", 1 >> "%vbsGetPrivileges%"
"%SystemRoot%\System32\WScript.exe" "%vbsGetPrivileges%" %*
exit /B

:gotPrivileges
setlocal & pushd .
cd /d %~dp0
if '%1'=='ELEV' (del "%vbsGetPrivileges%" 1>nul 2>nul & shift /1)

:detectOS
reg Query "HKLM\Hardware\Description\System\CentralProcessor\0" | find /i "x86" > NUL && set OS=32-BIT || set OS=64-BIT

:CheckInstallPath
CLS
@echo --------------------Installation Path--------------------
@echo.
@echo.
@echo.
set InstallPath=
set /p InstallPath= "Choose an installation folder or press Enter to close:" ||goto:eof
set PGBotPath=%InstallPath%\PokemonGo-Bot
set DownPath=%InstallPath%\Install-Files
if not exist %DownPath% md %DownPath%
if "%~dp0"=="%PGBotPath%\windows_bat" (
COPY "%PGBotPath%\windows_bat\PokemonGo-Bot-Install.bat" %InstallPath%
CALL "%InstallPath%\PokemonGo-Bot-Install.bat"
exit.
) ELSE (
@echo Installation Path OK! Proceeding!
)
@echo.
@echo.
@echo.

:Menu
CLS
@echo --------------------PokemonGo-Bot Installer--------------------
@echo.
@echo.
@echo.
if "%OS%" == "32-BIT" (
@echo. 1 - Install 32-Bit software
) ELSE (
@echo. 1 - Install 64-Bit software
)
@echo.
@echo. 2 - Install PokemonGo-Bot
@echo.
@echo.
@echo.

:_choice
set _ok=
set /p _ok= Choose an option or press Enter to close: ||goto:eof
if "%OS%" == "32-BIT" IF "%_ok%" == "1" SET CHOICE=32Bit&GOTO :32Bit
if "%OS%" == "64-BIT" IF "%_ok%" == "1" SET CHOICE=64Bit&GOTO :64Bit
IF "%_ok%" == "2" SET CHOICE=InstallBot&GOTO :InstallBot
GOTO :_choice

:32bit
CLS
@echo --------------------Installation of required software--------------------
@echo.
@echo Downloading Git...
if not exist %DownPath%%GitFName86% call:getit %DownPathGit% %GitFName86%
@echo Downloading Python...
if not exist %DownPath%%PythonFName86% call:getit %DownPathPython% %PythonFName86%
@echo Downloading Visual C++ for Python...
if not exist %DownPath%%VisualFName% call:getit %DownPathVisual% %VisualFName%
@echo Installing Git...
if exist %DownPath%%GitFName86% call:installit %GitFName86% /SILENT
@echo Installing Python...
if exist %DownPath%%PythonFName86% call:installit %PythonFName86% /quiet
@echo Installing Visual C++ for Python...
if exist %DownPath%%VisualFName% call:installit %VisualFName% /quiet
@echo.
@echo.
@echo.
@echo Installation of 32-Bit software is finished.
@echo.
@echo Choose Install PokemonGo-Bot in next screen to complete.
@echo.
@echo Wait 5 seconds or press any key to continue...
@echo.
@echo.
@echo.
timeout /t 5 >nul
goto:Menu

:64bit
CLS
@echo --------------------Installation of required software--------------------
@echo.
@echo Downloading Git...
if not exist %DownPath%%GitFName64% call:getit %DownPathGit% %GitFName64%
@echo Downloading Python...
if not exist %DownPath%%PythonFName64% call:getit %DownPathPython% %PythonFName64%
@echo Downloading Visual C++ for Python...
if not exist %DownPath%%VisualFName% call:getit %DownPathVisual% %VisualFName%
@echo Installing Git...
if exist %DownPath%%GitFName64% call:installit %GitFName64% /SILENT
@echo Installing Python...
if exist %DownPath%%PythonFName64% call:installit %PythonFName64% /quiet
@echo Installing Visual C++ for Python...
if exist %DownPath%%VisualFName% call:installit %VisualFName% /quiet
@echo.
@echo.
@echo.
@echo Installation of 64-Bit software is finished.
@echo.
@echo Choose Install PokemonGo-Bot in next screen to complete.
@echo.
@echo Wait 5 seconds or press any key to continue...
@echo.
@echo.
@echo.
timeout /t 5 >nul
goto:Menu

:getit
start /wait powershell -Command "Invoke-WebRequest %~1%~2 -OutFile %DownPath%%~2"
goto:eof

:installit
start /wait %DownPath%%~1 %~2
goto:eof

:InstallBot
CLS
@echo --------------------Creating Backup--------------------
@echo.
@echo.
@echo.
if exist %PGBotPath%\configs\config.json copy %PGBotPath%\configs\config.json %DownPath%
if exist %PGBotPath%\web\config\userdata.js copy %PGBotPath%\web\config\userdata.js %DownPath%
if exist %PGBotPath%\encrypt. copy %PGBotPath%\encrypt. %DownPath%
@echo.
@echo.
@echo.
@echo --------------------Downloading PokemonGo-Bot--------------------
@echo.
@echo.
@echo.
if exist %PGBotPath% rmdir %PGBotPath% /s /q
if not exist %PGBotPath% md %PGBotPath%
cd C:\Python27
pip2 install --upgrade pip
pip2 install --upgrade virtualenv
git clone --recursive -b master https://github.com/PokemonGoF/PokemonGo-Bot %PGBotPath%
pip2 install -r %PGBotPath%\requirements.txt
@echo.
@echo.
@echo.
@echo --------------------Restoring Backup--------------------
@echo.
@echo.
@echo.
if exist %DownPath%\encrypt. COPY %DownPath%\encrypt. %PGBotPath%
if exist %DownPath%\config.json COPY %DownPath%\config.json %PGBotPath%\configs
if exist %DownPath%\userdata.js COPY %DownPath%\userdata.js %PGBotPath%\web\config
@echo.
@echo.
@echo.

:FinalInstructions
CLS
@echo --------------------File customization--------------------
@echo.
@echo.
@echo.
@echo Before starting the bot, please copy the following files to %PGBotPath% if you dont have them yet.
@echo.
@echo.
@echo.
@echo ---- encrypt.so / encrypt.dll or encrypt_64.dll
@echo Get them from our Slack chat!
@echo "https://pokemongo-bot.herokuapp.com/"
@echo.
@echo.
@echo.
@echo Remember to configure both config.json and userdata.js!
@echo.
@echo.
@echo.
@echo "%PGBotPath%/configs/config.json"
@echo INSTRUCTIONS:
@echo "https://github.com/PokemonGoF/PokemonGo-Bot/blob/master/docs/configuration_files.md"
@echo.
@echo "%PGBotPath%/web/config/userdata.js"
@echo INSTRUCTIONS:
@echo "https://github.com/PokemonGoF/PokemonGo-Bot/blob/master/docs/google_map.md"
@echo.
@echo To get an Google Map API Key:
@echo "https://developers.google.com/maps/documentation/javascript/get-api-key"
@echo.
@echo.
@echo.
@Pause

:eof
ENDLOCAL
exit


[START BATCH]
TITLE PokemonGo-Bot
CLS
@echo OFF

:init
setlocal DisableDelayedExpansion
path c:\Program Files\Git\cmd;%PATH%
path C:\Python27;%PATH%
path C:\Python27\Scripts;%PATH%
set "batchPath=%~0"
for %%k in (%0) do set batchName=%%~nk
set "vbsGetPrivileges=%temp%\OEgetPriv_%batchName%.vbs"
setlocal EnableDelayedExpansion

:checkPrivileges
NET FILE 1>NUL 2>NUL
if '%errorlevel%' == '0' ( goto gotPrivileges ) else ( goto getPrivileges )

:getPrivileges
if '%1'=='ELEV' (echo ELEV & shift /1 & goto gotPrivileges)
@echo Set UAC = CreateObject^("Shell.Application"^) > "%vbsGetPrivileges%"
@echo args = "ELEV " >> "%vbsGetPrivileges%"
@echo For Each strArg in WScript.Arguments >> "%vbsGetPrivileges%"
@echo args = args ^& strArg ^& " " >> "%vbsGetPrivileges%"
@echo Next >> "%vbsGetPrivileges%"
@echo UAC.ShellExecute "!batchPath!", args, "", "runas", 1 >> "%vbsGetPrivileges%"
"%SystemRoot%\System32\WScript.exe" "%vbsGetPrivileges%" %*
exit /B

:gotPrivileges
setlocal & pushd .
cd /d %~dp0
if '%1'=='ELEV' (del "%vbsGetPrivileges%" 1>nul 2>nul & shift /1)

:startBot
CLS
@echo --------------------Verifying PokemonGo-Bot version--------------------
@echo.
CD..
git pull
git submodule update --init --recursive
@echo.
@echo WARNING: Verify if the Config.json file got updated. If Yes, check if your modifications are still valid before proceeding.
@echo.
@timeout /t 10
@echo.
CLS
@echo --------------------Initializing web server--------------------
@echo.
@echo.
set BatchPath="%~dp0"
start cmd.exe /k "CD %BatchPath%&CD..&CD web&python -m SimpleHTTPServer"
@echo.
@echo.
CLS
@echo --------------------Starting bot--------------------
@echo.
@echo.

:loop
TITLE=PokemonGo-Bot
CD %BatchPath%
CD ..
python pokecli.py
if errorlevel 1 goto restart
if errorlevel 0 goto eof

:restart
call:problem
timeout /t 60
goto loop
goto:eof

:problem
@echo.
@echo. Something went wrong and the bot needed to be restarted. Please investigate the cause.
@echo.
goto:eof

:eof
exit

@k4n30
Copy link
Contributor

k4n30 commented Aug 18, 2016

@danielsdian I don't like this idea of pasting the random code in an issue (which is for bugs or feature requests) and then hoping someone else will do the work for you. I'm going to add the tags and hope that someone creates the PR, but unless they have an understanding of why you have made this change and what problems it fixes, I doubt anyone is going to want to take this on.

If a PR hasn't been created in a few days, I'm going to close this issue. I'd suggest you learn GitHub and create a PR (fork this repo and mess around with it on your own first if you're not confident)

@danielsdian
Copy link
Contributor Author

Yeah, but I have been trying to create a PR and Im messing everything. I dont use GitHub in a daily basis and my idea was just to share something I use.

@k4n30
Copy link
Contributor

k4n30 commented Aug 18, 2016

I'd suggest joining the slack and asking for assistance with creating a PR. There' pleanty of great people, who'd be more than happy to help you out, especially as you are giving back to the community :)

Then when you've worked it out, you can come back here and close this issue :) See I'm helping you learn without realising it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants