| 96 | dust['amount'] = value |
| 97 | |
| 98 | def __init__(self, db, config): |
| 99 | |
| 100 | self.database = db |
| 101 | |
| 102 | self.config = config |
| 103 | super(PokemonGoBot, self).__init__() |
| 104 | |
| 105 | self.fort_timeouts = dict() |
| 106 | self.pokemon_list = json.load( |
| 107 | open(os.path.join(_base_dir, 'data', 'pokemon.json')) |
| 108 | ) |
| 109 | self.item_list = json.load(open(os.path.join(_base_dir, 'data', 'items.json'))) |
| 110 | # @var Metrics |
| 111 | self.metrics = Metrics(self) |
| 112 | self.latest_inventory = None |
| 113 | self.cell = None |
| 114 | self.recent_forts = [None] * config.forts_max_circle_size |
| 115 | self.tick_count = 0 |
| 116 | self.softban = False |
| 117 | self.wake_location = None |
| 118 | self.start_position = None |
| 119 | self.last_map_object = None |
| 120 | self.last_time_map_object = 0 |
| 121 | self.logger = logging.getLogger(type(self).__name__) |
| 122 | self.alt = self.config.gps_default_altitude |
| 123 | |
| 124 | # Make our own copy of the workers for this instance |
| 125 | self.workers = [] |
| 126 | |
| 127 | # Theading setup for file writing |
| 128 | self.web_update_queue = Queue.Queue(maxsize=1) |
| 129 | self.web_update_thread = threading.Thread(target=self.update_web_location_worker) |
| 130 | self.web_update_thread.start() |
| 131 | |
| 132 | # Heartbeat limiting |
| 133 | self.heartbeat_threshold = self.config.heartbeat_threshold |
| 134 | self.heartbeat_counter = 0 |
| 135 | self.last_heartbeat = time.time() |
| 136 | self.hb_locked = False # lock hb on snip |
| 137 | |
| 138 | # Inventory refresh limiting |
| 139 | self.inventory_refresh_threshold = 10 |
| 140 | self.inventory_refresh_counter = 0 |
| 141 | self.last_inventory_refresh = time.time() |
| 142 | |
| 143 | # Catch on/off |
| 144 | self.catch_disabled = False |
| 145 | |
| 146 | self.capture_locked = False # lock catching while moving to VIP pokemon |
| 147 | |
| 148 | # Inform bot if there's a response |
| 149 | self.empty_response = False |
| 150 | |
| 151 | client_id_file_path = os.path.join(_base_dir, 'data', 'mqtt_client_id') |
| 152 | saved_info = shelve.open(client_id_file_path) |
| 153 | key = 'client_id'.encode('utf-8') |
| 154 | if key in saved_info: |
| 155 | self.config.client_id = saved_info[key] |