PokemonGoF / PokemonGo-Bot

The Pokemon Go Bot, baking with community.
MIT License
3.85k stars 1.54k forks source link

[SOLVED]ERROR after login successful #4477

Closed siuyiuyeung closed 7 years ago

siuyiuyeung commented 7 years ago

config.json is valid JSON by using http://jsonlint.com/ to check.

Expected Behavior

the bot should work after login successful.

Actual Behavior

Something went wrong and the bot needed to be restarted. 1.call() takes exactly 1 argument (2 given) 2.Sentry responded with an error: 'utf8' codec can't decode byte 0x9c in position 1 : invalid start byte

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

{
    "auth_service": "ptc",
    "username": "xxxxxxxxxxxx",
    "password": "xxxxxxxxxxxx",
    "location": "xxx.xxxxxx, xxx.xxxxxx",
    "gmapkey": "xxxxxxxxxxxxxxxxxxxxxxxx",
    "encrypt_location": "",
    "websocket_server": false,
    "heartbeat_threshold": 10,
    "tasks": [
      {
        "type": "HandleSoftBan"
      },
      {
        "type": "SleepSchedule",
        "config": {
          "enabled": false,
          "time": "22:54",
          "duration":"7:46",
          "time_random_offset": "00:24",
          "duration_random_offset": "00:43"
        }
      },
      {
        "type": "RandomPause",
        "config": {
          "enabled": false,
          "min_duration": "00:00:10",
          "max_duration": "00:10:00",
          "min_interval": "00:10:00",
          "max_interval": "02:00:00"
        }
      },
      {
        "type": "CompleteTutorial",
        "config": {
          "enabled": false,
          "// set a name": "",
          "nickname": ""
        }
      },
      {
         "type": "CollectLevelUpReward"
      },
      {
        "type": "IncubateEggs",
        "config": {
          "longer_eggs_first": true
        }
      },
      {
        "type": "UpdateLiveStats",
        "config": {
          "enabled": false,
          "min_interval": 10,
          "stats": ["username", "uptime", "stardust_earned", "xp_earned", "xp_per_hour", "stops_visited"],
          "terminal_log": true,
          "terminal_title": true
        }
      },
      {
        "type": "UpdateLiveInventory",
        "config": {
          "enabled": false,
          "min_interval": 120,
          "show_all_multiple_lines": false,
          "items": ["pokemon_bag", "space_info", "pokeballs", "greatballs", "ultraballs", "razzberries", "luckyegg"]
        }
      },
      {
        "type": "TransferPokemon",
        "config": {
          "min_free_slot": 5,
          "transfer_wait_min": 1,
          "transfer_wait_max": 4
        }
      },
      {
        "type": "NicknamePokemon",
        "config": {
          "enabled": false,
          "nickname_template": "{iv_pct}_{iv_ads}"
        }
      },
      {
        "type": "EvolvePokemon",
        "config": {
          "evolve_all": "none",
          "first_evolve_by": "cp",
          "evolve_above_cp": 500,
          "evolve_above_iv": 0.8,
          "logic": "or",
          "evolve_speed": 20,
          "use_lucky_egg": false
        }
      },
      {
        "type": "RecycleItems",
        "config": {
          "min_empty_space": 15,
          "max_balls_keep": 150,
          "max_potions_keep": 50,
          "max_berries_keep": 70,
          "max_revives_keep": 70,
          "item_filter": {
            "Pokeball":       { "keep" : 100 },
            "Potion":         { "keep" : 10 },
            "Super Potion":   { "keep" : 20 },
            "Hyper Potion":   { "keep" : 30 },
            "Revive":         { "keep" : 30 },
            "Razz Berry":     { "keep" : 100 }
          },
          "recycle_wait_min": 1,
          "recycle_wait_max": 4
        }
      },
      {
        "type": "CatchPokemon",
        "config": {
          "catch_visible_pokemon": true,
          "catch_lured_pokemon": true,
          "min_ultraball_to_keep": 5,
          "berry_threshold": 0.35,
          "vip_berry_threshold": 0.9,
          "catch_throw_parameters": {
            "excellent_rate": 0.1,
            "great_rate": 0.5,
            "nice_rate": 0.3,
            "normal_rate": 0.1,
            "spin_success_rate" : 0.6,
            "hit_rate": 0.75
          },
          "catch_simulation": {
            "flee_count": 3,
            "flee_duration": 2,
            "catch_wait_min": 2,
            "catch_wait_max": 6,
            "berry_wait_min": 2,
            "berry_wait_max": 3,
            "changeball_wait_min": 2,
            "changeball_wait_max": 3
          }
        }
      },
      {
        "type": "SpinFort",
        "config": {
          "spin_wait_min": 2,
          "spin_wait_max": 3
        }
      },
      {
        "type": "MoveToFort",
        "config": {
          "lure_attraction": true,
          "lure_max_distance": 2000,
          "walker": "StepWalker"
        }
      },
      {
        "type": "FollowSpiral",
        "config": {
          "diameter": 4,
          "step_size": 70
        }
      }
    ],
    "map_object_cache_time": 5,
    "forts": {
      "avoid_circles": true,
      "max_circle_size": 50,
      "cache_recent_forts": true
    },
    "pokemon_bag": {
      "// if 'show_at_start' is true, it will log all the pokemons in the bag (not eggs) at bot start": {},
      "show_at_start": true,
      "// if 'show_count' is true, it will show the amount of each pokemon (minimum 1)": {},
      "show_count": false,
      "// 'pokemon_info' parameter define which info to show for each pokemon": {},
      "// the available options are": {},
      "// ['cp', 'iv_ads', 'iv_pct', 'ivcp', 'ncp', 'level', 'hp', 'moveset', 'dps']": {},
      "pokemon_info": ["cp", "iv_pct"]
    },
    "walk_max": 4.16,
    "walk_min": 2.16,
    "alt_min": 500,
    "alt_max": 1000,
    "gps_default_altitude": 8.0,
    "replicate_gps_xy_noise": false,
    "replicate_gps_z_noise": false,
    "gps_xy_noise_range": 0.000125,
    "gps_z_noise_range": 12.5,
    "debug": false,
    "test": false,
    "health_record": true,
    "location_cache": true,
    "distance_unit": "km",
    "reconnecting_timeout": 15,
    "logging_color": true,
    "daily_catch_limit": 800,
    "catch": {
      "any": {"catch_above_cp": 0, "catch_above_iv": 0, "logic": "or"},
      "// Example of always catching Rattata:": {},
      "// Rattata": { "always_catch" : true }
    },
    "release": {
      "any": {"release_below_cp": 0, "release_below_iv": 0, "logic": "or"},
      "// Example of always releasing Rattata:": {},
      "// Rattata": {"always_release": true},
      "// Example of keeping 3 stronger (based on CP) Pidgey:": {},
      "// Pidgey": {"keep_best_cp": 3},
      "// Example of keeping 2 best (based on IV) Zubat:": {},
      "// Zubat": {"keep_best_iv": 2},
      "// Also, it is working with any": {},
      "// any": {"keep_best_iv": 3},
      "// Example of keeping the 2 strongest (based on CP) and 3 best (based on IV) Zubat:": {},
      "// Caterpie": {"keep_best_cp": 2, "keep_best_iv": 3},
      "// Example of custom order of static criterion": {},
      "// Weedle": {"keep_best_custom": "iv, cp, hp_max", "amount":2}
    },
    "vips" : {
        "Any pokemon put here directly force to use Berry & Best Ball to capture, to secure the capture rate!": {},
        "any": {"catch_above_cp": 1200, "catch_above_iv": 0.9, "logic": "or" },
        "Lapras": {},
        "Moltres": {},
        "Zapdos": {},
        "Articuno": {},

        "// S-Tier pokemons (if pokemon can be evolved into tier, list the representative)": {},
        "Mewtwo": {},
        "Dragonite": {},
        "Snorlax": {},
        "// Mew evolves to Mewtwo": {},
        "Mew": {},
        "Arcanine": {},
        "Vaporeon": {},
        "Gyarados": {},
        "Exeggutor": {},
        "Muk": {},
        "Weezing": {},
        "Flareon": {}
    }
}

Output when issue occurred

--------------------Starting bot--------------------

2016-08-21 20:42:56,354 [       cli] [INFO] PokemonGO Bot v1.0
2016-08-21 20:42:56,358 [       cli] [INFO] commit: not found
2016-08-21 20:42:56,359 [       cli] [INFO] No config argument specified, checking for /configs/config.json
2016-08-21 20:42:56,361 [       cli] [INFO] Configuration initialized
2016-08-21 20:42:56,361 [pokemongo_bot.health_record.bot_event] [INFO] Health check is enabled. For more information:
2016-08-21 20:42:56,361 [pokemongo_bot.health_record.bot_event] [INFO] https://github.com/PokemonGoF/PokemonGo-Bot/tree/dev#analytics
2016-08-21 20:42:56,367 [requests.packages.urllib3.connectionpool] [INFO] Starting new HTTP connection (1): www.google-analytics.com
2016-08-21 20:42:56,509 [PokemonGoBot] [INFO] [set_start_location] Setting start location.
2016-08-21 20:42:56,510 [PokemonGoBot] [INFO] [x] Coordinates found in passed in location, not geocoding.
2016-08-21 20:42:56,510 [PokemonGoBot] [INFO] [location_found] Location found: 22.299466, 114.171175 (22.299466, 114.171175, 8.0)
2016-08-21 20:42:56,510 [PokemonGoBot] [INFO] [position_update] Now at (22.299466, 114.171175, 8.0)
2016-08-21 20:42:56,510 [PokemonGoBot] [INFO] [login_started] Login procedure started.
2016-08-21 20:42:59,322 [PokemonGoBot] [INFO] [login_successful] Login successful.
2016-08-21 20:42:59,322 [PokemonGoBot] [INFO] Found encrypt.dll! Platform: win32 encrypt.dll directory: C:\Users\User\Desktop\PokemonGoF\PokemonGo-Bot

2016-08-21 20:42:59,323 [PokemonGoBot] [INFO]
Traceback (most recent call last):
  File "pokecli.py", line 674, in <module>
    main()
  File "pokecli.py", line 176, in main
    report_summary(bot)
  File "pokecli.py", line 211, in report_summary
    metrics.capture_stats()
  File "C:\Users\User\Desktop\PokemonGoF\PokemonGo-Bot\pokemongo_bot\metrics.py", line 84, in capture_stats
    response_dict = request.call()
  File "C:\Users\User\Desktop\PokemonGoF\PokemonGo-Bot\pokemongo_bot\api_wrapper.py", line 233, in call
    result = self._call()
  File "C:\Users\User\Desktop\PokemonGoF\PokemonGo-Bot\pokemongo_bot\api_wrapper.py", line 182, in _call
    return PGoApiRequest.call(self, signature)
TypeError: call() takes exactly 1 argument (2 given)
2016-08-21 20:42:59,349 [sentry.errors] [ERROR] Sentry responded with an error: 'utf8' codec can't decode byte 0x9c in position 1: invalid start byte
(url: https://app.getsentry.com/api/90254/store/)
Traceback (most recent call last):
  File "C:\Python27\lib\site-packages\raven\transport\threaded.py", line 174, in send_sync
    super(ThreadedHTTPTransport, self).send(data, headers)
  File "C:\Python27\lib\site-packages\raven\transport\http.py", line 47, in send
    ca_certs=self.ca_certs,
  File "C:\Python27\lib\site-packages\raven\utils\http.py", line 66, in urlopen
    return opener.open(url, data, timeout)
  File "C:\Python27\lib\site-packages\future\backports\urllib\request.py", line 494, in open
    response = self._open(req, data)
  File "C:\Python27\lib\site-packages\future\backports\urllib\request.py", line 512, in _open
    '_open', req)
  File "C:\Python27\lib\site-packages\future\backports\urllib\request.py", line 466, in _call_chain
    result = func(*args)
  File "C:\Python27\lib\site-packages\raven\utils\http.py", line 46, in https_open
    return self.do_open(ValidHTTPSConnection, req)
  File "C:\Python27\lib\site-packages\future\backports\urllib\request.py", line 1284, in do_open
    h.request(req.get_method(), req.selector, req.data, headers)
  File "C:\Python27\lib\httplib.py", line 1057, in request
    self._send_request(method, url, body, headers)
  File "C:\Python27\lib\httplib.py", line 1097, in _send_request
    self.endheaders(body)
  File "C:\Python27\lib\httplib.py", line 1053, in endheaders
    self._send_output(message_body)
  File "C:\Python27\lib\httplib.py", line 895, in _send_output
    msg += message_body
  File "C:\Python27\lib\encodings\utf_8.py", line 16, in decode
    return codecs.utf_8_decode(input, errors, True)
UnicodeDecodeError: 'utf8' codec can't decode byte 0x9c in position 1: invalid start byte
2016-08-21 20:42:59,352 [sentry.errors.uncaught] [ERROR] [u'TypeError: call() takes exactly 1 argument (2 given)', u'  File "pokecli.py", line 674, in
 <module>', u'  File "pokecli.py", line 176, in main', u'  File "pokecli.py", line 211, in report_summary', u'  File "C:\\Users\\User\\Desktop\\Pokemo
nGoF\\PokemonGo-Bot\\pokemongo_bot\\metrics.py", line 84, in capture_stats', u'  File "C:\\Users\\User\\Desktop\\PokemonGoF\\PokemonGo-Bot\\pokemongo_
bot\\api_wrapper.py", line 233, in call', u'  File "C:\\Users\\User\\Desktop\\PokemonGoF\\PokemonGo-Bot\\pokemongo_bot\\api_wrapper.py", line 182, in
_call']

 Something went wrong and the bot needed to be restarted. Please investigate the cause.

Steps to Reproduce

Using PokemonGo-Bot-Start.bat to reinstall

Other Information

OS: windows 7

Branch: master Git Commit: 601e21dbf464e2b3631d6a58e508b26af7fd470f Python Version: 2.7.12 Any other relevant files/configs (eg: path files)
ebbrey commented 7 years ago

i have had multiple unicode decode error due to wrong api.

Check if your pip install blabla installs 1.1.6 or 1.1.8 pgoapi. If its the wrong one try to delete the pgoapi and pgo....egg folder inn ex. C:\Python27\Lib\site-packages and do an install again to see if it installs the 1.1.8

bjchristenson commented 7 years ago

Agree with @thereyrey . Was running into this issue on a few bots running against same code. Some worked, and some didn't. Doing a fresh install resolved the problem for me.

chrisle commented 7 years ago

I did a fresh install. I then did a ./setup.sh -i. Then I entered the virtualenv with source bin/activate. If I list the packages with pip list it gives me pgoapi (1.1.8, /home/XXXXXX/projects/PokemonGo-Bot/src/pgoapi).

The same problem exists.

This happens in both master and dev branches that are updated to the latest commit. Master: 601e21d and Dev 158e469.

chrisle commented 7 years ago

@thereyrey The correct version appears to be in installed. So I'm not sure it's the pgoapi.

The pgoapi submodule is from joelgreen:

chle@ (venv:PokemonGo-Bot)  [~/projects/PokemonGo-Bot/src/pgoapi]
 (master) $ git remote -v
origin  https://github.com/joelgreen/pgoapi.git/ (fetch)
origin  https://github.com/joelgreen/pgoapi.git/ (push)

chle@ (venv:PokemonGo-Bot)  [~/projects/PokemonGo-Bot/src/pgoapi]
 (master) $ cat setup.py | grep version
      version = '1.1.8',

pip list reports its version as 1.1.8:

chle@ (venv:PokemonGo-Bot)  [~/projects/PokemonGo-Bot/src/pgoapi]
 (master) $ cd ../..

chle@ (venv:PokemonGo-Bot)  [~/projects/PokemonGo-Bot]
 {master} $ pip list
click (6.6)
colorama (0.3.7)
contextlib2 (0.5.4)
decorator (4.0.10)
demjson (2.2.4)
enum34 (1.1.6)
eventlet (0.19.0)
Flask (0.11.1)
funcsigs (1.0.2)
future (0.15.2)
geopy (1.11.0)
googlemaps (2.4.4)
gpsoauth (0.3.0)
gpxpy (1.1.1)
greenlet (0.4.9)
haversine (0.4.5)
iniherit (0.3.4)
itsdangerous (0.24)
Jinja2 (2.8)
MarkupSafe (0.23)
mock (2.0.0)
networkx (1.11)
numpy (1.11.0)
pbr (1.10.0)
pgoapi (1.1.8, /home/chle/projects/PokemonGo-Bot/src/pgoapi)
pip (8.1.2)
polyline (1.3.1)
protobuf (3.0.0b4)
protobuf-to-dict (0.1.0)
pycryptodomex (3.4.2)
python-engineio (0.9.2)
python-slugify (1.2.0)
python-socketio (1.4.2)
PyYAML (3.11)
raven (5.23.0)
requests (2.10.0)
s2sphere (0.2.4)
setuptools (26.0.0)
six (1.10.0)
socketIO-client (0.7.0)
timeout-decorator (0.3.2)
Unidecode (0.4.19)
websocket-client (0.37.0)
Werkzeug (0.11.10)
wheel (0.29.0)
xxhash (0.6.1)
yoyo-migrations (5.0.3)

Running on the current master branch

chle@ (venv:PokemonGo-Bot)  [~/projects/PokemonGo-Bot]
 {master} $ git describe --tags
TAG_08132016_MASTER-201-g601e21d

It appears to die during 'GET_PLAYER' RPC request. It looks like it's trying to decode the protobuf for stats.

2016-08-21 16:33:24,030 [pgoapi.rpc_api] [DEBUG] Parsing main RPC response...
2016-08-21 16:33:24,030 [pgoapi.pgoapi] [INFO] Creating a new request...
2016-08-21 16:33:24,030 [pgoapi.pgoapi] [INFO] Adding 'GET_INVENTORY' to RPC request
2016-08-21 16:33:24,030 [pgoapi.pgoapi] [INFO] Adding 'GET_PLAYER' to RPC request
Traceback (most recent call last):
  File "pokecli.py", line 674, in <module>
    main()
  File "pokecli.py", line 176, in main
    report_summary(bot)
  File "pokecli.py", line 211, in report_summary
    metrics.capture_stats()
  File "/home/chle/projects/PokemonGo-Bot/pokemongo_bot/metrics.py", line 84, in capture_stats
    response_dict = request.call()
  File "/home/chle/projects/PokemonGo-Bot/pokemongo_bot/api_wrapper.py", line 233, in call
    result = self._call()
  File "/home/chle/projects/PokemonGo-Bot/pokemongo_bot/api_wrapper.py", line 157, in _call
    accelerometer_axes=3
  File "/home/chle/projects/PokemonGo-Bot/local/lib/python2.7/site-packages/google/protobuf/internal/python_message.py", line 533, in init
    setattr(self, field_name, field_value)
  File "/home/chle/projects/PokemonGo-Bot/local/lib/python2.7/site-packages/google/protobuf/internal/python_message.py", line 669, in field_setter
    new_value = type_checker.CheckValue(new_value)
  File "/home/chle/projects/PokemonGo-Bot/local/lib/python2.7/site-packages/google/protobuf/internal/type_checkers.py", line 134, in CheckValue
    raise ValueError('Value out of range: %d' % proposed_value)
ValueError: Value out of range: -89
2016-08-21 16:33:24,041 [sentry.errors] [ERROR] Sentry responded with an error: 'utf8' codec can't decode byte 0x9c in position 1: invalid start byte (url: https://app.getsentry.com/api/90254/store/)
Traceback (most recent call last):
  File "/home/chle/projects/PokemonGo-Bot/local/lib/python2.7/site-packages/raven/transport/threaded.py", line 174, in send_sync
    super(ThreadedHTTPTransport, self).send(data, headers)
  File "/home/chle/projects/PokemonGo-Bot/local/lib/python2.7/site-packages/raven/transport/http.py", line 47, in send
    ca_certs=self.ca_certs,
  File "/home/chle/projects/PokemonGo-Bot/local/lib/python2.7/site-packages/raven/utils/http.py", line 66, in urlopen
    return opener.open(url, data, timeout)
  File "/home/chle/projects/PokemonGo-Bot/local/lib/python2.7/site-packages/future/backports/urllib/request.py", line 494, in open
    response = self._open(req, data)
  File "/home/chle/projects/PokemonGo-Bot/local/lib/python2.7/site-packages/future/backports/urllib/request.py", line 512, in _open
    '_open', req)
  File "/home/chle/projects/PokemonGo-Bot/local/lib/python2.7/site-packages/future/backports/urllib/request.py", line 466, in _call_chain
    result = func(*args)
  File "/home/chle/projects/PokemonGo-Bot/local/lib/python2.7/site-packages/raven/utils/http.py", line 46, in https_open
    return self.do_open(ValidHTTPSConnection, req)
  File "/home/chle/projects/PokemonGo-Bot/local/lib/python2.7/site-packages/future/backports/urllib/request.py", line 1284, in do_open
    h.request(req.get_method(), req.selector, req.data, headers)
  File "/usr/lib/python2.7/httplib.py", line 1057, in request
    self._send_request(method, url, body, headers)
  File "/usr/lib/python2.7/httplib.py", line 1097, in _send_request
    self.endheaders(body)
  File "/usr/lib/python2.7/httplib.py", line 1053, in endheaders
    self._send_output(message_body)
  File "/usr/lib/python2.7/httplib.py", line 895, in _send_output
    msg += message_body
  File "/home/chle/projects/PokemonGo-Bot/lib/python2.7/encodings/utf_8.py", line 16, in decode
    return codecs.utf_8_decode(input, errors, True)
UnicodeDecodeError: 'utf8' codec can't decode byte 0x9c in position 1: invalid start byte
2016-08-21 16:33:24,042 [sentry.errors.uncaught] [ERROR] [u'ValueError: Value out of range: -89', u'  File "pokecli.py", line 674, in <module>', u'  File "pokecli.py", line 176, in main', u'  File "pokecli.py", line 211, in report_summary', u'  File "pokemongo_bot/metrics.py", line 84, in capture_stats', u'  File "pokemongo_bot/api_wrapper.py", line 233, in call', u'  File "pokemongo_bot/api_wrapper.py", line 157, in _call', u'  File "/home/chle/projects/PokemonGo-Bot/local/lib/python2.7/site-packages/google/protobuf/internal/python_message.py", line 533, in init', u'  File "/home/chle/projects/PokemonGo-Bot/local/lib/python2.7/site-packages/google/protobuf/internal/python_message.py", line 669, in field_setter', u'  File "/home/chle/projects/PokemonGo-Bot/local/lib/python2.7/site-packages/google/protobuf/internal/type_checkers.py", line 134, in CheckValue']
Sun Aug 21 16:33:24 UTC 2016 Pokebot  Stopped.
Press any button or wait 20 seconds to continue.
chrisle commented 7 years ago

SOLVED. The error message was misleading. The issue is that the IP is banned. (Running in a virtual machine in the cloud).

Solution: Use Torify to route traffic through Tor instead.

$ sudo apt-get install tor
$ torify ./run.sh
siuyiuyeung commented 7 years ago

@chrisle wasn't a IP ban. so sad

nugrahawahyu commented 7 years ago

@chrisle how to configure the exit node to specific country?

siuyiuyeung commented 7 years ago

@thereyrey thanks a lot i lov u dude!!!! just delete

pgoapi and pgo....egg folder inn ex. C:\Python27\Lib\site-packages

and reinstall. That's it. Problem solved!