diff --git a/README.md b/README.md index 45a4ecf7ab..8d0ce8d959 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # PokemonGo-Bot [PokemonGo-Bot](https://github.com/PokemonGoF/PokemonGo-Bot) is a project created by the [PokemonGoF](https://github.com/PokemonGoF) team. -## Is the bot working? [New API basic support](https://github.com/PokemonGoF/PokemonGo-Bot/pull/5784) +## Is the bot working? [Yes, since this PR](https://github.com/PokemonGoF/PokemonGo-Bot/pull/5784) ## Table of Contents - [Installation](https://github.com/PokemonGoF/PokemonGo-Bot/blob/dev/docs/installation.md) @@ -75,7 +75,7 @@ If you do not want any data to be gathered, you can turn off this feature by set ## Credits - [tejado](https://github.com/tejado) many thanks for the API -- [U6 Group](http://pgoapi.com) for the U6 +- [pogodevorg](https://github.com/pogodevorg/pgoapi) Without keyphact's coordination, this would not gonna happan again. - [Mila432](https://github.com/Mila432/Pokemon_Go_API) for the login secrets - [elliottcarlson](https://github.com/elliottcarlson) for the Google Auth PR - [AeonLucid](https://github.com/AeonLucid/POGOProtos) for improved protos diff --git a/configs/config.json.cluster.example b/configs/config.json.cluster.example index d0fea74420..c7c40db333 100644 --- a/configs/config.json.cluster.example +++ b/configs/config.json.cluster.example @@ -46,6 +46,7 @@ "best_in_family": true, "// candy_limit = 0 means no limit, so it will never change current buddy": {}, "candy_limit": 0, + "candy_limit_absolute":0, "// force_first_change = true will always change buddy at start removing current one": {}, "force_first_change": false, "buddy_change_wait_min": 3, diff --git a/configs/config.json.example b/configs/config.json.example index f4f088ca83..4a0e271faa 100644 --- a/configs/config.json.example +++ b/configs/config.json.example @@ -83,6 +83,7 @@ "best_in_family": true, "// candy_limit = 0 means no limit, so it will never change current buddy": {}, "candy_limit": 0, + "candy_limit_absolute":0, "// force_first_change = true will always change buddy at start removing current one": {}, "force_first_change": false, "buddy_change_wait_min": 3, @@ -253,7 +254,7 @@ "name": { "param": "pokemon" }, "latitude": { "param": "cords" }, "longitude": { "param": "cords" }, - "expiration": { "param": "timeend", "format": "milliseconds" } + "expiration": { "param": "timeend", "format": "seconds" } } }, { diff --git a/configs/config.json.map.example b/configs/config.json.map.example index 44f6c83dd8..f9e0f5cba6 100644 --- a/configs/config.json.map.example +++ b/configs/config.json.map.example @@ -46,6 +46,7 @@ "best_in_family": true, "// candy_limit = 0 means no limit, so it will never change current buddy": {}, "candy_limit": 0, + "candy_limit_absolute":0, "// force_first_change = true will always change buddy at start removing current one": {}, "force_first_change": false, "buddy_change_wait_min": 3, @@ -506,7 +507,7 @@ "name": { "param": "pokemon" }, "latitude": { "param": "cords" }, "longitude": { "param": "cords" }, - "expiration": { "param": "timeend", "format": "milliseconds" } + "expiration": { "param": "timeend", "format": "seconds" } } }, { diff --git a/configs/config.json.path.example b/configs/config.json.path.example index eef1d26559..533bd570f1 100644 --- a/configs/config.json.path.example +++ b/configs/config.json.path.example @@ -46,6 +46,7 @@ "best_in_family": true, "// candy_limit = 0 means no limit, so it will never change current buddy": {}, "candy_limit": 0, + "candy_limit_absolute":0, "// force_first_change = true will always change buddy at start removing current one": {}, "force_first_change": false, "buddy_change_wait_min": 3, diff --git a/configs/config.json.pokemon.example b/configs/config.json.pokemon.example index 6fb5ba7f3c..fb0cb54574 100644 --- a/configs/config.json.pokemon.example +++ b/configs/config.json.pokemon.example @@ -46,6 +46,7 @@ "best_in_family": true, "// candy_limit = 0 means no limit, so it will never change current buddy": {}, "candy_limit": 0, + "candy_limit_absolute":0, "// force_first_change = true will always change buddy at start removing current one": {}, "force_first_change": false, "buddy_change_wait_min": 3, diff --git a/docs/configuration_files.md b/docs/configuration_files.md index f956af9579..27b14d4728 100644 --- a/docs/configuration_files.md +++ b/docs/configuration_files.md @@ -850,7 +850,7 @@ This task is an upgrade version of the MoveToMapPokemon task. It will fetch poke "name": { "param": "pokemon" }, "latitude": { "param": "cords" }, "longitude": { "param": "cords" }, - "expiration": { "param": "timeend", "format": "milliseconds" } + "expiration": { "param": "timeend", "format": "seconds" } } } ], @@ -1298,6 +1298,7 @@ After setting a buddy it's not possible to remove it, only change it. So if a bu * `buddy_list`: `Default: []`. List of pokemon names that will be used as buddy. If '[]' or 'none', will not use or change buddy. * `best_in_family`: `Default: True`. If True, picks best Pokemon in the family (sorted by cp). * `candy_limit`: `Default: 0`. Set the candy limit to be rewarded per buddy, when reaching this limit the bot will change the buddy to the next in the list. When candy_limit = 0 or only one buddy in list, it has no limit and never changes buddy. +* `candy_limit_absolute`: `Default: 0`. Set the absolute candy limit to be rewarded per buddy, when reaching this limit the bot will change the buddy to the next in the list. When candy_limit_absolute = 0 or only one buddy in list, it has no limit and never changes buddy. Use this to stop collecting candy when a candy threshold for your buddy's pokemon family is reached (e.g. 50 for evolving). * `force_first_change`: `Default: False`. If True, will try to change buddy at bot start according to the buddy list. If False, will use the buddy already set until candy_limit is reached and then use the buddy list. * `buddy_change_wait_min`: `Default: 3`. Minimum time (in seconds) that the buddy change takes. * `buddy_change_wait_max`: `Default: 5`. Maximum time (in seconds) that the buddy change takes. @@ -1314,6 +1315,7 @@ After setting a buddy it's not possible to remove it, only change it. So if a bu "best_in_family": true, "// candy_limit = 0 means no limit, so it will never change current buddy": {}, "candy_limit": 0, + "candy_limit_absolute": 0, "// force_first_change = true will always change buddy at start removing current one": {}, "force_first_change": false, "buddy_change_wait_min": 3, diff --git a/pokemongo_bot/__init__.py b/pokemongo_bot/__init__.py index 2a258b22aa..c0a27effe4 100644 --- a/pokemongo_bot/__init__.py +++ b/pokemongo_bot/__init__.py @@ -167,7 +167,7 @@ def _setup_event_system(self): if self.config.websocket_start_embedded_server: self.sio_runner = SocketIoRunner(self.config.websocket_server_url) self.sio_runner.start_listening_async() - + websocket_handler = SocketIoHandler( self, self.config.websocket_server_url @@ -476,6 +476,20 @@ def _register_events(self): 'caught_last_24_hour', ) ) + self.event_manager.register_event( + 'pokemon_vip_caught', + parameters=( + 'pokemon', + 'ncp', 'cp', 'iv', 'iv_display', 'exp', + 'stardust', + 'encounter_id', + 'latitude', + 'longitude', + 'pokemon_id', + 'daily_catch_limit', + 'caught_last_24_hour', + ) + ) self.event_manager.register_event( 'pokemon_evolved', parameters=('pokemon', 'iv', 'cp', 'candy', 'xp') @@ -910,7 +924,8 @@ def check_session(self, position): self.api = ApiWrapper(config=self.config) self.api.set_position(*position) self.login() - self.api.activate_signature(self.get_encryption_lib()) + self.api.set_signature_lib(self.get_encryption_lib()) + self.api.set_hash_lib(self.get_hash_lib()) def login(self): self.event_manager.emit( @@ -964,12 +979,39 @@ def get_encryption_lib(self): if _platform == "Windows" or _platform == "win32": # Check if we are on 32 or 64 bit if sys.maxsize > 2**32: - file_name = 'encrypt_64.dll' + file_name = 'src/pgoapi/pgoapi/lib/encrypt64.dll' else: - file_name = 'encrypt.dll' + file_name = 'src/pgoapi/pgoapi/lib/encrypt32.dll' + if _platform.lower() == "darwin": + file_name= 'src/pgoapi/pgoapi/lib/libencrypt-osx-64.so' + if _platform.lower() == "linux" or _platform.lower() == "linux2": + file_name = 'src/pgoapi/pgoapi/lib/libencrypt-linux-x86-64.so' + if self.config.encrypt_location == '': + path = os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir)) else: - file_name = 'encrypt.so' + path = self.config.encrypt_location + + full_path = path + '/'+ file_name + if not os.path.isfile(full_path): + self.logger.error(file_name + ' is not found! Please place it in the bots root directory or set encrypt_location in config.') + self.logger.info('Platform: '+ _platform + ' ' + file_name + ' directory: '+ path) + sys.exit(1) + else: + self.logger.info('Found '+ file_name +'! Platform: ' + _platform + ' ' + file_name + ' directory: ' + path) + return full_path + + def get_hash_lib(self): + if _platform == "Windows" or _platform == "win32": + # Check if we are on 32 or 64 bit + if sys.maxsize > 2**32: + file_name = 'src/pgoapi/pgoapi/lib/niantichash64.dll' + else: + file_name = 'src/pgoapi/pgoapi/lib/niantichash32.dll' + if _platform.lower() == "darwin": + file_name= 'src/pgoapi/pgoapi/lib/libniantichash-osx-64.so' + if _platform.lower() == "linux" or _platform.lower() == "linux2": + file_name = 'src/pgoapi/pgoapi/lib/libniantichash-linux-x86-64.so' if self.config.encrypt_location == '': path = os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir)) else: @@ -977,7 +1019,7 @@ def get_encryption_lib(self): full_path = path + '/'+ file_name if not os.path.isfile(full_path): - self.logger.error(file_name + ' is not found! Please place it in the bots root directory or set encrypt_location in config.') + self.logger.error(file_name + ' is not found! Please place it in the bots root directory') self.logger.info('Platform: '+ _platform + ' ' + file_name + ' directory: '+ path) sys.exit(1) else: @@ -995,7 +1037,9 @@ def _setup_api(self): self.login() # chain subrequests (methods) into one RPC call - self.api.activate_signature(self.get_encryption_lib()) + self.api.set_signature_lib(self.get_encryption_lib()) + self.api.set_hash_lib(self.get_hash_lib()) + self.logger.info('') # send empty map_cells and then our position self.update_web_location() diff --git a/pokemongo_bot/cell_workers/buddy_pokemon.py b/pokemongo_bot/cell_workers/buddy_pokemon.py index 1db8a0b5de..811a3b67dc 100644 --- a/pokemongo_bot/cell_workers/buddy_pokemon.py +++ b/pokemongo_bot/cell_workers/buddy_pokemon.py @@ -25,6 +25,7 @@ class BuddyPokemon(BaseTask): "best_in_family": true, "// candy_limit = 0 means no limit, so it will never change current buddy": {}, "candy_limit": 0, + "candy_limit_absolute": 0, "// force_first_change = true will always change buddy at start removing current one": {}, "force_first_change": false, "buddy_change_wait_min": 3, @@ -42,6 +43,16 @@ class BuddyPokemon(BaseTask): to the next in the list. When candy_limit = 0 or only one buddy in list, it has no limit and never changes buddy. + candy_limit_absolute: Default: 0. Set the absolute candy limit to be + rewarded per buddy, when reaching this + limit the bot will change the buddy to the + next in the list. When + candy_limit_absolute = 0 or only one buddy + in list, it has no limit and never changes + buddy. Use this to stop collecting candy + when a candy threshold for your buddy's + pokemon family is reached (e.g. 50 for + evolving). force_first_change: Default: False. If True, will try to change buddy at bot start according to the buddy list. If False, will use the buddy already set until candy_limit is reached @@ -61,6 +72,7 @@ def initialize(self): self.buddy_list = self.config.get('buddy_list', []) self.best_in_family = self.config.get('best_in_family', True) self.candy_limit = self.config.get('candy_limit', 0) # 0 = No Limit + self.candy_limit_absolute = self.config.get('candy_limit_absolute', 0) # 0 = No Limit self.force_first_change = self.config.get('force_first_change', False) self.buddy_change_wait_min = self.config.get('buddy_change_wait_min', 3) self.buddy_change_wait_max = self.config.get('buddy_change_wait_max', 5) @@ -93,10 +105,16 @@ def work(self): return WorkerResult.SUCCESS if self.buddy_list: - if self.force_first_change or not self.buddy or self.candy_limit != 0 and self.candy_awarded >= self.candy_limit: + pokemon = self._get_pokemon_by_name(self._get_pokemon_by_id(self.buddy['id']).name) + if self.force_first_change or not self.buddy or pokemon is None or (self.candy_limit != 0 and self.candy_awarded >= self.candy_limit) or self._check_candy_limit_absolute(pokemon): self.force_first_change = False - remaining = [name for name in self.buddy_list if name not in self.cache] + remaining = [] + for name in self.buddy_list: + pokemon = self._get_pokemon_by_name(name) + if name not in self.cache and pokemon is not None and not self._check_candy_limit_absolute(pokemon): + remaining.append(name) + if not remaining: self.cache = [] return WorkerResult.SUCCESS @@ -199,6 +217,9 @@ def _get_award(self): ) return False + def _check_candy_limit_absolute(self, pokemon): + return self.candy_limit_absolute != 0 and inventory.candies().get(pokemon.family_id).quantity >= self.candy_limit_absolute + def _check_old_reward(self): if not self.buddy: return @@ -215,7 +236,7 @@ def _get_pokemon_by_name(self, name): pokemons = inventory.pokemons().all() pokemon = None for p in pokemons: - if p.name.lower() == name: + if p.name.lower() == name.lower(): pokemon = p break diff --git a/pokemongo_bot/cell_workers/pokemon_catch_worker.py b/pokemongo_bot/cell_workers/pokemon_catch_worker.py index 75ecb579df..ae43e44da5 100644 --- a/pokemongo_bot/cell_workers/pokemon_catch_worker.py +++ b/pokemongo_bot/cell_workers/pokemon_catch_worker.py @@ -649,25 +649,47 @@ def _do_catch(self, pokemon, encounter_id, catch_rate_by_ball, is_vip=False): result = c.fetchone() - self.emit_event( - 'pokemon_caught', - formatted='Captured {pokemon}! (CP: {cp} IV: {iv} {iv_display} NCP: {ncp}) Catch Limit: ({caught_last_24_hour}/{daily_catch_limit}) +{exp} exp +{stardust} stardust', - data={ - 'pokemon': pokemon.name, - 'ncp': str(round(pokemon.cp_percent, 2)), - 'cp': str(int(pokemon.cp)), - 'iv': str(pokemon.iv), - 'iv_display': str(pokemon.iv_display), - 'exp': str(exp_gain), - 'stardust': stardust_gain, - 'encounter_id': str(self.pokemon['encounter_id']), - 'latitude': str(self.pokemon['latitude']), - 'longitude': str(self.pokemon['longitude']), - 'pokemon_id': str(pokemon.pokemon_id), - 'caught_last_24_hour': str(result[0]), - 'daily_catch_limit': str(self.daily_catch_limit) - } - ) + if is_vip: + self.emit_event( + 'pokemon_vip_caught', + formatted='Vip Captured {pokemon}! (CP: {cp} IV: {iv} {iv_display} NCP: {ncp}) Catch Limit: ({caught_last_24_hour}/{daily_catch_limit}) +{exp} exp +{stardust} stardust', + data={ + 'pokemon': pokemon.name, + 'ncp': str(round(pokemon.cp_percent, 2)), + 'cp': str(int(pokemon.cp)), + 'iv': str(pokemon.iv), + 'iv_display': str(pokemon.iv_display), + 'exp': str(exp_gain), + 'stardust': stardust_gain, + 'encounter_id': str(self.pokemon['encounter_id']), + 'latitude': str(self.pokemon['latitude']), + 'longitude': str(self.pokemon['longitude']), + 'pokemon_id': str(pokemon.pokemon_id), + 'caught_last_24_hour': str(result[0]), + 'daily_catch_limit': str(self.daily_catch_limit) + } + ) + + else: + self.emit_event( + 'pokemon_caught', + formatted='Captured {pokemon}! (CP: {cp} IV: {iv} {iv_display} NCP: {ncp}) Catch Limit: ({caught_last_24_hour}/{daily_catch_limit}) +{exp} exp +{stardust} stardust', + data={ + 'pokemon': pokemon.name, + 'ncp': str(round(pokemon.cp_percent, 2)), + 'cp': str(int(pokemon.cp)), + 'iv': str(pokemon.iv), + 'iv_display': str(pokemon.iv_display), + 'exp': str(exp_gain), + 'stardust': stardust_gain, + 'encounter_id': str(self.pokemon['encounter_id']), + 'latitude': str(self.pokemon['latitude']), + 'longitude': str(self.pokemon['longitude']), + 'pokemon_id': str(pokemon.pokemon_id), + 'caught_last_24_hour': str(result[0]), + 'daily_catch_limit': str(self.daily_catch_limit) + } + ) inventory.pokemons().add(pokemon) diff --git a/pokemongo_bot/cell_workers/sniper.py b/pokemongo_bot/cell_workers/sniper.py index 958bb25a49..a401c083b8 100644 --- a/pokemongo_bot/cell_workers/sniper.py +++ b/pokemongo_bot/cell_workers/sniper.py @@ -416,6 +416,16 @@ def work(self): if targets: # Order the targets (descending) targets = sorted(targets, key=itemgetter(*self.order), reverse=True) + #List Pokemons found + self._trace('Sniping the {} best Pokemons found, ordered by {}'.format(self.bullets, self.order)) + self._trace('+----+------+----------------+-------+----------+---------+---------+----------+') + self._trace('| # | Id | Name | IV | Verified | VIP | Missing | Priority |') + self._trace('+----+------+----------------+-------+----------+---------+---------+----------+') + row_format ="|{:>3} |{:>5} | {:<15}|{:>6} | {:<9}| {:<8}| {:<8}|{:>9} |" + for index, target in enumerate(targets): + self._trace(row_format.format(*[index+1, target.get('pokemon_id'), target.get('pokemon_name'), target.get('iv'), str(target.get('verified')), str(target.get('vip')), str(target.get('missing')), target.get('priority')])) + + self._trace('+----+------+----------------+-------+----------+---------+---------+----------+') shots = 0 # For as long as there are targets available, try to snipe untill we run out of bullets diff --git a/pokemongo_bot/event_handlers/logging_handler.py b/pokemongo_bot/event_handlers/logging_handler.py index f12544d0e6..1fea294e02 100644 --- a/pokemongo_bot/event_handlers/logging_handler.py +++ b/pokemongo_bot/event_handlers/logging_handler.py @@ -70,6 +70,7 @@ class LoggingHandler(EventHandler): 'pokemon_release': 'green', 'pokemon_upgraded': 'green', 'pokemon_vanished': 'red', + 'pokemon_vip_caught': 'blue', 'pokestop_empty': 'yellow', 'pokestop_log': 'magenta', 'pokestop_searching_too_often': 'yellow', diff --git a/requirements.txt b/requirements.txt index 6036f1fb16..f90247648a 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,6 @@ numpy==1.11.0 networkx==1.11 --e git+https://github.com/pogodevorg/pgoapi.git/@3a02e7416f6924b1bbcbcdde60c10bd247ba8e11#egg=pgoapi +-e git+https://github.com/pogodevorg/pgoapi.git/@1a112879f424b518f994b99f43859dd95cd43fdf#egg=pgoapi geopy==1.11.0 geographiclib==1.46.3 protobuf==3.0.0b4