tejado / pgoapi

Pokemon Go API lib
Other
1.4k stars 445 forks source link

NICKNAME_POKEMON #59

Closed Techbrunch closed 8 years ago

Techbrunch commented 8 years ago

I'm trying to set a nickname to one of my pokemon but it's not working, I'm using:

api.nickname_pokemon(pokemon_id = "XXX", nickname = "test")

This is the console output:

2016-07-21 00:15:22,248 [    pgoapi] [ INFO] Execution of RPC
2016-07-21 00:15:22,248 [   rpc_api] [WARNING] Argument pokemon_id with value REDACTED unknown inside NicknamePokemonMessage (Exception: 'long' object has no attribute 'append')
2016-07-21 00:15:27,761 [    pgoapi] [ INFO] Cleanup of request!
Response dictionary: 
{   'auth_ticket': {   'end': 'REDACTED',
                       'expire_timestamp_ms': 1469054727504L,
                       'start': 'REDACTED'},
    'request_id': REDACTED,
    'responses': {   'NICKNAME_POKEMON': {   'result': 3}},
    'status_code': 1}

Any idea what I'm doing wrong ?

danil-shatokhin commented 8 years ago

NicknamePokemonResponse.proto says in result enum this answer corresponds to ERROR_POKEMON_NOT_FOUND = 3;

Icehawk78 commented 8 years ago

I'm getting the same issue.

For the request I was generating, I explicitly grabbed the ID from the PokemonData in the InventoryData response - not sure if a conversion needs to be made, or if there's a mapping issue in the nickname request proto, but it seems like it should be working.

Icehawk78 commented 8 years ago

Steps to reproduce:

api.get_inventory()
response_dict = api.call()
all_pokemon = filter(lambda i: i['inventory_item_data'].has_key('pokemon_data') and not i['inventory_item_data']['pokemon_data'].has_key('is_egg'), response_dict['responses']['GET_INVENTORY']['inventory_delta']['inventory_items'])
all_pokemon = map(lambda i: i['inventory_item_data']['pokemon_data'], all_pokemon)`
pokemon_ids = map(lambda p: p['id'], all_pokemon)
responses = map(lambda p: api.nickname_pokemon(pokemon_id=p, nickname='TEST').call()['responses']['NICKNAME_POKEMON'], pokemon_ids)

This returns (for the single pokemon in my inventory) {'result': 3}

earthchie commented 8 years ago

any update here?

ghost commented 8 years ago

The problem seems to be the ID type.

In protos/POGOProtos/Networking/Requests/Messages_pb2.py Line 1395 I've changed "type=4" to "type=6" and it works without problems!

Techbrunch commented 8 years ago

I'm guessing this pull request fixed the issue: https://github.com/AeonLucid/POGOProtos/pull/38 so I would look into https://github.com/tejado/pgoapi/issues/95 to fix the issue.

Techbrunch commented 8 years ago

I'm closing this issue in favor of https://github.com/tejado/pgoapi/issues/95

Techbrunch commented 8 years ago

@GreWull How should I pass the pokemon_id ? I always get the pokemon not found error :(

api.nickname_pokemon(pokemon_id = 13918471692738592768, nickname = 'Test')
response_dict = api.call()
print('Response dictionary: \n\r{}'.format(pprint.PrettyPrinter(indent=4).pformat(response_dict)))
ghost commented 8 years ago

@Techbrunch that's strange, I've seen you have commited the change.

This is the function I use (in the Pokemon Go Bot):

 def rename_pokemon(self, pid, name): 
        self.api.nickname_pokemon(pokemon_id=pid, nickname=name)
        response_dict = self.api.call()

The ID I use is type Long, I don't see why it shouldn't work..

Techbrunch commented 8 years ago

@GreWull Not sure what was wrong but after updating the proto files now it works, thanks :)

Techbrunch commented 8 years ago

I thought the protos where up to date but they still are not. So this issue is still not fixed.

tejado commented 8 years ago

What do you mean with they are not up to date?

Techbrunch commented 8 years ago

Well this call is still not working if I don't manually compile the current protos from AeonLucid.

Edit: I'm going to try with a fresh repo Edit2:Sorry with a fresh repo it works, not sure what happened ><