diff --git a/pokecli.py b/pokecli.py index c01607f..5356fe4 100755 --- a/pokecli.py +++ b/pokecli.py @@ -39,7 +39,6 @@ ssl._create_default_https_context = ssl._create_unverified_context from pokemongo_bot import PokemonGoBot -from server import PokemonGoServer def init_config(): parser = argparse.ArgumentParser() @@ -97,14 +96,8 @@ def main(): bot = PokemonGoBot(config) bot.start() - pid = os.fork() - - if pid == 0: - server = PokemonGoServer(bot, 5000) - server.start() - else: - while(True): - bot.take_step() + while(True): + bot.take_step() if __name__ == '__main__': main() diff --git a/pokemongo_bot/__init__.py b/pokemongo_bot/__init__.py index 84be0a0..69e5e83 100644 --- a/pokemongo_bot/__init__.py +++ b/pokemongo_bot/__init__.py @@ -11,7 +11,6 @@ from stepper import Stepper from geopy.geocoders import GoogleV3 from math import radians, sqrt, sin, cos, atan2 -from collections import OrderedDict class PokemonGoBot(object): @@ -249,10 +248,7 @@ def get_inventory_count(self, what): return itemcount return '0' - def get_player_info(self, print_stats=True): - player_stats = stats = OrderedDict() - - # Get contents of inventory + def get_player_info(self): self.api.get_inventory() response_dict = self.api.call() if 'responses' in response_dict: @@ -270,19 +266,14 @@ def get_player_info(self, print_stats=True): nextlvlxp = (int(playerdata['next_level_xp']) - int(playerdata['experience'])) if 'level' in playerdata: - player_stats['Level'] = playerdata['level'] + print('[#] -- Level: {level}'.format(**playerdata)) if 'experience' in playerdata: - player_stats['Experience'] = playerdata['experience'] - player_stats['Experience until next level'] = nextlvlxp + print('[#] -- Experience: {experience}'.format(**playerdata)) + print('[#] -- Experience until next level: {}'.format(nextlvlxp)) if 'pokemons_captured' in playerdata: - player_stats['Pokemon Captured'] = playerdata['pokemons_captured'] + print('[#] -- Pokemon Captured: {pokemons_captured}'.format(**playerdata)) if 'poke_stop_visits' in playerdata: - player_stats['Pokestops Visited'] = playerdata['poke_stop_visits'] - - if print_stats: - for key in player_stats: - print('[#] -- {}: {}'.format(key, player_stats[key])) - return json.dumps(player_stats, indent=4) + print('[#] -- Pokestops Visited: {poke_stop_visits}'.format(**playerdata)) diff --git a/pokemongo_bot/cell_workers/pokemon_catch_worker.py b/pokemongo_bot/cell_workers/pokemon_catch_worker.py index 5566e1c..e7d5585 100644 --- a/pokemongo_bot/cell_workers/pokemon_catch_worker.py +++ b/pokemongo_bot/cell_workers/pokemon_catch_worker.py @@ -77,12 +77,11 @@ def work(self): if cp < self.config.cp: print_green('[x] Captured ' + str(pokemon_name) + '! [CP' + str(cp) + '] - exchanging for candy') id_list2 = self.count_pokemon_inventory() - try: - # Transfering Pokemon - self.transfer_pokemon(list(Set(id_list2) - Set(id_list1))[0]) - except: - print_red('[###] Your inventory is full! Please manually delete some items.') - break + # Transfering Pokemon + + ## TODO - FIX TRANSFERRING OF POKEMON + self.transfer_pokemon(list(Set(id_list2) - Set(id_list1))) + print_green('[#] ' + str(pokemon_name) + ' has been exchanged for candy!') else: print_green('[x] Captured ' + str(pokemon_name) + '! [CP' + str(cp) + ']') break diff --git a/pokemongo_bot/cell_workers/seen_fort_worker.py b/pokemongo_bot/cell_workers/seen_fort_worker.py index 13fc49d..e00457b 100644 --- a/pokemongo_bot/cell_workers/seen_fort_worker.py +++ b/pokemongo_bot/cell_workers/seen_fort_worker.py @@ -58,8 +58,16 @@ def work(self): items_awarded = spin_details.get('items_awarded', False) if items_awarded: + tmp_count_items = {} for item in items_awarded: - item_id = str(item['item_id']) + item_id = item['item_id'] + if not item_id in tmp_count_items: + tmp_count_items[item_id] = item['item_count'] + else: + tmp_count_items[item_id] += item['item_count'] + + for item_id, item_count in tmp_count_items.iteritems(): + item_id = str(item_id) item_name = self.item_list[item_id] print_green("- " + str(item['item_count']) + "x " + item_name) else: diff --git a/requirements.txt b/requirements.txt index 36596cc..1aa47b0 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,18 +1,8 @@ -click==6.6 -Flask==0.11.1 -Flask-Classy==0.6.10 -future==0.15.2 -geopy==1.11.0 -googlemaps==2.4.4 -gpsoauth==0.3.0 -itsdangerous==0.24 -Jinja2==2.8 -MarkupSafe==0.23 -e git://github.com/tejado/pgoapi.git@1f25e907f3e5f1b603330e71041e1ad7bee7580f#egg=pgoapi +geopy==1.11.0 protobuf==3.0.0b4 -protobuf-to-dict==0.1.0 -pycryptodomex==3.4.2 requests==2.10.0 s2sphere==0.2.4 -six==1.10.0 -Werkzeug==0.11.10 +gpsoauth==0.3.0 +protobuf-to-dict==0.1.0 +googlemaps==2.4.4 diff --git a/server.py b/server.py deleted file mode 100644 index 1198f16..0000000 --- a/server.py +++ /dev/null @@ -1,30 +0,0 @@ -import json - -from flask import Flask -from flask.ext.classy import FlaskView, route -#from bot import PokemonGoBot - -from pgoapi import PGoApi - -app = Flask(__name__) - -global global_bot - -class PokemonGoServer(object): - def __init__(self, bot, port=5000): - api_view = ApiView() - api_view.set_bot(bot) - api_view.register(app) - self.port = port - - def start(self): - app.run(host='0.0.0.0', port=self.port) - -class ApiView(FlaskView): - def set_bot(self, bot): - global global_bot - global_bot = bot - - @route("/player_info") - def get_player_info(self): - return global_bot.get_player_info(False)