def drop_items_request(pgacc, item_id, amount): time.sleep(random.uniform(2, 4)) try: response_dict = pgacc.req_recycle_inventory_item(item_id, amount) if ('RECYCLE_INVENTORY_ITEM' in response_dict): drop_details = response_dict['RECYCLE_INVENTORY_ITEM'] return drop_details.get('result', -1) except Exception as e: log.warning('Exception while dropping items: %s', repr(e)) return False
def drop_items(api, inventory, item_id, drop_stats, drop_count=-1): item_count = inventory.get(item_id, 0) drop_count = item_count if drop_count == -1 else min(item_count, drop_count) if drop_count > 0: result = drop_items_request(api, item_id, drop_count, inventory) if result == 1: drop_stats[item_id] = drop_count return drop_count else: log.warning(u"Failed dropping {} {}s.".format(drop_count, ITEM_NAMES[item_id])) return 0
def drop_items(pgacc, item_id, drop_stats, drop_count=-1): item_count = pgacc.inventory.get(item_id, 0) drop_count = item_count if drop_count == -1 else min(item_count, drop_count) if drop_count > 0: time.sleep(random.uniform(2, 4)) result = clear_inventory_request(pgacc, item_id, drop_count)['RECYCLE_INVENTORY_ITEM'].result if result == 1: drop_stats[item_id] = drop_count return drop_count else: log.warning(u"GXP: Failed dropping {} {}s.".format(drop_count, ITEM_NAMES[item_id])) return 0
def lure_pokestop(args, pgacc, fort, step_location): if len(fort.active_fort_modifier) == 0: lures = pgacc.inventory_lures lure_result = None modifier = 501 if args.lureFence is not None: allowed = lure_geofence(step_location, args.lureFence) if allowed == []: forbidden = True else: forbidden = False if args.nolureFence is not None: forbidden = lure_geofence(step_location, args.nolureFence, forbidden=True) if forbidden == []: forbidden = False else: forbidden = True if lures == 0: forbidden = True while lure_result is None and lures > 0: lure_response = lure_pokestop_request(pgacc, modifier, fort, step_location) # Check for Captcha if pgacc.has_captcha(): log.debug('Account encountered a reCaptcha.') return False lure_result = lure_response['ADD_FORT_MODIFIER'].result if lure_result is 0: log.warning('Lure unset!') elif lure_result is 1: log.warning('Lure Successfully Set!') elif lure_result is 2: log.warning('Stop already has lure!') elif lure_result is 3: log.warning('Out of range to set lure!') elif lure_result is 4: log.warning('Account has no lures!') else: log.debug('Failed to lure a Pokestop. Unknown result %d.', lure_result) return False
def drop_items_request(api, item_id, amount, account): time.sleep(random.uniform(2, 4)) try: req = api.create_request() req.recycle_inventory_item(item_id=item_id, count=amount) req.check_challenge() req.get_hatched_eggs() add_get_inventory_request(req, account) req.check_awarded_badges() req.download_settings() req.get_buddy_walked() response_dict = req.call() update_account_from_response(account, response_dict) if ('responses' in response_dict) and ('RECYCLE_INVENTORY_ITEM' in response_dict['responses']): drop_details = response_dict['responses']['RECYCLE_INVENTORY_ITEM'] return drop_details.get('result', -1) except Exception as e: log.warning('Exception while dropping items: %s', repr(e)) return False