コード例 #1
0
    def __init__(self, config=None):
        self.config = config
        self.gen_device_id()
        self.logger = logging.getLogger(__name__)

        device_info = {
            "device_id": ApiWrapper.DEVICE_ID,
            "device_brand": 'Apple',
            "device_model": 'iPhone',
            "device_model_boot": 'iPhone8,2',
            "hardware_manufacturer": 'Apple',
            "hardware_model": 'N66AP',
            "firmware_brand": 'iPhone OS',
            "firmware_type": '9.3.3'
        }

        PGoApi.__init__(self, device_info=device_info)
         
        if not self.config.hashkey is None:
            PGoApi.activate_hash_server(self,self.config.hashkey)
        # Set to default, just for CI...
        self.actual_lat, self.actual_lng, self.actual_alt = PGoApi.get_position(self)
        self.teleporting = False
        self.noised_lat, self.noised_lng, self.noised_alt = self.actual_lat, self.actual_lng, self.actual_alt

        self.useVanillaRequest = False
コード例 #2
0
    def login(self, provider, username, password):
        # login needs base class "create_request"
        self.useVanillaRequest = True
        if self.config.check_niantic_api is True:
            capi = '0.45.0'
            link = "https://pgorelease.nianticlabs.com/plfe/version"
            f = urllib.urlopen(link)
            myfile = f.read()
            self.config.check_niantic_api
            print "Niantic Official API Version:" + myfile
            if capi not in myfile:
                print("\033[1;31;40m We have detected a Pokemon API Change. The current API version 0.45.0 is no longer supported. Exiting...")
                sys.exit(1)
        
        try:
            PGoApi.set_authentication(
                    self,
                    provider,
                    username=username,
                    password=password
                    )
        except:
            raise

        response = PGoApi.app_simulation_login(self)
        # cleanup code
        self.useVanillaRequest = False
        return response
コード例 #3
0
    def __init__(self, config=None):
        self.config = config
        self.gen_device_id()
        self.logger = logging.getLogger(__name__)

        device_info = {
            "device_id": ApiWrapper.DEVICE_ID,
            "device_brand": 'Apple',
            "device_model": 'iPhone',
            "device_model_boot": 'iPhone8,2',
            "hardware_manufacturer": 'Apple',
            "hardware_model": 'N66AP',
            "firmware_brand": 'iPhone OS',
            "firmware_type": '9.3.3'
        }

        PGoApi.__init__(self, device_info=device_info)

        if not self.config.hashkey is None:
            PGoApi.activate_hash_server(self, self.config.hashkey)
        # Set to default, just for CI...
        self.actual_lat, self.actual_lng, self.actual_alt = PGoApi.get_position(
            self)
        self.teleporting = False
        self.noised_lat, self.noised_lng, self.noised_alt = self.actual_lat, self.actual_lng, self.actual_alt

        self.useVanillaRequest = False
コード例 #4
0
    def login(self, provider, username, password):
        # login needs base class "create_request"
        self.useVanillaRequest = True
        if self.config.check_niantic_api is True:
            capi = '0.45.0'
            link = "https://pgorelease.nianticlabs.com/plfe/version"
            f = urllib.urlopen(link)
            myfile = f.read()
            self.config.check_niantic_api
            print "Niantic Official API Version:" + myfile
            if capi not in myfile:
                print(
                    "\033[1;31;40m We have detected a Pokemon API Change. The current API version 0.45.0 is no longer supported. Exiting..."
                )
                sys.exit(1)

        try:
            PGoApi.set_authentication(self,
                                      provider,
                                      username=username,
                                      password=password)
        except:
            raise

        response = PGoApi.app_simulation_login(self)
        # cleanup code
        self.useVanillaRequest = False
        return response
コード例 #5
0
ファイル: api_wrapper.py プロジェクト: Gurzeh/PokemonGo-Bot
    def __init__(self, config=None):
        PGoApi.__init__(self)
        # Set to default, just for CI...
        self.actual_lat, self.actual_lng, self.actual_alt = PGoApi.get_position(self)
        self.noised_lat, self.noised_lng, self.noised_alt = self.actual_lat, self.actual_lng, self.actual_alt

        self.useVanillaRequest = False
        self.config = config

        if self.config is None or self.config.username is None:
            ApiWrapper.DEVICE_ID = "3d65919ca1c2fc3a8e2bd7cc3f974c34"
            return
        file_salt = None
        did_path = os.path.join(_base_dir, 'data', 'deviceid-%s.txt' % self.config.username)
        if os.path.exists(did_path):
            file_salt = open(did_path, 'r').read()
        if self.config is not None:
            key_string = self.config.username
            if file_salt is not None:
                # Config and file are set, so use those.
                ApiWrapper.DEVICE_ID = hashlib.md5(key_string + file_salt).hexdigest()
            else:
                # Config is set, but file isn't, so make it.
                rand_float = random.SystemRandom().random()
                salt = base64.b64encode((struct.pack('!d', rand_float)))
                ApiWrapper.DEVICE_ID = hashlib.md5(key_string + salt).hexdigest()
                with open(did_path, "w") as text_file:
                    text_file.write("{0}".format(salt))
        else:
            if file_salt is not None:
                # No config, but there's a file, use it.
                ApiWrapper.DEVICE_ID = hashlib.md5(file_salt).hexdigest()
            else:
                # No config or file, so make up a reasonable default.
                ApiWrapper.DEVICE_ID = "3d65919ca1c2fc3a8e2bd7cc3f974c34"
コード例 #6
0
ファイル: api_wrapper.py プロジェクト: bram2268/pokemonpython
    def login(self, provider, username, password):
        # login needs base class "create_request"
        self.useVanillaRequest = True
        try:
            PGoApi.set_authentication(self,
                                      provider,
                                      username=username,
                                      password=password)
        except:
            raise

        response = PGoApi.app_simulation_login(self)
        # cleanup code
        self.useVanillaRequest = False
        return response
コード例 #7
0
    def login(self, provider, username, password):
        # login needs base class "create_request"
        self.useVanillaRequest = True
        try:
            PGoApi.set_authentication(
                    self,
                    provider,
                    username=username,
                    password=password
                    )
        except:
            raise

        response = PGoApi.app_simulation_login(self)
        # cleanup code
        self.useVanillaRequest = False
        return response
コード例 #8
0
ファイル: api_wrapper.py プロジェクト: nuttanai/PokemonGo-Bot
 def login(self, *args):
     # login needs base class "create_request"
     self.useVanillaRequest = True
     try:
         ret_value = PGoApi.login(self, *args)
     finally:
         # cleanup code
         self.useVanillaRequest = False
     return ret_value
コード例 #9
0
 def login(self, *args):
     # login needs base class "create_request"
     self.useVanillaRequest = True
     try:
         ret_value = PGoApi.login(self, *args)
     finally:
         # cleanup code
         self.useVanillaRequest = False
     return ret_value
コード例 #10
0
    def __init__(self, config=None):
        self.config = config
        self.gen_device_id()
        self.capi = float(0.55)
        self.POGOProtos = float(2.6)
        # Check if bot is using lastest POGOProtos, only do so if check_niantic_api is set to true
        # If a new Protos is availible, it mean there's a possibility of a new API
        latestProtos = float(0.0)
        if self.config.check_niantic_api is True:
            if latestProtos > self.POGOProtos:
                link = "https://raw.githubusercontent.com/AeonLucid/POGOProtos/master/.current-version"
                f = urllib.urlopen(link)
                myfile = f.read()
                latestProtos = float(myfile[0:3])
                print(
                    "\033[1;31;40m We have detected a possibility of a new pogo API. Try upgarding it by using ./setup.sh -u command"
                )
                print(
                    "\033[1;31;40m This message might still be shown after updating unless a new commit is done in Github\n"
                )

        device_info = {
            "device_id": ApiWrapper.DEVICE_ID,
            "device_brand": 'Apple',
            "device_model": 'iPhone',
            "device_model_boot": 'iPhone8,2',
            "hardware_manufacturer": 'Apple',
            "hardware_model": 'N66AP',
            "firmware_brand": 'iPhone OS',
            "firmware_type": '9.3.3'
        }

        PGoApi.__init__(self, device_info=device_info)
        if not self.config.hashkey is None:
            PGoApi.activate_hash_server(self, self.config.hashkey)
        # Set to default, just for CI...
        self.actual_lat, self.actual_lng, self.actual_alt = PGoApi.get_position(
            self)
        self.teleporting = False
        self.noised_lat, self.noised_lng, self.noised_alt = self.actual_lat, self.actual_lng, self.actual_alt

        self.useVanillaRequest = False
コード例 #11
0
ファイル: api_wrapper.py プロジェクト: lythien/PokemonGo-Bot
    def set_position(self, lat, lng, alt=None):
        self.actual_lat = lat
        self.actual_lng = lng
        if None != alt:
            self.actual_alt = alt
        else:
            alt = self.actual_alt

        if self.config.replicate_gps_xy_noise:
            lat_noise = gps_noise_rng(self.config.gps_xy_noise_range)
            lng_noise = gps_noise_rng(self.config.gps_xy_noise_range)
            lat = lat + lat_noise
            lng = lng + lng_noise
        if self.config.replicate_gps_z_noise:
            alt_noise = gps_noise_rng(self.config.gps_z_noise_range)
            alt = alt + alt_noise

        self.noised_lat, self.noised_lng, self.noised_alt = lat, lng, alt

        PGoApi.set_position(self, lat, lng, alt)
コード例 #12
0
ファイル: api_wrapper.py プロジェクト: Gurzeh/PokemonGo-Bot
    def set_position(self, lat, lng, alt=None):
        self.actual_lat = lat
        self.actual_lng = lng
        if None != alt:
            self.actual_alt = alt
        else:
            alt = self.actual_alt

        if self.config.replicate_gps_xy_noise:
            lat_noise = gps_noise_rng(self.config.gps_xy_noise_range)
            lng_noise = gps_noise_rng(self.config.gps_xy_noise_range)
            lat = lat + lat_noise
            lng = lng + lng_noise
        if self.config.replicate_gps_z_noise:
            alt_noise = gps_noise_rng(self.config.gps_z_noise_range)
            alt = alt + alt_noise

        self.noised_lat, self.noised_lng, self.noised_alt = lat, lng, alt

        PGoApi.set_position(self, lat, lng, alt)
コード例 #13
0
ファイル: api_wrapper.py プロジェクト: zoberg/PokemonGo-Bot
    def __init__(self, config=None):
        PGoApi.__init__(self)
        # Set to default, just for CI...
        self.actual_lat, self.actual_lng, self.actual_alt = PGoApi.get_position(
            self)
        self.teleporting = False
        self.noised_lat, self.noised_lng, self.noised_alt = self.actual_lat, self.actual_lng, self.actual_alt

        self.useVanillaRequest = False
        self.config = config

        if self.config is None or self.config.username is None:
            ApiWrapper.DEVICE_ID = "3d65919ca1c2fc3a8e2bd7cc3f974c34"
            return
        file_salt = None
        did_path = os.path.join(_base_dir, 'data',
                                'deviceid-%s.txt' % self.config.username)
        if os.path.exists(did_path):
            file_salt = open(did_path, 'r').read()
        if self.config is not None:
            key_string = self.config.username
            if file_salt is not None:
                # Config and file are set, so use those.
                ApiWrapper.DEVICE_ID = hashlib.md5(key_string +
                                                   file_salt).hexdigest()
            else:
                # Config is set, but file isn't, so make it.
                rand_float = random.SystemRandom().random()
                salt = base64.b64encode((struct.pack('!d', rand_float)))
                ApiWrapper.DEVICE_ID = hashlib.md5(key_string +
                                                   salt).hexdigest()
                with open(did_path, "w") as text_file:
                    text_file.write("{0}".format(salt))
        else:
            if file_salt is not None:
                # No config, but there's a file, use it.
                ApiWrapper.DEVICE_ID = hashlib.md5(file_salt).hexdigest()
            else:
                # No config or file, so make up a reasonable default.
                ApiWrapper.DEVICE_ID = "3d65919ca1c2fc3a8e2bd7cc3f974c34"
コード例 #14
0
    def login(self, provider, username, password):
        # login needs base class "create_request"
        self.useVanillaRequest = True
        
        # Get Timecode and Country Code
        country_code = "US"
        timezone = "America/Chicago"
        geolocator = GoogleV3(api_key=self.config.gmapkey)
        
        if self.config.locale_by_location:
            try:
                location = geolocator.reverse((self.actual_lat, self.actual_lng), timeout = 10, exactly_one=True)
                country_code = self.get_component(location,'country')
            except:
                self.logger.warning("Please make sure you have google api key and enable Google Maps Geocoding API at console.developers.google.com")
            
            try:    
                timezone = geolocator.timezone([self.actual_lat, self.actual_lng], timeout=10)
            except:
                self.logger.warning("Please make sure you have google api key and enable Google Maps Time Zone API at console.developers.google.com")

        # Start login process
        try:
            if self.config.proxy:
                PGoApi.set_authentication(
                    self,
                    provider,
                    username=username,
                    password=password,
                    proxy_config={'http': self.config.proxy, 'https': self.config.proxy}
                )
            else:
                PGoApi.set_authentication(
                    self,
                    provider,
                    username=username,
                    password=password
                )
        except:
            raise
        try:
            if self.config.locale_by_location:
                response = PGoApi.app_simulation_login(self,country_code,timezone.zone)
            else:
                response = PGoApi.app_simulation_login(self) # To prevent user who have not update the api being caught off guard by errors
        except BadHashRequestException:
            self.logger.warning("Your hashkey seems to have expired or is not accepted!")
            self.logger.warning("Please set a valid hash key in your auth JSON file!")
            exit(-3)
            raise
        except BannedAccountException:
            self.logger.warning("This account is banned!")
            exit(-3)
            raise
        except:
            raise
        # cleanup code
        self.useVanillaRequest = False
        return response
コード例 #15
0
    def login(self, provider, username, password):
        # login needs base class "create_request"
        self.useVanillaRequest = True
        
        # Get Timecode and Country Code
        country_code = "US"
        timezone = "America/Chicago"
        geolocator = GoogleV3(api_key=self.config.gmapkey)
        
        if self.config.locale_by_location:
            try:
                location = geolocator.reverse((self.actual_lat, self.actual_lng), timeout = 10, exactly_one=True)
                country_code = self.get_component(location,'country')
            except:
                self.logger.warning("Please make sure you have google api key and enable Google Maps Geocoding API at console.developers.google.com")
            
            try:    
                timezone = geolocator.timezone([self.actual_lat, self.actual_lng], timeout=10)
            except:
                self.logger.warning("Please make sure you have google api key and enable Google Maps Time Zone API at console.developers.google.com")

        # Start login process
        try:
            if self.config.proxy:
                PGoApi.set_authentication(
                    self,
                    provider,
                    username=username,
                    password=password,
                    proxy_config={'http': self.config.proxy, 'https': self.config.proxy}
                )
            else:
                PGoApi.set_authentication(
                    self,
                    provider,
                    username=username,
                    password=password
                )
        except:
            raise
        try:
            if self.config.locale_by_location:
                response = PGoApi.app_simulation_login(self,country_code,timezone.zone)
            else:
                response = PGoApi.app_simulation_login(self) # To prevent user who have not update the api being caught off guard by errors
        except BadHashRequestException:
            self.logger.warning("Your hashkey seems to have expired or is not accepted!")
            self.logger.warning("Please set a valid hash key in your auth JSON file!")
            exit(-3)
            raise
        except BannedAccountException:
            self.logger.warning("This account is banned!")
            exit(-3)
            raise
        except:
            raise
        # cleanup code
        self.useVanillaRequest = False
        return response
コード例 #16
0
ファイル: api_wrapper.py プロジェクト: dtee/PokemonGo-Bot
    def __init__(self, config=None):
        self.config = config
        self.gen_device_id()
        self.capi = float(0.55)
        self.POGOProtos = float(2.6)
        # Check if bot is using lastest POGOProtos, only do so if check_niantic_api is set to true
        # If a new Protos is availible, it mean there's a possibility of a new API
        latestProtos = float(0.0)
        if self.config.check_niantic_api is True:
            if latestProtos > self.POGOProtos:
                link = "https://raw.githubusercontent.com/AeonLucid/POGOProtos/master/.current-version"
                f = urllib.urlopen(link)
                myfile = f.read()
                latestProtos = float(myfile[0:3])
                print("\033[1;31;40m We have detected a possibility of a new pogo API. Try upgarding it by using ./setup.sh -u command")
                print("\033[1;31;40m This message might still be shown after updating unless a new commit is done in Github\n")
        
        device_info = {
            "device_id": ApiWrapper.DEVICE_ID,
            "device_brand": 'Apple',
            "device_model": 'iPhone',
            "device_model_boot": 'iPhone8,2',
            "hardware_manufacturer": 'Apple',
            "hardware_model": 'N66AP',
            "firmware_brand": 'iPhone OS',
            "firmware_type": '9.3.3'
        }

        PGoApi.__init__(self, device_info=device_info)
        if not self.config.hashkey is None:
            PGoApi.activate_hash_server(self,self.config.hashkey)
        # Set to default, just for CI...
        self.actual_lat, self.actual_lng, self.actual_alt = PGoApi.get_position(self)
        self.teleporting = False
        self.noised_lat, self.noised_lng, self.noised_alt = self.actual_lat, self.actual_lng, self.actual_alt

        self.useVanillaRequest = False
コード例 #17
0
ファイル: api_wrapper.py プロジェクト: nuttanai/PokemonGo-Bot
 def __init__(self):
     PGoApi.__init__(self)
     self.useVanillaRequest = False
コード例 #18
0
def api_init(account):
    api = PGoApi()
    
    try:
        api.set_position(360,360,0)  
        api.set_authentication(provider = account.auth_service,
                               username = account.username, password =  account.password)
        api.activate_signature(get_encryption_lib_path()); time.sleep(1); api.get_player()
    
    except AuthException:
        log.error('Login for %s:%s failed - wrong credentials?' % (account.username, account.password))
        return None
    
    else:
        time.sleep(1); response = api.get_inventory()
        
        if response:
            if 'status_code' in response:
                if response['status_code'] == 1 or response['status_code'] == 2: return api
                
                elif response['status_code'] == 3:
                    # try to accept ToS
                    time.sleep(5); response = api.mark_tutorial_complete(tutorials_completed = 0,
                                    send_marketing_emails = False, send_push_notifications = False)                    

                    if response['status_code'] == 1 or response['status_code'] == 2:
                        print('Accepted TOS for %s' % account.username)
                        return api
                    
                    elif response['status_code'] == 3:
                        print('Account %s BANNED!' % account.username)
                        raise AccountBannedException
                
    return None
コード例 #19
0
 def __init__(self):
     PGoApi.__init__(self)
     self.useVanillaRequest = False