diff --git a/Dockerfile b/Dockerfile index 36e182d8b4..19f9ea5360 100644 --- a/Dockerfile +++ b/Dockerfile @@ -16,22 +16,19 @@ FROM alpine ARG BUILD_REPO=PokemonGoF/PokemonGo-Bot ARG BUILD_BRANCH=master -ARG TIMEZONE=Etc/UTC LABEL build_repo=$BUILD_REPO build_branch=$BUILD_BRANCH WORKDIR /usr/src/app VOLUME ["/usr/src/app/configs", "/usr/src/app/web"] -RUN apk -U --no-cache add python py-pip \ +RUN apk -U --no-cache add python py-pip tzdata \ && rm -rf /var/cache/apk/* \ && find / -name '*.pyc' -o -name '*.pyo' | xargs -rn1 rm -f ADD http://pgoapi.com/pgoencrypt.tar.gz /tmp/pgoencrypt.tar.gz ADD https://raw.githubusercontent.com/$BUILD_REPO/$BUILD_BRANCH/requirements.txt . -RUN apk -U --no-cache add --virtual .build-dependencies python-dev gcc make musl-dev git tzdata \ - && cp -fa /usr/share/zoneinfo/$TIMEZONE /etc/localtime \ - && echo $TIMEZONE > /etc/timezone \ +RUN apk -U --no-cache add --virtual .build-dependencies python-dev gcc make musl-dev git \ && tar zxf /tmp/pgoencrypt.tar.gz -C /tmp \ && make -C /tmp/pgoencrypt/src \ && cp /tmp/pgoencrypt/src/libencrypt.so /usr/src/app/encrypt.so \ @@ -48,4 +45,14 @@ RUN apk -U --no-cache add --virtual .pgobot-dependencies wget ca-certificates ta && apk del .pgobot-dependencies \ && rm -rf /var/cache/apk/* /tmp/pgobot-version -ENTRYPOINT ["python", "pokecli.py"] +RUN printf "#!/bin/sh\n\ +\n\ +TIMEZONE=\${TIMEZONE:-Etc/UTC}\n\ +\n\ +ln -sfn /usr/share/zoneinfo/\$TIMEZONE /etc/localtime\n\ +echo \$TIMEZONE > /etc/timezone\n\ +\n\ +python pokecli.py \$@\n" > /entrypoint.sh \ + && chmod +x /entrypoint.sh + +ENTRYPOINT ["/entrypoint.sh"] diff --git a/configs/config.json.example b/configs/config.json.example index 9cde3ee824..e7a6244691 100644 --- a/configs/config.json.example +++ b/configs/config.json.example @@ -12,7 +12,6 @@ "config": { "enabled": false, "master": null, - "min_interval": 120, "// old syntax, still supported: alert_catch": ["all"], "// new syntax:": {}, "alert_catch": { diff --git a/docker-compose.yml b/docker-compose.yml index 291b692939..8625631650 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -6,6 +6,8 @@ services: - ./configs:/usr/src/app/configs - ./data:/usr/src/app/data - ./web:/usr/src/app/web + environment: + - TIMEZONE=Etc/UTC stdin_open: true tty: true bot1-pokegoweb: diff --git a/docker-compose_tor.yml b/docker-compose_tor.yml index bb5309e826..33b9acbfc3 100644 --- a/docker-compose_tor.yml +++ b/docker-compose_tor.yml @@ -23,6 +23,8 @@ services: - ./configs:/usr/src/app/configs - ./data:/usr/src/app/data - ./web:/usr/src/app/web + environment: + - TIMEZONE=Etc/UTC stdin_open: true tty: true bot1-pokegoweb: diff --git a/docs/configuration_files.md b/docs/configuration_files.md index 8f4abb9625..d6828229d4 100644 --- a/docs/configuration_files.md +++ b/docs/configuration_files.md @@ -991,7 +991,6 @@ Bot answer on command '/info' self stats. * `telegram_token` : bot token (getting [there](https://core.telegram.org/bots#6-botfather) - one token per bot) * `master` : id (without quotes) of bot owner, who will gett announces. * `alert_catch` : dict of rules pokemons catch. -* `min_interval`: min interval check messages from telegram. ### Sample configuration [[back to top](#table-of-contents)] @@ -1001,7 +1000,6 @@ Bot answer on command '/info' self stats. "config": { "enabled": true, "master": 12345678, - "min_interval": 120, "alert_catch": { "all": {"operator": "and", "cp": 1300, "iv": 0.95}, "Snorlax": {"operator": "or", "cp": 900, "iv": 0.9} diff --git a/map-chat/javascript/main.js b/map-chat/javascript/main.js index d09e798edc..c1f5a009b2 100644 --- a/map-chat/javascript/main.js +++ b/map-chat/javascript/main.js @@ -26,15 +26,34 @@ function initialiseEventBus(){ var pLoadR2 = pLoadR.split(","); var olat = pLoadR2[0] var olong = pLoadR2[1] - var sessid = pLoadR2[2] - var ico = pLoadR2[3] - var expir = pLoadR2[4] - var pokenick = pLoadR2[5] - var path = "./images/p/" - var icon = path + "0" + ico + ".png" - var icostr = icon.toString(); - displayMessageOnMap(payload, olat, olong, sessid, icostr, expir, pokenick); - console.debug('[CATCHABLE]', pokenick, '(' + olat + ',' + olong + ')'); + + var pokemon_id = parseInt(pLoadR2[2]) + if (pokemon_id>0 && pokemon_id< 160){ + var ico = pLoadR2[2] + var expir = pLoadR2[3] + var pokenick = pLoadR2[4] + var sessid = pLoadR2[2] + var path = "./images/p/" + console.log('icon is '+ico) + var icon = path + "0" + ico.replace(" ","") + ".png" + var icostr = icon.toString(); + displayMessageOnMap(payload, olat, olong, sessid, icostr, expir, pokenick); + console.debug('[CATCHABLE]', pokenick, '(' + olat + ',' + olong + ')'); + } else { + var pokemon_id = parseInt(pLoadR2[3]) + if (pokemon_id>0 && pokemon_id< 160){ + var ico = pLoadR2[3] + var expir = pLoadR2[4] + var pokenick = pLoadR2[5] + var sessid = pLoadR2[5] + var path = "./images/p/" + console.log('icon is '+ico) + var icon = path + "0" + ico.replace(" ","") + ".png" + var icostr = icon.toString(); + displayMessageOnMap(payload, olat, olong, sessid, icostr, expir, pokenick); + console.debug('[CATCHABLE]', pokenick, '(' + olat + ',' + olong + ')'); + } + } } else { console.debug(topic); } diff --git a/pokemongo_bot/__init__.py b/pokemongo_bot/__init__.py index fb288cfc37..38e440ba59 100644 --- a/pokemongo_bot/__init__.py +++ b/pokemongo_bot/__init__.py @@ -1251,7 +1251,7 @@ def heartbeat(self): 'level': badgelevel} ) human_behaviour.action_delay(3, 10) - + inventory.refresh_inventory() try: @@ -1322,7 +1322,7 @@ def _load_recent_forts(self): with open(cached_forts_path) as f: cached_recent_forts = json.load(f) except (IOError, ValueError) as e: - self.bot.logger.info('[x] Error while opening cached forts: %s' % e, 'red') + self.logger.info('[x] Error while opening cached forts: %s' % e, 'red') pass except: raise FileIOException("Unexpected error opening {}".cached_forts_path) diff --git a/pokemongo_bot/cell_workers/evolve_pokemon.py b/pokemongo_bot/cell_workers/evolve_pokemon.py index 48ea4316ed..7822f4379e 100644 --- a/pokemongo_bot/cell_workers/evolve_pokemon.py +++ b/pokemongo_bot/cell_workers/evolve_pokemon.py @@ -49,7 +49,7 @@ def work(self): filtered_list = filter(lambda x: x.name in self.evolve_list, filtered_list) if (len(self.donot_evolve_list) > 0) and self.donot_evolve_list[0] != 'none': - filtered_list = filter(lambda pokemon: pokemon.name not in donot_evolve_list, filtered_list) + filtered_list = filter(lambda pokemon: pokemon.name not in self.donot_evolve_list, filtered_list) cache = {} for pokemon in filtered_list: diff --git a/pokemongo_bot/cell_workers/telegram_task.py b/pokemongo_bot/cell_workers/telegram_task.py old mode 100644 new mode 100755 index 85f973b8e7..441039769b --- a/pokemongo_bot/cell_workers/telegram_task.py +++ b/pokemongo_bot/cell_workers/telegram_task.py @@ -14,108 +14,12 @@ class FileIOException(Exception): class TelegramTask(BaseTask): SUPPORTED_TASK_API_VERSION = 1 - update_id = None - tbot = None - min_interval = None - next_job = None def initialize(self): if not self.enabled: return - api_key = self.bot.config.telegram_token - if api_key is None: - self.emit_event( - 'config_error', - formatted='api_key not defined.' - ) - return - self.tbot = telegram.Bot(api_key) - self.master = self.config.get('master', None) - if self.master: - self.bot.event_manager.add_handler(TelegramHandler(self.tbot, self.master, self.config.get('alert_catch'))) - try: - self.update_id = self.tbot.getUpdates()[0].update_id - except IndexError: - self.update_id = None - self.min_interval = self.config.get('min_interval', 120) - self.next_job = datetime.now() + timedelta(seconds=self.min_interval) + self.bot.event_manager.add_handler(TelegramHandler(self.bot, self.config)) + def work(self): if not self.enabled: return - if datetime.now() < self.next_job: - return - self.next_job = datetime.now() + timedelta(seconds=self.min_interval) - for update in self.tbot.getUpdates(offset=self.update_id, timeout=10): - self.update_id = update.update_id+1 - if update.message: - self.bot.logger.info("message from {} ({}): {}".format(update.message.from_user.username, update.message.from_user.id, update.message.text)) - if self.config.get('master', None) and self.config.get('master', None) not in [update.message.from_user.id, "@{}".format(update.message.from_user.username)]: - self.emit_event( - 'debug', - formatted="Master wrong: expecting {}, got {}({})".format(self.master, update.message.from_user.username, update.message.from_user.id)) - continue - else: - if not re.match(r'^[0-9]+$', "{}".format(self.config['master'])): # master was not numeric... - self.config['master'] = update.message.chat_id - idx = (i for i,v in enumerate(self.bot.event_manager._handlers) if type(v) is TelegramHandler).next() - self.bot.event_manager._handlers[idx] = TelegramHandler(self.tbot, self.master, self.config.get('alert_catch')) - if update.message.text == "/info": - stats = self._get_player_stats() - if stats: - with self.bot.database as conn: - cur = conn.cursor() - cur.execute("SELECT DISTINCT COUNT(encounter_id) FROM catch_log WHERE dated >= datetime('now','-1 day')") - catch_day = cur.fetchone()[0] - cur.execute("SELECT DISTINCT COUNT(pokestop) FROM pokestop_log WHERE dated >= datetime('now','-1 day')") - ps_day = cur.fetchone()[0] - res = ( - "*"+self.bot.config.username+"*", - "_Level:_ "+str(stats["level"]), - "_XP:_ "+str(stats["experience"])+"/"+str(stats["next_level_xp"]), - "_Pokemons Captured:_ "+str(stats["pokemons_captured"])+" ("+str(catch_day)+" _last 24h_)", - "_Poke Stop Visits:_ "+str(stats["poke_stop_visits"])+" ("+str(ps_day)+" _last 24h_)", - "_KM Walked:_ "+str(stats["km_walked"]) - ) - self.send_message(chat_id=update.message.chat_id, parse_mode='Markdown', text="\n".join(res)) - self.send_location(chat_id=update.message.chat_id, latitude=self.bot.api._position_lat, longitude=self.bot.api._position_lng) - else: - self.send_message(chat_id=update.message.chat_id, parse_mode='Markdown', text="Stats not loaded yet\n") - elif update.message.text == "/start" or update.message.text == "/help": - res = ( - "Commands: ", - "/info - info about bot" - ) - self.send_message(chat_id=update.message.chat_id, parse_mode='Markdown', text="\n".join(res)) - def send_message(self, chat_id, parse_mode, text): - try: - self.tbot.sendMessage(chat_id, parse_mode, text) - except telegram.error.NetworkError: - pass - def send_location(self, chat_id, latitude, longitude): - try: - self.tbot.send_location(chat_id, latitude, longitude) - except telegram.error.NetworkError: - pass - def _get_player_stats(self): - """ - Helper method parsing the bot inventory object and returning the player stats object. - :return: The player stats object. - :rtype: dict - """ - web_inventory = os.path.join(_base_dir, "web", "inventory-%s.json" % self.bot.config.username) - - try: - with open(web_inventory, "r") as infile: - json_inventory = json.load(infile) - except ValueError as exception: - # Unable to read json from web inventory - # File may be corrupt. Create a new one. - self.bot.logger.info('[x] Error while opening inventory file for read: %s' % exception) - json_inventory = [] - except: - raise FileIOException("Unexpected error reading from {}".format(web_inventory)) - - return next((x["inventory_item_data"]["player_stats"] - for x in json_inventory - if x.get("inventory_item_data", {}).get("player_stats", {})), - None) diff --git a/pokemongo_bot/event_handlers/telegram_handler.py b/pokemongo_bot/event_handlers/telegram_handler.py old mode 100644 new mode 100755 index 4052e8c4ea..bee593c899 --- a/pokemongo_bot/event_handlers/telegram_handler.py +++ b/pokemongo_bot/event_handlers/telegram_handler.py @@ -1,18 +1,111 @@ # -*- coding: utf-8 -*- from pokemongo_bot.event_manager import EventHandler +from pokemongo_bot.base_dir import _base_dir +import json +import os +import time +import telegram import thread import re DEBUG_ON = False +class FileIOException(Exception): + pass + +class TelegramClass: + + update_id = None + + def __init__(self, bot, master, pokemons): + self.bot = bot + self.master = master + self.pokemons = pokemons + self._tbot = None + + def sendMessage(self, chat_id=None, parse_mode='Markdown', text=None): + self._tbot.sendMessage(chat_id=chat_id, parse_mode=parse_mode, text=text) + + def connect(self): + self._tbot = telegram.Bot(self.bot.config.telegram_token) + try: + self.update_id = self._tbot.getUpdates()[0].update_id + except IndexError: + self.update_id = None + + def _get_player_stats(self): + web_inventory = os.path.join(_base_dir, "web", "inventory-%s.json" % self.bot.config.username) + try: + with open(web_inventory, "r") as infile: + json_inventory = json.load(infile) + except ValueError as exception: + self.bot.logger.info('[x] Error while opening inventory file for read: %s' % exception) + json_inventory = [] + except: + raise FileIOException("Unexpected error reading from {}".format(web_inventory)) + return next((x["inventory_item_data"]["player_stats"] + for x in json_inventory + if x.get("inventory_item_data", {}).get("player_stats", {})), + None) + + def run(self): + time.sleep(1) + while True: + try: + for update in self._tbot.getUpdates(offset=self.update_id, timeout=10): + self.update_id = update.update_id+1 + if update.message: + self.bot.logger.info("message from {} ({}): {}".format(update.message.from_user.username, update.message.from_user.id, update.message.text)) + if self.master and self.master not in [update.message.from_user.id, "@{}".format(update.message.from_user.username)]: + continue + if update.message.text == "/info": + stats = self._get_player_stats() + if stats: + with self.bot.database as conn: + cur = conn.cursor() + cur.execute("SELECT DISTINCT COUNT(encounter_id) FROM catch_log WHERE dated >= datetime('now','-1 day')") + catch_day = cur.fetchone()[0] + cur.execute("SELECT DISTINCT COUNT(pokestop) FROM pokestop_log WHERE dated >= datetime('now','-1 day')") + ps_day = cur.fetchone()[0] + res = ( + "*"+self.bot.config.username+"*", + "_Level:_ "+str(stats["level"]), + "_XP:_ "+str(stats["experience"])+"/"+str(stats["next_level_xp"]), + "_Pokemons Captured:_ "+str(stats["pokemons_captured"])+" ("+str(catch_day)+" _last 24h_)", + "_Poke Stop Visits:_ "+str(stats["poke_stop_visits"])+" ("+str(ps_day)+" _last 24h_)", + "_KM Walked:_ "+str(stats["km_walked"]) + ) + self._tbot.sendMessage(chat_id=update.message.chat_id, parse_mode='Markdown', text="\n".join(res)) + self._tbot.send_location(chat_id=update.message.chat_id, latitude=self.bot.api._position_lat, longitude=self.bot.api._position_lng) + else: + self._tbot.sendMessage(chat_id=update.message.chat_id, parse_mode='Markdown', text="Stats not loaded yet\n") + elif update.message.text == "/start" or update.message.text == "/help": + res = ( + "Commands: ", + "/info - info about bot" + ) + self._tbot.sendMessage(chat_id=update.message.chat_id, parse_mode='Markdown', text="\n".join(res)) + except telegram.error.NetworkError: + time.sleep(1) + except telegram.error.Unauthorized: + self.update_id += 1 + class TelegramHandler(EventHandler): - def __init__(self, tbot,master,pokemons): - self.tbot = tbot - self.master=master - self.pokemons=pokemons - self.whoami="TelegramHandler" + def __init__(self, bot, config): + self.bot = bot + self.tbot = None + self.master = config.get('master', None) + self.pokemons = config.get('alert_catch', {}) + self.whoami = "TelegramHandler" def handle_event(self, event, sender, level, formatted_msg, data): + if self.tbot is None: + try: + self.tbot = TelegramClass(self.bot, self.master, self.pokemons) + self.tbot.connect() + thread.start_new_thread(self.tbot.run) + except Exception as inst: + self.tbot = None if self.master: if not re.match(r'^[0-9]+$', str(self.master)): return @@ -23,7 +116,7 @@ def handle_event(self, event, sender, level, formatted_msg, data): elif event == 'pokemon_caught': if isinstance(self.pokemons, list): if data["pokemon"] in self.pokemons or "all" in self.pokemons: - msg = "Caught {} CP: {}, IV: {}".format(data["pokemon"],data["cp"],data["iv"]) + msg = "Caught {} CP: {}, IV: {}".format(data["pokemon"], data["cp"], data["iv"]) else: return else: @@ -34,7 +127,7 @@ def handle_event(self, event, sender, level, formatted_msg, data): else: return if (not "operator" in trigger or trigger["operator"] == "and") and data["cp"] >= trigger["cp"] and data["iv"] >= trigger["iv"] or ("operator" in trigger and trigger["operator"] == "or" and (data["cp"] >= trigger["cp"] or data["iv"] >= trigger["iv"])): - msg = "Caught {} CP: {}, IV: {}".format(data["pokemon"],data["cp"],data["iv"]) + msg = "Caught {} CP: {}, IV: {}".format(data["pokemon"], data["cp"], data["iv"]) else: return else: diff --git a/pokemongo_bot/inventory.py b/pokemongo_bot/inventory.py index b09d1c5330..b73531b101 100644 --- a/pokemongo_bot/inventory.py +++ b/pokemongo_bot/inventory.py @@ -126,7 +126,7 @@ def exp(self, value): def refresh(self,inventory): self.player_stats = self.retrieve_data(inventory) - + def parse(self, item): if not item: item = {} @@ -1222,9 +1222,9 @@ def update_web_inventory(self): def jsonify_inventory(self): json_inventory = [] - + json_inventory.append({"inventory_item_data": {"player_stats": self.player.player_stats}}) - + for pokedex in self.pokedex.all(): json_inventory.append({"inventory_item_data": {"pokedex_entry": pokedex}}) @@ -1335,11 +1335,18 @@ def refresh_inventory(data=None): :return: Nothing. :rtype: None """ - _inventory.refresh(data) + try: + _inventory.refresh(data) + except AttributeError: + print '_inventory was not initialized' def jsonify_inventory(): - return _inventory.jsonify_inventory() - + try: + return _inventory.jsonify_inventory() + except AttributeError: + print '_inventory was not initialized' + return [] + def update_web_inventory(): _inventory.update_web_inventory() diff --git a/windows_bat/PokemonGo-Bot-Install.bat b/windows_bat/PokemonGo-Bot-Install.bat index b744fc4586..2d8097a7e9 100755 --- a/windows_bat/PokemonGo-Bot-Install.bat +++ b/windows_bat/PokemonGo-Bot-Install.bat @@ -62,10 +62,9 @@ ECHO.>>%log% :CheckInstallPath cls -@ECHO.--------------------Installation Path-------------------- -@ECHO. -@ECHO. -@ECHO. +call:ech +ECHO.--------------------Installation Path-------------------- +call:ech SET InstallPath= SET /p InstallPath= "Choose an installation folder (example: C:/Test/) or press Enter to close: " ||goto:eof ECHO.----- Input Path ----->>%log% @@ -101,37 +100,30 @@ COPY "%PGBotPath%\windows_bat\PokemonGo-Bot-Install.bat" %InstallPath% CALL "%InstallPath%PokemonGo-Bot-Install.bat" exit. ) ELSE ( -@ECHO.Installation Path OK^^! Proceeding^^! +ECHO.Installation Path OK^^! Proceeding^^! ) ECHO.----- Checking Some Paths ----->>%log% ECHO.>>%log% ECHO.BatchPath is "%~dp0">>%log% ECHO.PokemonGo-Bot Path is "%PGBotPath%">>%log% ECHO.>>%log% -@ECHO. -@ECHO. -@ECHO. - :Menu cls -@ECHO.--------------------PokemonGo-Bot Installer-------------------- -@ECHO. -@ECHO. -@ECHO. +call:ech +ECHO.--------------------PokemonGo-Bot Installer-------------------- +call:ech if "%OS%" == "32-BIT" ( -@ECHO. 1 - Install 32-Bit software +ECHO. 1 - Install 32-Bit software ) ELSE ( -@ECHO. 1 - Install 64-Bit software +ECHO. 1 - Install 64-Bit software ) -@ECHO. -@ECHO. 2 - Install PokemonGo-Bot Master Version (Stable) -@ECHO. -@ECHO. 3 - Install PokemonGo-Bot Development Version (Unstable) -@ECHO. -@ECHO. -@ECHO. +ECHO. +ECHO. 2 - Install PokemonGo-Bot Master Version (Stable) +ECHO. +ECHO. 3 - Install PokemonGo-Bot Development Version (Unstable) +call:ech @@ -152,32 +144,27 @@ ECHO.>>%log% ECHO.Choice was "%_ok%" installing "%OS%" software>>%log% ECHO.>>%log% cls -@ECHO.--------------------Installation of required software-------------------- -@ECHO. -IF NOT EXIST %DownPath%\%GitFName86% @ECHO.Downloading Git... +call:ech +ECHO.--------------------Installation of required software-------------------- +call:ech +IF NOT EXIST %DownPath%\%GitFName86% ECHO.Downloading Git... IF NOT EXIST %DownPath%\%GitFName86% call:getit %DownPathGit% %GitFName86% -IF NOT EXIST %DownPath%\%PythonFName86% @ECHO.Downloading Python... +IF NOT EXIST %DownPath%\%PythonFName86% ECHO.Downloading Python... IF NOT EXIST %DownPath%\%PythonFName86% call:getit %DownPathPython% %PythonFName86% -IF NOT EXIST %DownPath%\%VisualFName% @ECHO.Downloading Visual C++ for Python... +IF NOT EXIST %DownPath%\%VisualFName% ECHO.Downloading Visual C++ for Python... IF NOT EXIST %DownPath%\%VisualFName% call:getit %DownPathVisual% %VisualFName% -@ECHO.Installing Python... +ECHO.Installing Python... IF EXIST %DownPath%\%PythonFName86% call:installit %PythonFName86% /quiet -@ECHO.Installing Git... +ECHO.Installing Git... IF EXIST %DownPath%\%GitFName86% call:installit %GitFName86% /SILENT -@ECHO.Installing Visual C++ for Python... +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 +call:ech +ECHO.Installation of 32-Bit software is finished. +ECHO. +ECHO.Choose Install PokemonGo-Bot in next screen to complete installation. +call:ech +timeout /t 5 goto:Menu @@ -188,32 +175,28 @@ ECHO.>>%log% ECHO.Choice was "%_ok%" installing "%OS%" software>>%log% ECHO.>>%log% cls -@ECHO.--------------------Installation of required software-------------------- -@ECHO. -IF NOT EXIST %DownPath%\%GitFName64% @ECHO.Downloading Git... +call:ech +ECHO.--------------------Installation of required software-------------------- +call:ech +IF NOT EXIST %DownPath%\%GitFName64% ECHO.Downloading Git... IF NOT EXIST %DownPath%\%GitFName64% call:getit %DownPathGit% %GitFName64% -IF NOT EXIST %DownPath%\%PythonFName64% @ECHO.Downloading Python... +IF NOT EXIST %DownPath%\%PythonFName64% ECHO.Downloading Python... IF NOT EXIST %DownPath%\%PythonFName64% call:getit %DownPathPython% %PythonFName64% -IF NOT EXIST %DownPath%\%VisualFName% @ECHO.Downloading Visual C++ for Python... +IF NOT EXIST %DownPath%\%VisualFName% ECHO.Downloading Visual C++ for Python... IF NOT EXIST %DownPath%\%VisualFName% call:getit %DownPathVisual% %VisualFName% -@ECHO.Installing Python... +ECHO.Installing Python... IF EXIST %DownPath%\%PythonFName64% call:installit %PythonFName64% /quiet -@ECHO.Installing Git... +ECHO.Installing Git... IF EXIST %DownPath%\%GitFName64% call:installit %GitFName64% /SILENT -@ECHO.Installing Visual C++ for Python... +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 +call:ech +ECHO.Installation of 64-Bit software is finished. +ECHO. +ECHO.Choose Install PokemonGo-Bot in next screen to complete installation. +call:ech +ECHO. +timeout /t 5 goto:Menu @@ -243,10 +226,9 @@ ECHO.>>%log% ECHO.Choice was "%_ok%" installing Bot>>%log% ECHO.>>%log% cls -@ECHO.--------------------Creating Backup-------------------- -@ECHO. -@ECHO. -@ECHO. +call:ech +ECHO.--------------------Creating Backup-------------------- +call:ech ECHO.----- Checking Creating Backup ----->>%log% ECHO.>>%log% IF EXIST %PGBotPath%\encrypt.so ( @@ -267,6 +249,12 @@ COPY %PGBotPath%\encrypt_64.dll %DownPath%>>%log% ) else ( ECHO.No "%PGBotPath%\encrypt_64.dll">>%log% ) +IF EXIST %PGBotPath%\configs\auth.json ( +ECHO.Copying "%PGBotPath%\configs\auth.json" to %DownPath%>>%log% +COPY %PGBotPath%\configs\auth.json %DownPath%>>%log% +) else ( +ECHO.No "%PGBotPath%\configs\auth.json">>%log% +) IF EXIST %PGBotPath%\configs\config.json ( ECHO.Copying "%PGBotPath%\configs\config.json" to %DownPath%>>%log% COPY %PGBotPath%\configs\config.json %DownPath%>>%log% @@ -280,14 +268,12 @@ COPY %PGBotPath%\web\config\userdata.js %DownPath%>>%log% ECHO.No "%PGBotPath%\web\config\userdata.js">>%log% ) ECHO.>>%log% + cls -@ECHO. -@ECHO. -@ECHO. -@ECHO.--------------------Downloading PokemonGo-Bot-------------------- -@ECHO. -@ECHO. -@ECHO. +ECHO. +call:ech +ECHO.--------------------Downloading PokemonGo-Bot-------------------- +call:ech ECHO. Be patience... We are working hard to download and install the PokemonGo-Bot. ECHO.----- Checking Removing Bot Folder ----->>%log% ECHO.>>%log% @@ -319,13 +305,9 @@ ECHO.----- Checking second pip2 install or upgrade ----->>%log% ECHO.>>%log% pip2 install -r %PGBotPath%\requirements.txt>>%log% ECHO.>>%log% -@ECHO. -@ECHO. -@ECHO. -@ECHO.--------------------Restoring Backup-------------------- -@ECHO. -@ECHO. -@ECHO. +call:ech +ECHO.--------------------Restoring Backup-------------------- +call:ech ECHO.----- Checking Restoring Backup ----->>%log% ECHO.>>%log% IF EXIST %~dp0encrypt.so ( @@ -346,6 +328,12 @@ COPY %~dp0encrypt_64.dll %PGBotPath%>>%log% ) else ( ECHO.No "%~dp0encrypt_64.dll">>%log% ) +IF EXIST %~dp0auth.json ( +ECHO.Copying %~dp0auth.json to %PGBotPath%\configs\>>%log% +COPY %~dp0auth.json %PGBotPath%\configs\>>%log% +) else ( +ECHO.No "%~dp0auth.json">>%log% +) IF EXIST %~dp0config.json ( ECHO.Copying %~dp0config.json to %PGBotPath%\configs\>>%log% COPY %~dp0config.json %PGBotPath%\configs\>>%log% @@ -376,6 +364,12 @@ COPY %DownPath%\encrypt_64.dll %PGBotPath%>>%log% ) else ( ECHO.No "%DownPath%\encrypt_64.dll">>%log% ) +IF EXIST %DownPath%\auth.json ( +ECHO.Copying %DownPath%\auth.json to %PGBotPath%\configs\>>%log% +COPY %DownPath%\auth.json %PGBotPath%\configs\>>%log% +) else ( +ECHO.No "%DownPath%\auth.json">>%log% +) IF EXIST %DownPath%\config.json ( ECHO.Copying %DownPath%\config.json to %PGBotPath%\configs\>>%log% COPY %DownPath%\config.json %PGBotPath%\configs\>>%log% @@ -388,50 +382,57 @@ COPY %DownPath%\userdata.js %PGBotPath%\web\config\>>%log% ) else ( ECHO.No "%DownPath%\userdata.js">>%log% ) -@ECHO. -@ECHO. -@ECHO. ECHO.>>%Log% ECHO. ----- End Log ----->>%log% :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.--------------------File customization-------------------- +call:ech +ECHO.Before starting the bot, please copy the following files to %PGBotPath% if you dont have them yet. +call:ech IF NOT EXIST %PGBotPath%\encrypt*.* ( -@ECHO.---- encrypt.so / encrypt.dll or encrypt_64.dll -@ECHO. Get them from our Slack chat^^! -@ECHO. "https://pokemongo-bot.herokuapp.com/" +ECHO.---- encrypt.so / encrypt.dll or encrypt_64.dll +ECHO. Get them from our Slack chat^^! +ECHO. "https://pokemongo-bot.herokuapp.com/" ) else ( 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 Maps API Key: -@ECHO."https://developers.google.com/maps/documentation/javascript/get-api-key" -@ECHO. -@ECHO. -@ECHO. +call:ech +ECHO.Remember to configure auth.json, config.json and userdata.js^^! +call:ech +ECHO."%PGBotPath%\configs\auth.json" +ECHO."%PGBotPath%\configs\config.json" +ECHO.INSTRUCTIONS: +ECHO."https://github.com/PokemonGoF/PokemonGo-Bot/blob/master/docs/configuration_files.md" +call:ech +ECHO."%PGBotPath%\web\config\userdata.js" +ECHO.INSTRUCTIONS: +ECHO."https://github.com/PokemonGoF/PokemonGo-Bot/blob/master/docs/google_map.md" +call:ech +ECHO.To get an Google Maps API Key: +ECHO."https://developers.google.com/maps/documentation/javascript/get-api-key" +call:ech @PAUSE +CLS +call:ech +ECHO.You can configure the auth.json and userdata.js files when you choose y in the next question. +ECHO. +ECHO.If you first want to get your Google MAPS API key and encrypt dll/so choose n, +ECHO. +ECHO.put encrypt dll/so in %PGBotPath% and then, +ECHO. +ECHO.start PokemonGo-Bot-Configurator.bat in %PGBotPath%\windows_bat\ +call:ech +SET /p json="Do you want to start the PokemonGo-Bot-Configurator (Y/N): " +IF "%json%" == "y" call %PGBotPath%\windows_bat\PokemonGo-Bot-Configurator.bat +IF "%json%" == "n" goto:eof +:ech +ECHO. +ECHO. +goto:eof :eof ENDLOCAL