PokemonGo-Bot icon indicating copy to clipboard operation
PokemonGo-Bot copied to clipboard

Buddy Enabled Causes Error on Exit

Open Holzberg opened this issue 9 years ago • 7 comments

Expected Behavior

The bot should exit without error

Actual Behavior

I get an error

Your FULL config.json (remove your username, password, gmapkey and any other private info)

Just a subset of tasks

"tasks": [
    {
        "type": "HandleSoftBan"
    },
    {
        "type": "CompleteTutorial",
        "config": {
            "enabled": true,
            "// set a name": "",
            "nickname": "",
            "// 0 = No Team, 1 = Blue, 2 = Red, 3 = Yellow": "",
            "team": 0
        }
    },
    {
        "type": "CollectLevelUpReward",
        "config": {
            "collect_reward": true,
            "level_limit": 2
        }
    },
    {
        "type": "BuddyPokemon",
        "config": {
            "enabled": true,
            "buddy_list": "charmander, squirtle, bulbasaur",
            "best_in_family": true,
            "// candy_limit = 0 means no limit, so it will never change current buddy": {},
            "candy_limit": 0,
            "candy_limit_absolute": 0,
            "// force_first_change = true will always change buddy at start removing current one": {},
            "force_first_change": false,
            "buddy_change_wait_min": 3,
            "buddy_change_wait_max": 5,
            "min_interval": 120
        }
    }
]

Output when issue occurred

[2017-02-21 08:27:36] [       cli] [INFO] Encountered 0 pokemon, 0 caught, 0 released, 0 evolved, 0 never seen before ()
[2017-02-21 08:27:36] [       cli] [INFO] Threw 0 pokeballs
[2017-02-21 08:27:36] [       cli] [INFO] Earned 0 Stardust
[2017-02-21 08:27:36] [       cli] [INFO] Hatched eggs 0
[2017-02-21 08:27:36] [       cli] [INFO]
[2017-02-21 08:27:36] [       cli] [INFO] Highest CP Pokemon:
[2017-02-21 08:27:36] [       cli] [INFO] Most Perfect Pokemon:
Traceback (most recent call last):
  File "pokecli.py", line 865, in <module>
    main()
  File "pokecli.py", line 206, in main
    bot.tick()
  File "/home/tony/bot/PokemonGo-Bot/pokemongo_bot/__init__.py", line 778, in tick
    if worker.work() == WorkerResult.RUNNING:
  File "/home/tony/bot/PokemonGo-Bot/pokemongo_bot/cell_workers/buddy_pokemon.py", line 135, in work
    if self._km_walked() - self.buddy['last_km_awarded'] >= self.buddy_distance_needed:
KeyError: 'last_km_awarded'

Steps to Reproduce

run latest master branch using buddy and have it exit using CollectLevelUpReward max level

Other Information

OS: Ubuntu 16.04 server

Branch: master

Git Commit: e00e8db36ca095c42a98e8925c454edc682eb13a

Python Version: 2.7

Any other relevant files/configs (eg: path files)

Holzberg avatar Feb 21 '17 14:02 Holzberg

I had the same issue. Adding the following code on line 135 fixed it for me:

        if not 'last_km_awarded' in self.buddy or ('last_km_awarded' in self.buddy and not isinstance(self.buddy['last_km_awarded'],int)):
            self.buddy['last_km_awarded']=0

mlussi avatar Feb 21 '17 15:02 mlussi

@mlussi Thanks, that worked. Hopefully they can find out why it isn't being set in the first place and fix it.

Holzberg avatar Feb 21 '17 18:02 Holzberg

@Holzberg My Guess is the buddy got evolved and removed from buddy list. But the bot still think that the buddy is still there.

Modified my codes and now testing if that the case.

MerlionRock avatar Mar 05 '17 03:03 MerlionRock

I don't think that's the case for me because I am using a starter as a buddy and only leveling to 3 so there would be no way it would have enough candy to evolve.

On Mar 4, 2017 9:47 PM, "MerlionRock" [email protected] wrote:

@Holzberg https://github.com/Holzberg My Guess is the buddy got evolved and removed from buddy list. But the bot still think that the buddy is still there.

Modified my codes and now testing if that the case.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/PokemonGoF/PokemonGo-Bot/issues/5928#issuecomment-284203147, or mute the thread https://github.com/notifications/unsubscribe-auth/AGWsOvN5TJ2E0NPD0j6ezon5KWaXfPFEks5rijBDgaJpZM4MHYTc .

Holzberg avatar Mar 05 '17 05:03 Holzberg

As a note, I have check level up reward enabled and have it set to max level 3. I think what happens is the bot starts, sees it has level 3 and stops before the buddy module is initialized.

On Mar 4, 2017 11:55 PM, "Tony Holzer" [email protected] wrote:

I don't think that's the case for me because I am using a starter as a buddy and only leveling to 3 so there would be no way it would have enough candy to evolve.

On Mar 4, 2017 9:47 PM, "MerlionRock" [email protected] wrote:

@Holzberg https://github.com/Holzberg My Guess is the buddy got evolved and removed from buddy list. But the bot still think that the buddy is still there.

Modified my codes and now testing if that the case.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/PokemonGoF/PokemonGo-Bot/issues/5928#issuecomment-284203147, or mute the thread https://github.com/notifications/unsubscribe-auth/AGWsOvN5TJ2E0NPD0j6ezon5KWaXfPFEks5rijBDgaJpZM4MHYTc .

Holzberg avatar Mar 05 '17 05:03 Holzberg

seems to be resolved in later builds. closing

pogarek avatar Mar 27 '17 08:03 pogarek

As far as I can see, the problem is still there. It seems to be related to the account. I created a new account, and did the initial steps on the phone, included setting a buddy. Immediately afterwards I switched to the bot. It failed with KeyError: 'last_km_awarded' every time I had the buddy enabled. After running the bot for some time I opened the account on the phone, collected the buddy candies, and afterwards the bot run with buddy enabled without issues.

guenterneust avatar May 20 '17 06:05 guenterneust