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

Added UpdateLiveInventory config #3950

Merged
merged 16 commits into from
Aug 18, 2016
Merged
9 changes: 9 additions & 0 deletions configs/config.json.cluster.example
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,15 @@
"terminal_title": true
}
},
{
"type": "UpdateLiveInventory",
"config": {
"enabled": false,
"min_interval": 120,
"show_all_multiple_lines": false,
"items": ["space_info", "pokeballs", "greatballs", "ultraballs", "razzberries", "luckyegg"]
}
},
{
"type": "TransferPokemon"
},
Expand Down
11 changes: 10 additions & 1 deletion configs/config.json.example
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,20 @@
"config": {
"enabled": false,
"min_interval": 10,
"stats": ["uptime", "stardust_earned", "xp_earned", "xp_per_hour", "stops_visited"],
"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": ["space_info", "pokeballs", "greatballs", "ultraballs", "razzberries", "luckyegg"]
}
},
{
"type": "TransferPokemon"
},
Expand Down
9 changes: 9 additions & 0 deletions configs/config.json.map.example
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,15 @@
"terminal_title": true
}
},
{
"type": "UpdateLiveInventory",
"config": {
"enabled": false,
"min_interval": 120,
"show_all_multiple_lines": false,
"items": ["space_info", "pokeballs", "greatballs", "ultraballs", "razzberries", "luckyegg"]
}
},
{
"type": "TransferPokemon"
},
Expand Down
9 changes: 9 additions & 0 deletions configs/config.json.optimizer.example
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,15 @@
"longer_eggs_first": true
}
},
{
"type": "UpdateLiveInventory",
"config": {
"enabled": false,
"min_interval": 120,
"show_all_multiple_lines": false,
"items": ["space_info", "pokeballs", "greatballs", "ultraballs", "razzberries", "luckyegg"]
}
},
{
"type": "PokemonOptimizer",
"config": {
Expand Down
9 changes: 9 additions & 0 deletions configs/config.json.path.example
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,15 @@
"terminal_title": true
}
},
{
"type": "UpdateLiveInventory",
"config": {
"enabled": false,
"min_interval": 120,
"show_all_multiple_lines": false,
"items": ["space_info", "pokeballs", "greatballs", "ultraballs", "razzberries", "luckyegg"]
}
},
{
"type": "TransferPokemon"
},
Expand Down
9 changes: 9 additions & 0 deletions configs/config.json.pokemon.example
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,15 @@
"terminal_title": true
}
},
{
"type": "UpdateLiveInventory",
"config": {
"enabled": false,
"min_interval": 120,
"show_all_multiple_lines": false,
"items": ["space_info", "pokeballs", "greatballs", "ultraballs", "razzberries", "luckyegg"]
}
},
{
"type": "TransferPokemon"
},
Expand Down
19 changes: 14 additions & 5 deletions pokecli.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,11 @@ class SIGINTRecieved(Exception): pass
def main():
bot = False

try:
def handle_sigint(*args):
raise SIGINTRecieved
signal.signal(signal.SIGINT, handle_sigint)
def handle_sigint(*args):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like you have a bad merge. This was changed in a different PR.

raise SIGINTRecieved
signal.signal(signal.SIGINT, handle_sigint)

try:
logger.info('PokemonGO Bot v1.0')
sys.stdout = codecs.getwriter('utf8')(sys.stdout)
sys.stderr = codecs.getwriter('utf8')(sys.stderr)
Expand Down Expand Up @@ -103,7 +103,7 @@ def handle_sigint(*args):
while True:
bot.tick()

except (KeyboardInterrupt, SIGINTRecieved):
except KeyboardInterrupt:
bot.event_manager.emit(
'bot_exit',
sender=bot,
Expand Down Expand Up @@ -147,6 +147,15 @@ def handle_sigint(*args):
)
except GeocoderQuotaExceeded:
raise Exception("Google Maps API key over requests limit.")
except SIGINTRecieved:
if bot:
bot.event_manager.emit(
'bot_interrupted',
sender=bot,
level='info',
formatted='Bot caught SIGINT. Shutting down.'
)
report_summary(bot)
except Exception as e:
# always report session summary and then raise exception
if bot:
Expand Down
1 change: 1 addition & 0 deletions pokemongo_bot/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ def _register_events(self):

self.event_manager.register_event('bot_start')
self.event_manager.register_event('bot_exit')
self.event_manager.register_event('bot_interrupted')

# sleep stuff
self.event_manager.register_event(
Expand Down
1 change: 1 addition & 0 deletions pokemongo_bot/cell_workers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@
from follow_cluster import FollowCluster
from sleep_schedule import SleepSchedule
from update_live_stats import UpdateLiveStats
from update_live_inventory import UpdateLiveInventory
3 changes: 3 additions & 0 deletions pokemongo_bot/cell_workers/nickname_pokemon.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

import os
import json
from pokemongo_bot.base_task import BaseTask
Expand Down
1 change: 1 addition & 0 deletions pokemongo_bot/cell_workers/pokemon_catch_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ def _use_berry(self, berry_id, berry_count, encounter_id, catch_rate_by_ball, cu
# softban?
else:
new_catch_rate_by_ball = catch_rate_by_ball
self.bot.softban = True
self.emit_event(
'softban',
level='warning',
Expand Down
2 changes: 1 addition & 1 deletion pokemongo_bot/cell_workers/spin_fort.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ def work(self):
def get_forts_in_range(self):
forts = self.bot.get_forts(order_by_distance=True)

for fort in forts:
for fort in reversed(forts):
if 'cooldown_complete_timestamp_ms' in fort:
self.bot.fort_timeouts[fort["id"]] = fort['cooldown_complete_timestamp_ms']
forts.remove(fort)
Expand Down
Loading