Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Broken connection fix #1071

Merged
merged 2 commits into from
Jul 26, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions configs/config.json.example
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"initial_transfer": false,
"location_cache": true,
"distance_unit": "km",
"reconnecting_timeout": 15,
"item_filter": {
"1": { "keep" : 100 },
"101": { "keep" : 10 },
Expand Down
37 changes: 27 additions & 10 deletions pokecli.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@
import os
import ssl
import sys
import time
from getpass import getpass
from pgoapi.exceptions import NotLoggedInException

from pokemongo_bot import PokemonGoBot
from pokemongo_bot import logger
Expand Down Expand Up @@ -173,6 +175,13 @@ def init_config():
type=bool,
default=False
)
parser.add_argument(
"-rt",
"--reconnecting_timeout",
help="Timeout between reconnecting if error occured (in minutes, e.g. 15)",
type=float,
default=15.0
)

# Start to parse other attrs
config = parser.parse_args()
Expand Down Expand Up @@ -227,19 +236,27 @@ def main():
return
logger.log('Configuration initialized', 'yellow')

try:
bot = PokemonGoBot(config)
bot.start()
finished = False

while not finished:
try:
bot = PokemonGoBot(config)
bot.start()

logger.log('Starting PokemonGo Bot....', 'green')

logger.log('Starting PokemonGo Bot....', 'green')
while True:
bot.take_step()

while True:
bot.take_step()
except KeyboardInterrupt:
logger.log('Exiting PokemonGo Bot', 'red')
finished = True
# TODO Add number of pokemon catched, pokestops visited, highest CP
# pokemon catched, etc.

except KeyboardInterrupt:
logger.log('Exiting PokemonGo Bot', 'red')
# TODO Add number of pokemon catched, pokestops visited, highest CP
# pokemon catched, etc.
except NotLoggedInException:
logger.log('[x] Error while connecting to the server, please wait %s minutes' % config.reconnecting_timeout, 'red')
time.sleep(config.reconnecting_timeout * 60)


if __name__ == '__main__':
Expand Down