From 201840e1db13c94982d0a1748aa2fffef99e9a12 Mon Sep 17 00:00:00 2001 From: Alexus Date: Sat, 29 Jul 2017 00:05:31 +0300 Subject: [PATCH 01/22] fix last_km_awarded error for new account --- pokemongo_bot/cell_workers/buddy_pokemon.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pokemongo_bot/cell_workers/buddy_pokemon.py b/pokemongo_bot/cell_workers/buddy_pokemon.py index 6d8d108cdd..704c050564 100644 --- a/pokemongo_bot/cell_workers/buddy_pokemon.py +++ b/pokemongo_bot/cell_workers/buddy_pokemon.py @@ -132,6 +132,9 @@ def work(self): if not self.buddy: return WorkerResult.SUCCESS ++ if not self.buddy.has_key('last_km_awarded'): ++ self.buddy['last_km_awarded'] = 0 + if self._km_walked() - self.buddy['last_km_awarded'] >= self.buddy_distance_needed: self.buddy['last_km_awarded'] += self.buddy_distance_needed if not self._get_award(): From 76d9afedabf16e2f1e34338cd9a2c84332f0cfc0 Mon Sep 17 00:00:00 2001 From: Jason Hawks Date: Fri, 28 Jul 2017 18:51:06 -0400 Subject: [PATCH 02/22] Update web files to newest commits --- web | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web b/web index acbf10115e..8c5a43a57e 160000 --- a/web +++ b/web @@ -1 +1 @@ -Subproject commit acbf10115e401edd6f276005bd362795da6b60bf +Subproject commit 8c5a43a57e3e703853cade50f1cda1f06ce31fc7 From d5eaa6ea5ebf9075a982c456100b80d6d3d21b58 Mon Sep 17 00:00:00 2001 From: Jason Hawks Date: Fri, 28 Jul 2017 18:59:41 -0400 Subject: [PATCH 03/22] modified posix setup for new map config --- setup.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/setup.sh b/setup.sh index 869d1b45e8..830dd08b6c 100755 --- a/setup.sh +++ b/setup.sh @@ -75,9 +75,12 @@ Configure userdata.js for web " read -p "Input E-Mail (Google) or Username (PTC) " webusername +read -p "Input Friendly Name For Your Bot (Name you want bot to show up as on the map) +" webfriendlyname read -p "Input Google API Key (gmapkey) " webgmapkey sed -e "s/username1/$webusername/g" -e "s/YOUR_API_KEY_HERE/$webgmapkey/g" \ + -e "s/FriendlyName1/$webfriendlyname/g" \ config/userdata.js.example > config/userdata.js echo "Your userdata.js is now configured." else From 58f9f79260da53ca8f228e012b2da0be40a8bfa5 Mon Sep 17 00:00:00 2001 From: Jason Hawks Date: Fri, 28 Jul 2017 19:10:07 -0400 Subject: [PATCH 04/22] modified windows setup for new map config --- windows_bat/PokemonGo-Bot-Configurator.bat | 2 ++ 1 file changed, 2 insertions(+) diff --git a/windows_bat/PokemonGo-Bot-Configurator.bat b/windows_bat/PokemonGo-Bot-Configurator.bat index 66192e493d..50eacd1f9d 100644 --- a/windows_bat/PokemonGo-Bot-Configurator.bat +++ b/windows_bat/PokemonGo-Bot-Configurator.bat @@ -205,6 +205,8 @@ ECHO. users: [{>>%UserData% ECHO. enable: true,>>%UserData% Set /p users="What's the username to use ?: " ECHO. username: "%users%",>>%UserData% +Set /p friendlyname="What's the friendly/display name to use ?: " +ECHO. alias: "%friendlyname%",>>%UserData% ECHO. socketAddress: "127.0.0.1:4000",>>%UserData% ECHO. enableSocket: true>>%UserData% ECHO. }],>>%UserData% From a82e896ed7d7d53c715569135a8022d475e7a621 Mon Sep 17 00:00:00 2001 From: Jason Hawks Date: Sat, 29 Jul 2017 07:39:51 -0400 Subject: [PATCH 05/22] fixed pgo version --- runMultiBot.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runMultiBot.sh b/runMultiBot.sh index 2f8bc98fed..6f10903c50 100644 --- a/runMultiBot.sh +++ b/runMultiBot.sh @@ -10,7 +10,7 @@ then fi git fetch -a installed=(`pip list 2>/dev/null |sed -e 's/ //g' -e 's/(/:/' -e 's/)//' -e 's/[-_]//g' | awk '{print tolower($0)}'`) -required=(`cat requirements.txt | sed -e 's/.*pgoapi$/pgoapi==1.2.0/' -e 's/[-_]//g' -e 's/==\(.*\)/:\1/' | awk '{print tolower($0)}'`) +required=(`cat requirements.txt | sed -e 's/.*pgoapi$/pgoapi==1.2.1/' -e 's/[-_]//g' -e 's/==\(.*\)/:\1/' | awk '{print tolower($0)}'`) for package in ${required[@]} do if [[ ! (${installed[*]} =~ $package) ]]; From dd667096619ef4d31a7921d482f698eb3b9ad4a7 Mon Sep 17 00:00:00 2001 From: Alexus Date: Sat, 29 Jul 2017 14:50:31 +0300 Subject: [PATCH 06/22] fix last_km_awarded error for new account - 2nd try --- pokemongo_bot/cell_workers/buddy_pokemon.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pokemongo_bot/cell_workers/buddy_pokemon.py b/pokemongo_bot/cell_workers/buddy_pokemon.py index 704c050564..3cd1d2b394 100644 --- a/pokemongo_bot/cell_workers/buddy_pokemon.py +++ b/pokemongo_bot/cell_workers/buddy_pokemon.py @@ -132,8 +132,8 @@ def work(self): if not self.buddy: return WorkerResult.SUCCESS -+ if not self.buddy.has_key('last_km_awarded'): -+ self.buddy['last_km_awarded'] = 0 + if not self.buddy.has_key('last_km_awarded'): + self.buddy['last_km_awarded'] = 0 if self._km_walked() - self.buddy['last_km_awarded'] >= self.buddy_distance_needed: self.buddy['last_km_awarded'] += self.buddy_distance_needed From c2ecade5d4c0ff12e06b49286ad512caa1fed5c7 Mon Sep 17 00:00:00 2001 From: Jason Hawks Date: Sat, 29 Jul 2017 08:26:17 -0400 Subject: [PATCH 07/22] multibot shell test fix --- runMultiBot.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/runMultiBot.sh b/runMultiBot.sh index 6f10903c50..de6d01bd5a 100644 --- a/runMultiBot.sh +++ b/runMultiBot.sh @@ -30,6 +30,11 @@ then ./setup.sh -u fi fi -python MultiBot.py +while true +do + python MultiBot.py + echo `date`" Pokebot "$*" Stopped." + read -p "Press any button or wait 20 seconds to continue. + " -r -s -n1 -t 20 done exit 0 From 908ff9043e65bbadf7aadaa6519cfb05ad2d3985 Mon Sep 17 00:00:00 2001 From: Jason Hawks Date: Sun, 30 Jul 2017 05:34:57 -0400 Subject: [PATCH 08/22] add .git to clone commands --- docs/manual_installation.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/docs/manual_installation.md b/docs/manual_installation.md index c210fa1611..09b165a3c8 100644 --- a/docs/manual_installation.md +++ b/docs/manual_installation.md @@ -55,7 +55,7 @@ rm -f get-pip.py (Please keep in mind that `master` is stable and tested but `dev` is bleeding edge. In the installation note below change `master` to `dev` if you want to get and use the latest version.) ```bash -git clone --recursive -b master https://github.com/PokemonGoF/PokemonGo-Bot +git clone --recursive -b master https://github.com/PokemonGoF/PokemonGo-Bot.git cd PokemonGo-Bot ``` @@ -131,8 +131,7 @@ source bin/activate cd C:\Python27\ pip install --upgrade pip cd .. -cd to PokemonGo-Bot directory -git clone --recursive -b dev https://github.com/PokemonGoF/PokemonGo-Bot +git clone --recursive -b dev https://github.com/PokemonGoF/PokemonGo-Bot.git pip install --upgrade -r requirements.txt git pull cd web From bbabf04c3dff8ee60f33f527c7ea270cae903a23 Mon Sep 17 00:00:00 2001 From: Xairooo Date: Sun, 30 Jul 2017 11:45:14 +0200 Subject: [PATCH 09/22] Update MultiBot.py fixing proxy and websocket handling --- MultiBot.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/MultiBot.py b/MultiBot.py index 53549045a6..34a9e0df4d 100644 --- a/MultiBot.py +++ b/MultiBot.py @@ -47,7 +47,7 @@ def getProxy(): headers = {'user-agent': 'Niantic App'} if requests.get('https://pgorelease.nianticlabs.com/plfe/', headers=headers, proxies=proxies).status_code == 200: headers = {'user-agent': 'pokemongo/1 CFNetwork/758.5.3 Darwin/15.6.0'} - if requests.get('https://sso.pokemon.com/', headers=headers, proxies=proxies).status_code == 200: + if requests.get('https://sso.pokemon.com/', headers=headers, proxies=proxies).status_code != 404: return proxy else: Lprint ("Proxy is Banned") @@ -147,8 +147,11 @@ def MakeConf(CurThread, username, password): stop() except: jsonData.items().append("{u'websocket':,{u'server_url': u'" + MultiBotConfig[u'WebSocket'][u'IP'] + ":" + str(MultiBotConfig[u'WebSocket'][u'Port'] + CurThread) + "u'start_embedded_server': True}") - - + else: + try: + del jsonData[u'websocket'] + except KeyboardInterrupt: + stop() with open('configs/temp/config-' + str(CurThread) + '.json', 'w') as s: s.write(json.dumps(jsonData)) @@ -184,9 +187,11 @@ def run(self): if MultiBotConfig[u'UseProxy']: self.proxy = getProxy() if platform.system() == "Linux": - self.os.system('export HTTP_PROXY="http://' + proxy + '"; export HTTPS_PROXY="https://' + proxy + '"') + os.system('export HTTP_PROXY="http://' + proxy + '"; export HTTPS_PROXY="https://' + proxy + '"') if platform.system() == "Windows": - self.os.system('') + Lprint ("Proxy on Windows not Supported yet, exit in 15s") + time.sleep (15) + stop() os.system( "python pokecli.py -af configs/temp/auth-{0}.json -cf configs/temp/config-{0}.json --walker_limit_output {1}".format( self.CurThread, MultiBotConfig[u'walker_limit_output'])) From b09388700400bdadd0b4bc7796cc7aea568b7e75 Mon Sep 17 00:00:00 2001 From: Jason Hawks Date: Sun, 30 Jul 2017 05:53:01 -0400 Subject: [PATCH 10/22] fixed booboo --- docs/manual_installation.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/manual_installation.md b/docs/manual_installation.md index 09b165a3c8..9f9e618379 100644 --- a/docs/manual_installation.md +++ b/docs/manual_installation.md @@ -131,6 +131,7 @@ source bin/activate cd C:\Python27\ pip install --upgrade pip cd .. +cd to PokemonGo-Bot directory git clone --recursive -b dev https://github.com/PokemonGoF/PokemonGo-Bot.git pip install --upgrade -r requirements.txt git pull From d5d2d1f3858a868759f40dc5029e81d37e8f0f7c Mon Sep 17 00:00:00 2001 From: Xairooo Date: Sun, 30 Jul 2017 17:03:04 +0200 Subject: [PATCH 11/22] Fixing proxies --- MultiBot.py | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/MultiBot.py b/MultiBot.py index 34a9e0df4d..26c1c66efd 100644 --- a/MultiBot.py +++ b/MultiBot.py @@ -47,7 +47,7 @@ def getProxy(): headers = {'user-agent': 'Niantic App'} if requests.get('https://pgorelease.nianticlabs.com/plfe/', headers=headers, proxies=proxies).status_code == 200: headers = {'user-agent': 'pokemongo/1 CFNetwork/758.5.3 Darwin/15.6.0'} - if requests.get('https://sso.pokemon.com/', headers=headers, proxies=proxies).status_code != 404: + if requests.get('https://sso.pokemon.com/', headers=headers, proxies=proxies).status_code == 200: return proxy else: Lprint ("Proxy is Banned") @@ -147,16 +147,18 @@ def MakeConf(CurThread, username, password): stop() except: jsonData.items().append("{u'websocket':,{u'server_url': u'" + MultiBotConfig[u'WebSocket'][u'IP'] + ":" + str(MultiBotConfig[u'WebSocket'][u'Port'] + CurThread) + "u'start_embedded_server': True}") - else: + elif not MultiBotConfig[u'WebSocket'][u'start_embedded_server']: try: del jsonData[u'websocket'] except KeyboardInterrupt: stop() + except: + pass with open('configs/temp/config-' + str(CurThread) + '.json', 'w') as s: s.write(json.dumps(jsonData)) s.close() - + except IOError: Lprint ('config file error') time.sleep(30) @@ -184,17 +186,14 @@ def run(self): Lprint ('Thread-{0} using account {1}'.format(self.CurThread, self.username)) try: MakeConf(self.CurThread, self.username, self.password) + StartCmd = "python pokecli.py -af configs/temp/auth-{0}.json -cf configs/temp/config-{0}.json --walker_limit_output {1}".format(self.CurThread, MultiBotConfig[u'walker_limit_output']) if MultiBotConfig[u'UseProxy']: self.proxy = getProxy() if platform.system() == "Linux": - os.system('export HTTP_PROXY="http://' + proxy + '"; export HTTPS_PROXY="https://' + proxy + '"') + os.system('export HTTP_PROXY="http://' + proxy + '"; export HTTPS_PROXY="https://' + proxy + '"; ' + StartCmd) if platform.system() == "Windows": - Lprint ("Proxy on Windows not Supported yet, exit in 15s") - time.sleep (15) - stop() - os.system( - "python pokecli.py -af configs/temp/auth-{0}.json -cf configs/temp/config-{0}.json --walker_limit_output {1}".format( - self.CurThread, MultiBotConfig[u'walker_limit_output'])) + os.system('set HTTP_PROXY="http://' + proxy + '" & set HTTPS_PROXY="https://' + proxy + '" & ' + StartCmd) + os.system(StartCmd) except Exception as e: import traceback Lprint ((e)) From c7dc416e84fd4c5286276742d4b536260fbc74e3 Mon Sep 17 00:00:00 2001 From: VoIP Date: Sun, 30 Jul 2017 16:43:11 -0500 Subject: [PATCH 12/22] Line 46 spelling error. Update from "Legendart" to "Legendary". --- data/items.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/items.json b/data/items.json index 5e565021cf..5c788e5cc2 100644 --- a/data/items.json +++ b/data/items.json @@ -43,5 +43,5 @@ "1301": "Rare Candy", "1401": "Free Raid Ticket", "1402": "Paid Raid Ticket", - "1403": "Legendart Raid Ticket" + "1403": "Legendary Raid Ticket" } From 78e8bfc7846b3963807ed7d4cf5953d25e95727a Mon Sep 17 00:00:00 2001 From: Jason Hawks Date: Sun, 30 Jul 2017 17:49:23 -0400 Subject: [PATCH 13/22] revert multibot shell looping --- runMultiBot.sh | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/runMultiBot.sh b/runMultiBot.sh index de6d01bd5a..cc38a33cc5 100644 --- a/runMultiBot.sh +++ b/runMultiBot.sh @@ -30,11 +30,5 @@ then ./setup.sh -u fi fi -while true -do - python MultiBot.py - echo `date`" Pokebot "$*" Stopped." - read -p "Press any button or wait 20 seconds to continue. - " -r -s -n1 -t 20 -done +python MultiBot.py exit 0 From fd039ebf32145ba211c465f11b2f1c58073c4268 Mon Sep 17 00:00:00 2001 From: Xairooo Date: Mon, 31 Jul 2017 04:16:47 +0200 Subject: [PATCH 14/22] new settings, comments added --- configs/MultiBotConfig.json.example | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/configs/MultiBotConfig.json.example b/configs/MultiBotConfig.json.example index 140818cc72..c395a75593 100644 --- a/configs/MultiBotConfig.json.example +++ b/configs/MultiBotConfig.json.example @@ -1,4 +1,5 @@ { + "Threads": "set it to (account number / 2)", "Threads": 2, "HashKeyFile": "MultiBotConfigHashkey.txt", "UseProxy": false, @@ -6,11 +7,15 @@ "AccountsFile": "MultiBotConfigAccounts.txt", "AuthJsonFile": "auth.json", "ConfigJsonFile": "config.json", + "CompleteTutorialNickName": "set to true to use login as username", "CompleteTutorialNickName": true, + "TelegramTask": "should be false or Telegram maybe crash the bot", + "TelegramTask": false, "WebSocket": { "start_embedded_server": false, "IP": "127.0.0.1", "Port": 4000 }, + "walker_limit_output": "set to true to reduce spam in console", "walker_limit_output": true } From e9f22d762b8ddf03549cfe8d9c06063759abf941 Mon Sep 17 00:00:00 2001 From: Xairooo Date: Mon, 31 Jul 2017 04:27:34 +0200 Subject: [PATCH 15/22] Telegram Settings --- MultiBot.py | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/MultiBot.py b/MultiBot.py index 26c1c66efd..7e6cf49dec 100644 --- a/MultiBot.py +++ b/MultiBot.py @@ -45,14 +45,14 @@ def getProxy(): if proxyCur >= proxyNum: proxyCur = 0 headers = {'user-agent': 'Niantic App'} - if requests.get('https://pgorelease.nianticlabs.com/plfe/', headers=headers, proxies=proxies).status_code == 200: + if requests.get('https://pgorelease.nianticlabs.com/plfe/', headers=headers, proxies=proxies, timeout=15).status_code == 200: headers = {'user-agent': 'pokemongo/1 CFNetwork/758.5.3 Darwin/15.6.0'} - if requests.get('https://sso.pokemon.com/', headers=headers, proxies=proxies).status_code == 200: + if requests.get('https://sso.pokemon.com/', headers=headers, proxies=proxies, timeout=15).status_code == 200: return proxy else: - Lprint ("Proxy is Banned") + Lprint ("Proxy {} is Banned or offline".format(proxy)) else: - Lprint ("Proxy is Banned") + Lprint ("Proxy {} is Banned or offline".format(proxy)) except Exception as e: Lprint (e) @@ -154,7 +154,26 @@ def MakeConf(CurThread, username, password): stop() except: pass - + if MultiBotConfig[u'TelegramTask']: + try: + for i in range(len(jsonData[u'tasks'])): + if jsonData[u'tasks'][1][u'type'] == u'TelegramTask': + jsonData[u'tasks'][i][u'config'][u'enabled'] = True + except KeyboardInterrupt: + stop() + except: + pass + + if not MultiBotConfig[u'TelegramTask']: + try: + for i in range(len(jsonData[u'tasks'])): + if jsonData[u'tasks'][1][u'type'] == u'TelegramTask': + jsonData[u'tasks'][i][u'config'][u'enabled'] = False + except KeyboardInterrupt: + stop() + except: + pass + with open('configs/temp/config-' + str(CurThread) + '.json', 'w') as s: s.write(json.dumps(jsonData)) s.close() From 58d91d0695064317e76748bb386334f5c1d050fa Mon Sep 17 00:00:00 2001 From: Jason Hawks Date: Mon, 31 Jul 2017 02:19:45 -0400 Subject: [PATCH 16/22] clarify some steps in manual install --- docs/manual_installation.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/docs/manual_installation.md b/docs/manual_installation.md index 9f9e618379..d5461be1cc 100644 --- a/docs/manual_installation.md +++ b/docs/manual_installation.md @@ -73,8 +73,6 @@ source bin/activate - install the requirements ```bash pip install -r requirements.txt -make -cd ../../ ``` #### @@ -82,6 +80,7 @@ cd ../../ - copy and edit the config (after copying it you can use any editor you like if you don't like `vi`) ```bash +cd ../PokemonGo-Bot/configs/ cp configs/config.json.example configs/config.json vi configs/config.json cp configs/auth.json.example configs/auth.json From cf78ba3e0464372d46720fd735db0283d21d6910 Mon Sep 17 00:00:00 2001 From: Jason Hawks Date: Mon, 31 Jul 2017 08:31:41 +0200 Subject: [PATCH 17/22] changed runMultiBot.sh to be executable --- runMultiBot.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 runMultiBot.sh diff --git a/runMultiBot.sh b/runMultiBot.sh old mode 100644 new mode 100755 From 261a8fb507f7735d5e588f321aa0f0e4528d7110 Mon Sep 17 00:00:00 2001 From: MerlionRock Date: Mon, 31 Jul 2017 21:36:28 +0800 Subject: [PATCH 18/22] Updated Telegram Features Updated with Lucky egg Support Updated with new time calculation for sniper Update with new command to get time to snipe before snipping --- .../event_handlers/telegram_handler.py | 107 ++++++++++++++++++ 1 file changed, 107 insertions(+) diff --git a/pokemongo_bot/event_handlers/telegram_handler.py b/pokemongo_bot/event_handlers/telegram_handler.py index 8f661db066..56a334d01b 100644 --- a/pokemongo_bot/event_handlers/telegram_handler.py +++ b/pokemongo_bot/event_handlers/telegram_handler.py @@ -7,8 +7,13 @@ from telegram.utils import request from chat_handler import ChatHandler from pokemongo_bot.inventory import Pokemons +from pokemongo_bot import inventory +from pokemongo_bot.item_list import Item +from pokemongo_bot.cell_workers.utils import wait_time_sec, distance, convert DEBUG_ON = False +SUCCESS = 1 +ERROR_XP_BOOST_ALREADY_ACTIVE = 3 class TelegramSnipe(object): ENABLED = False @@ -16,6 +21,7 @@ class TelegramSnipe(object): POKEMON_NAME = '' LATITUDE = float(0) LONGITUDE = float(0) + SNIPE_DISABLED = False class TelegramClass: update_id = None @@ -213,6 +219,24 @@ def request_snipe(self, update, pkm, lat, lng): outMsg = 'Catching pokemon: ' + TelegramSnipe.POKEMON_NAME + ' at Latitude: ' + str(TelegramSnipe.LATITUDE) + ' Longitude: ' + str(TelegramSnipe.LONGITUDE) + '\n' self.sendMessage(chat_id=update.message.chat_id, parse_mode='Markdown', text="".join(outMsg)) + def request_snipe_time(self, update, lat, lng): + last_position = self.bot.position[0:2] + snipe_distance = convert(distance(last_position[0],last_position[1],float(lat),float(lng)),"m","km") + time_to_snipe = wait_time_sec(snipe_distance)/60 + if time_to_snipe <= 900: + outMsg = "Estimate Time to Snipe: " + "{0:.2f}".format(time_to_snipe) + " Mins. Distance: " + "{0:.2f}".format(snipe_distance) + "KM" + self.sendMessage(chat_id=update.message.chat_id, parse_mode='Markdown', text="".join(outMsg)) + else: + self.sendMessage(chat_id=update.message.chat_id, parse_mode='Markdown', text="Sniping distance is more than supported distance") + + def request_snipe_disable(self, update, config): + if config.lower() == "true": + TelegramSnipe.SNIPE_DISABLED = True + return True + else: + TelegramSnipe.SNIPE_DISABLED = False + return False + def send_evolved(self, update, num, order): evolved = self.chat_handler.get_evolved(num, order) outMsg = '' @@ -225,6 +249,45 @@ def send_evolved(self, update, num, order): else: self.sendMessage(chat_id=update.message.chat_id, parse_mode='Markdown', text="No Evolutions Found.\n") + + def request_luckyegg_count(self,update): + lucky_egg = inventory.items().get(Item.ITEM_LUCKY_EGG.value) # @UndefinedVariable + self.sendMessage(chat_id=update.message.chat_id, parse_mode='Markdown', + text="Lucky Egg Count: " + str(lucky_egg.count)) + + + def request_luckyegg(self,update): + lucky_egg = inventory.items().get(Item.ITEM_LUCKY_EGG.value) # @UndefinedVariable + + if lucky_egg.count == 0: + return False + + response_dict = self.bot.use_lucky_egg() + + if not response_dict: + self.bot.logger.info("Telegram Request: Failed to use lucky egg!") + self.sendMessage(chat_id=update.message.chat_id, parse_mode='Markdown', + text="Failed to use lucky egg!\n") + return False + + result = response_dict.get("responses", {}).get("USE_ITEM_XP_BOOST", {}).get("result", 0) + + if result == SUCCESS: + lucky_egg.remove(1) + self.bot.logger.info("Telegram Request: Used lucky egg, {} left.".format(lucky_egg.count)) + self.sendMessage(chat_id=update.message.chat_id, parse_mode='Markdown', + text="Used lucky egg, " + str(lucky_egg.count) + " left.") + return True + elif result == ERROR_XP_BOOST_ALREADY_ACTIVE: + self.bot.logger.info("Telegram Request: Lucky egg already active, {} left.".format(lucky_egg.count)) + self.sendMessage(chat_id=update.message.chat_id, parse_mode='Markdown', + text="Lucky egg already active, " + str(lucky_egg.count) + " left.") + return True + else: + self.bot.logger.info("Telegram Request: Failed to use lucky egg!") + self.sendMessage(chat_id=update.message.chat_id, parse_mode='Markdown', + text="Failed to use lucky egg!\n") + return False def send_pokestops(self, update, num): pokestops = self.chat_handler.get_pokestops( num) @@ -329,6 +392,9 @@ def send_start(self, update): "/released - show top x released, sorted by CP, IV, or Date", "/vanished - show top x vanished, sorted by CP, IV, or Date", "/snipe - to snipe a pokemon at location Latitude, Longitude", + "/snipetime - return time that will be teaken to snipe at given location", + "/luckyegg - activate luckyegg", + "/luckyeggcount - return number of luckyegg", "/softbans - info about possible softbans" ) self.sendMessage(chat_id=update.message.chat_id, parse_mode='Markdown', @@ -466,6 +532,47 @@ def run(self): self.sendMessage(chat_id=update.message.chat_id, parse_mode='Markdown', text="An Error has occured") continue + if re.match(r'^/snipetime ', update.message.text): + try: + (cmd, lat, lng) = self.tokenize(update.message.text, 3) + self.request_snipe_time(update, lat, lng) + except: + self.sendMessage(chat_id=update.message.chat_id, parse_mode='Markdown', + text="An Error has occured") + continue + + if re.match(r'^/luckyeggcount', update.message.text): + try: + self.request_luckyegg_count(update) + except: + self.sendMessage(chat_id=update.message.chat_id, parse_mode='Markdown', + text="An Error has occured") + continue + if re.match(r'^/luckyegg', update.message.text): + try: + if self.request_luckyegg(update): + self.bot.logger.info("Telegram has called for lucky egg. Success.") + else: + self.bot.logger.info("Telegram has called for lucky egg. Failed.") + except: + self.sendMessage(chat_id=update.message.chat_id, parse_mode='Markdown', + text="An Error has occured") + continue + if re.match(r'^/snipedisabled ', update.message.text): + try: + (cmd, config) = self.tokenize(update.message.text, 2) + success = self.request_snipe_disable(update, config) + if success: + msg = "Sniper disabled" + else: + msg = "Sniper set as default" + + self.sendMessage(chat_id=update.message.chat_id, parse_mode='Markdown', + text=msg) + except: + self.sendMessage(chat_id=update.message.chat_id, parse_mode='Markdown', + text="An Error has occured") + continue if re.match(r'^/softbans ', update.message.text): (cmd, num) = self.tokenize(update.message.text, 2) self.send_softbans(update, num) From c9d43fa6ea0f13c796cbf858343f5473d021b812 Mon Sep 17 00:00:00 2001 From: MerlionRock Date: Mon, 31 Jul 2017 21:37:56 +0800 Subject: [PATCH 19/22] Updated Sniper Updated with Lucky egg Support (For telegram) Updated with new time calculation for sniper (Now up to 30KM at 15Mins) Update with new command to get time to snipe before snipping --- pokemongo_bot/cell_workers/sniper.py | 18 ++++++------------ pokemongo_bot/cell_workers/utils.py | 19 +++++++++++++++++++ 2 files changed, 25 insertions(+), 12 deletions(-) diff --git a/pokemongo_bot/cell_workers/sniper.py b/pokemongo_bot/cell_workers/sniper.py index 9ad7d168f5..c841aae8e6 100644 --- a/pokemongo_bot/cell_workers/sniper.py +++ b/pokemongo_bot/cell_workers/sniper.py @@ -7,9 +7,6 @@ import calendar import difflib import hashlib - -from geopy.distance import great_circle - from random import uniform from operator import itemgetter, methodcaller from itertools import izip @@ -20,6 +17,7 @@ from pokemongo_bot.worker_result import WorkerResult from pokemongo_bot.event_handlers.telegram_handler import TelegramSnipe from pokemongo_bot.cell_workers.pokemon_catch_worker import PokemonCatchWorker +from pokemongo_bot.cell_workers.utils import wait_time_sec, distance, convert # Represents a URL source and its mappings class SniperSource(object): @@ -361,15 +359,17 @@ def snipe(self, pokemon): # Backup position before anything last_position = self.bot.position[0:2] teleport_position = [pokemon['latitude'], pokemon['longitude']] - teleport_distance = self._get_distance(last_position, teleport_position) - sleep_time = self._get_sleep_sec(teleport_distance) + #teleport_distance = self._get_distance(last_position, teleport_position) + teleport_distance = convert(distance(last_position[0],last_position[1],float(pokemon['latitude']),float(pokemon['longitude'])),"m","km") + #sleep_time = self._get_sleep_sec(teleport_distance) + sleep_time = wait_time_sec(teleport_distance) if sleep_time > 900: success = False exists = False self._log('Sniping distance is more than supported distance, abort sniping') else: - self._log('Base on distance, pausing for {} sec'.format(sleep_time)) + self._log('Base on distance, pausing for {0:.2f} Mins'.format(sleep_time/60)) # Teleport, so that we can see nearby stuff self.bot.hb_locked = True @@ -695,9 +695,3 @@ def _teleport_back_and_catch(self, position_array, pokemon): api_encounter_response = catch_worker.create_encounter_api_call() self._teleport_back(position_array) catch_worker.work(api_encounter_response) - - def _get_distance(self, location_from, location_to): - return great_circle(location_from, location_to).kilometers - - def _get_sleep_sec(self, distance): - return distance * 60 diff --git a/pokemongo_bot/cell_workers/utils.py b/pokemongo_bot/cell_workers/utils.py index 25a8f6a9ce..b3c626b633 100644 --- a/pokemongo_bot/cell_workers/utils.py +++ b/pokemongo_bot/cell_workers/utils.py @@ -67,6 +67,25 @@ def encode(cellid): encoder._VarintEncoder()(output.append, cellid) return ''.join(output) +def wait_time_sec(distance): + if distance <= 1: + return distance*60 + elif distance <= 3: + return (distance/3)*(60*2) + elif distance <= 7: + return (distance/7)*(60*5) + elif distance <= 10: + return (distance/10)*(60*7) + elif distance <= 12: + return (distance/12)*(60*8) + elif distance <= 18: + return (distance/18)*(60*10) + elif distance <= 30: + return (distance/30)*(60*15) + else: + return distance*60 + + def distance(lat1, lon1, lat2, lon2): p = 0.017453292519943295 From 11780e50af16fa86d379912c79cc597eea5beaf4 Mon Sep 17 00:00:00 2001 From: TheCannings Date: Tue, 1 Aug 2017 10:27:20 +0100 Subject: [PATCH 20/22] Update telegram_handler.py Added use incense and get incense count telegram functionality --- .../event_handlers/telegram_handler.py | 80 ++++++++++++++++++- 1 file changed, 79 insertions(+), 1 deletion(-) diff --git a/pokemongo_bot/event_handlers/telegram_handler.py b/pokemongo_bot/event_handlers/telegram_handler.py index 56a334d01b..63959e0f44 100644 --- a/pokemongo_bot/event_handlers/telegram_handler.py +++ b/pokemongo_bot/event_handlers/telegram_handler.py @@ -11,9 +11,10 @@ from pokemongo_bot.item_list import Item from pokemongo_bot.cell_workers.utils import wait_time_sec, distance, convert -DEBUG_ON = False +DEBUG_ON = True SUCCESS = 1 ERROR_XP_BOOST_ALREADY_ACTIVE = 3 +ERROR_INCENSE_ALREADY_ACTIVE = 2 class TelegramSnipe(object): ENABLED = False @@ -255,6 +256,10 @@ def request_luckyegg_count(self,update): self.sendMessage(chat_id=update.message.chat_id, parse_mode='Markdown', text="Lucky Egg Count: " + str(lucky_egg.count)) + def request_ordincense_count(self,update): + ord_incense = inventory.items().get(Item.ITEM_INCENSE_ORDINARY.value) # @UndefinedVariable + self.sendMessage(chat_id=update.message.chat_id, parse_mode='Markdown', + text="Ordinary Incense Count: " + str(ord_incense.count)) def request_luckyegg(self,update): lucky_egg = inventory.items().get(Item.ITEM_LUCKY_EGG.value) # @UndefinedVariable @@ -289,6 +294,50 @@ def request_luckyegg(self,update): text="Failed to use lucky egg!\n") return False + def request_ordincense(self,update): + ord_incense = inventory.items().get(Item.ITEM_INCENSE_ORDINARY.value) # @UndefinedVariable + + if ord_incense.count == 0: + return False + + request = self.bot.api.create_request() + request.use_incense(incense_type=401) + response_dict = request.call() + + if not response_dict: + self.bot.logger.info("Telegram Request: Failed to use ordinary incense!") + self.sendMessage(chat_id=update.message.chat_id, parse_mode='Markdown', + text="Failed to use ordinary incense!\n") + return False + + result = response_dict.get('responses', {}).get('USE_INCENSE', {}).get('result', 0) + + self.bot.logger.info("Result = " + str(result)) + + if result == SUCCESS: + ord_incense.remove(1) + self.bot.logger.info("Telegram Request: Used ordinary incense, {} left.".format(ord_incense.count)) + self.sendMessage(chat_id=update.message.chat_id, parse_mode='Markdown', + text="Used ordinary incense, " + str(ord_incense.count) + " left.") + return True + elif result == ERROR_INCENSE_ALREADY_ACTIVE: + self.bot.logger.info("Telegram Request: Ordinary incense already active, {} left.".format(ord_incense.count)) + self.sendMessage(chat_id=update.message.chat_id, parse_mode='Markdown', + text="Ordinary incense already active, " + str(ord_incense.count) + " left and has " + str(currentincense.expire_ms) + " remaining") + return True + else: + self.bot.logger.info("Telegram Request: Failed to use ordinary incense! Result=" + str(result)) + self.sendMessage(chat_id=update.message.chat_id, parse_mode='Markdown', + text="Failed to use ordinary incense!\n") + return False + + def request_incensetime(self, update): + self.bot.logger.info("Time Started") + currentincense = inventory.applied_items().get('401') + self.bot.logger.info(currentincense) + #self.bot.logger.info(currentincense.expire_ms) + return True + def send_pokestops(self, update, num): pokestops = self.chat_handler.get_pokestops( num) outMsg = '' @@ -395,6 +444,8 @@ def send_start(self, update): "/snipetime - return time that will be teaken to snipe at given location", "/luckyegg - activate luckyegg", "/luckyeggcount - return number of luckyegg", + "/ordincense - activate ordinary incense", + "/ordincensecount - return number of ordinary incense", "/softbans - info about possible softbans" ) self.sendMessage(chat_id=update.message.chat_id, parse_mode='Markdown', @@ -558,6 +609,33 @@ def run(self): self.sendMessage(chat_id=update.message.chat_id, parse_mode='Markdown', text="An Error has occured") continue + if re.match(r'^/ordincensecount', update.message.text): + try: + self.request_ordincense_count(update) + except: + self.sendMessage(chat_id=update.message.chat_id, parse_mode='Markdown', + text="An Error has occured") + continue + if re.match(r'^/ordincense', update.message.text): + try: + if self.request_ordincense(update): + self.bot.logger.info("Telegram has called for ordinary incense. Success.") + else: + self.bot.logger.info("Telegram has called for ordinary incense. Failed.") + except: + self.sendMessage(chat_id=update.message.chat_id, parse_mode='Markdown', + text="An Error has occured") + continue + if re.match(r'^/itime', update.message.text): + try: + if self.request_incensetime(update): + self.bot.logger.info("Telegram has called for incense time. Success.") + else: + self.bot.logger.info("Telegram has called for incense time. Failed.") + except: + self.sendMessage(chat_id=update.message.chat_id, parse_mode='Markdown', + text="An Error has occured") + continue if re.match(r'^/snipedisabled ', update.message.text): try: (cmd, config) = self.tokenize(update.message.text, 2) From e256b2eab4ed0b6da17cec87b570c3e159f760cf Mon Sep 17 00:00:00 2001 From: TheCannings Date: Tue, 1 Aug 2017 10:29:41 +0100 Subject: [PATCH 21/22] Update telegram_handler.py --- pokemongo_bot/event_handlers/telegram_handler.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pokemongo_bot/event_handlers/telegram_handler.py b/pokemongo_bot/event_handlers/telegram_handler.py index 63959e0f44..54abb3cb29 100644 --- a/pokemongo_bot/event_handlers/telegram_handler.py +++ b/pokemongo_bot/event_handlers/telegram_handler.py @@ -11,7 +11,7 @@ from pokemongo_bot.item_list import Item from pokemongo_bot.cell_workers.utils import wait_time_sec, distance, convert -DEBUG_ON = True +DEBUG_ON = False SUCCESS = 1 ERROR_XP_BOOST_ALREADY_ACTIVE = 3 ERROR_INCENSE_ALREADY_ACTIVE = 2 From f2df6faeb98576640c2776b32b601a4cb57de13f Mon Sep 17 00:00:00 2001 From: goedzo Date: Tue, 1 Aug 2017 12:02:01 +0200 Subject: [PATCH 22/22] API updated to 0.69.1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Note: Version number is updated to 2.13.0 to be in synch with protos version number. We are following [semantic versioning](http://semver.org/) for POGOProtos. Every version will be mapped to their current PokémonGo version. | Version | Android | iOS | Extra | |--------------|---------------|---------------|---------------------------| | 2.13.0 | 0.69.1 | 1.39.1 | | | 2.12.0 | 0.69.0 | 1.39.0 | | | 2.11.0 | 0.67.2 | 1.37.2 | | | 2.11.0-beta | 0.67.1 | 1.37.1 | | | 2.10.x | 0.63.1 | 1.33.1 | | | 2.9.2 | 0.61.0 | 1.31.0 | Updated protobuf to 3.3.0 | | 2.9.1 | 0.61.0 | 1.31.0 | Updated protobuf to 3.2.0 | | 2.9.0 | 0.61.0 | 1.31.0 | | | 2.8.0 | 0.59.1 | 1.29.1 | | | 2.7.0 | 0.57.2 | 1.27.2 | | | 2.6.x | 0.55.0 | 1.25.0 | | | 2.5.x | 0.53.1 | 1.23.1 | | | 2.4.x | 0.51.0 | 1.21.0 | | | 2.3.0 | 0.49.1 | 1.19.1 | | | 2.2.0 | 0.47.1 | 1.17.0 | | | 2.1.0 | 0.45.0 | 1.15.0 | | | 2.1.0-beta | 0.45.0 | 1.15.0 | | | 2.0.x | 0.43.4 | 1.13.4 | | --- pokecli.py | 2 +- run.sh | 2 +- runMultiBot.sh | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pokecli.py b/pokecli.py index 5efd00ab23..4d8eef1737 100644 --- a/pokecli.py +++ b/pokecli.py @@ -66,7 +66,7 @@ try: import pkg_resources pgoapi_version = pkg_resources.get_distribution("pgoapi").version - if pgoapi_version != '1.2.1': + if pgoapi_version != '2.13.0': print "Run following command to get latest update: `pip install -r requirements.txt --upgrade`" sys.exit(1) except pkg_resources.DistributionNotFound: diff --git a/run.sh b/run.sh index 8eefcb9700..3907d5a9b2 100755 --- a/run.sh +++ b/run.sh @@ -22,7 +22,7 @@ then fi git fetch -a installed=(`pip list 2>/dev/null |sed -e 's/ //g' -e 's/(/:/' -e 's/)//' -e 's/[-_]//g' | awk '{print tolower($0)}'`) -required=(`cat requirements.txt | sed -e 's/.*pgoapi$/pgoapi==1.2.1/' -e 's/[-_]//g' -e 's/==\(.*\)/:\1/' | awk '{print tolower($0)}'`) +required=(`cat requirements.txt | sed -e 's/.*pgoapi$/pgoapi==2.13.0/' -e 's/[-_]//g' -e 's/==\(.*\)/:\1/' | awk '{print tolower($0)}'`) for package in ${required[@]} do if [[ ! (${installed[*]} =~ $package) ]]; diff --git a/runMultiBot.sh b/runMultiBot.sh index cc38a33cc5..847c5a7f89 100755 --- a/runMultiBot.sh +++ b/runMultiBot.sh @@ -10,7 +10,7 @@ then fi git fetch -a installed=(`pip list 2>/dev/null |sed -e 's/ //g' -e 's/(/:/' -e 's/)//' -e 's/[-_]//g' | awk '{print tolower($0)}'`) -required=(`cat requirements.txt | sed -e 's/.*pgoapi$/pgoapi==1.2.1/' -e 's/[-_]//g' -e 's/==\(.*\)/:\1/' | awk '{print tolower($0)}'`) +required=(`cat requirements.txt | sed -e 's/.*pgoapi$/pgoapi==2.13.0/' -e 's/[-_]//g' -e 's/==\(.*\)/:\1/' | awk '{print tolower($0)}'`) for package in ${required[@]} do if [[ ! (${installed[*]} =~ $package) ]];