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

Dev merge to master #4987

Merged
merged 26 commits into from
Aug 31, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
bd4b32e
Revert "Hotfix for EvolvePokemon" (#4964)
alexyaoyang Aug 30, 2016
549e372
Added reconnectPeriod, set to 10s.
solderzzc Aug 30, 2016
4d62a96
Merge branch 'dev' of https://github.com/PokemonGoF/PokemonGo-Bot int…
solderzzc Aug 30, 2016
012b7fd
Hotfix for EvolvePokemon (#4965)
alexyaoyang Aug 30, 2016
bb0f9f8
Fixed eggs not incubating
DeXtroTip Aug 30, 2016
91b7bd7
Merge remote-tracking branch 'upstream/dev' into fix_incubate_eggs
DeXtroTip Aug 30, 2016
62f4021
Merge pull request #4967 from DeXtroTip/fix_incubate_eggs
solderzzc Aug 30, 2016
afa1eda
PokemonGo-Bot-Updater
LuckyMe4Evers Aug 30, 2016
994174b
Merge pull request #4968 from LuckyMe4Evers/dev
solderzzc Aug 30, 2016
c0f6a36
Fixed IndexError exception in incubate_eggs.py.
solderzzc Aug 30, 2016
fdcbd76
Fixed egg hatching data
DeXtroTip Aug 30, 2016
b74dd5e
Small update
DeXtroTip Aug 30, 2016
b6ac7d9
Merge pull request #4973 from DeXtroTip/fix_incubate_eggs
solderzzc Aug 31, 2016
624dfdd
Get player_stats from cached inventory, not .json file
Gobberwart Aug 31, 2016
0ff1551
Tweaks to telegram
Gobberwart Aug 31, 2016
a27e383
Reverted change
Gobberwart Aug 31, 2016
e4e7803
Added capture_stats()
Gobberwart Aug 31, 2016
39b02b1
Merge pull request #4979 from Gobberwart/dev_telegram
solderzzc Aug 31, 2016
25f58e3
Merge branch 'dev' into dev_updatelivestats
Gobberwart Aug 31, 2016
95b65bb
Merge pull request #4981 from Gobberwart/dev_updatelivestats
Gobberwart Aug 31, 2016
eb7d8e2
Update config.json.cluster.example
oralunal Aug 31, 2016
03eb674
Update config.json.example
oralunal Aug 31, 2016
ede5cfa
Update config.json.map.example
oralunal Aug 31, 2016
2fc9927
Update config.json.path.example
oralunal Aug 31, 2016
ab9f39f
Update config.json.pokemon.example
oralunal Aug 31, 2016
2c09179
Merge pull request #4984 from oralunal/patch-5
solderzzc Aug 31, 2016
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -142,3 +142,5 @@ pip-selfcheck.json

# Mac Gargage
.DS_Store
data/mqtt_client_id
Encrypt_64.dll
6 changes: 5 additions & 1 deletion configs/config.json.cluster.example
Original file line number Diff line number Diff line change
Expand Up @@ -285,5 +285,9 @@
"Weezing": {},
"Flareon": {}

}
},
"websocket": {
"start_embedded_server": true,
"server_url": "127.0.0.1:4000"
}
}
6 changes: 5 additions & 1 deletion configs/config.json.example
Original file line number Diff line number Diff line change
Expand Up @@ -330,5 +330,9 @@
"Muk": {},
"Weezing": {},
"Flareon": {}
}
},
"websocket": {
"start_embedded_server": true,
"server_url": "127.0.0.1:4000"
}
}
6 changes: 5 additions & 1 deletion configs/config.json.map.example
Original file line number Diff line number Diff line change
Expand Up @@ -549,5 +549,9 @@
"Weezing": {},
"Flareon": {}

}
},
"websocket": {
"start_embedded_server": true,
"server_url": "127.0.0.1:4000"
}
}
6 changes: 5 additions & 1 deletion configs/config.json.path.example
Original file line number Diff line number Diff line change
Expand Up @@ -268,5 +268,9 @@
"// all": {"keep_best_cp": 100},
"// Example of keeping the 2 strongest (based on CP) and 3 best (based on IV) Zubat:": {},
"// Zubat": {"keep_best_cp": 2, "keep_best_iv": 3}
}
},
"websocket": {
"start_embedded_server": true,
"server_url": "127.0.0.1:4000"
}
}
6 changes: 5 additions & 1 deletion configs/config.json.pokemon.example
Original file line number Diff line number Diff line change
Expand Up @@ -519,5 +519,9 @@
"Weezing": {},
"Flareon": {}

}
},
"websocket": {
"start_embedded_server": true,
"server_url": "127.0.0.1:4000"
}
}
5 changes: 3 additions & 2 deletions map-chat/javascript/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@ var urlHashTopic = location.hash ? location.hash.substring(1).toLowerCase() : nu
var topic = urlHashTopic ? urlHashTopic : "pgomapcatch/chat";

function initialiseEventBus(){
window.client = mqtt.connect('ws://broker.pikabot.org'); // you add a ws:// url here
window.client = mqtt.connect('ws://broker.pikabot.org',{
reconnectPeriod:10*1000
});
client.subscribe("pgomapcatch/#");
client.subscribe("pgochat/chat");

client.on("message", function (topic, payload) {
//Materialize.toast(payload, 4000);
if (topic === 'pgochat/chat') {
Expand Down
28 changes: 11 additions & 17 deletions pokemongo_bot/cell_workers/incubate_eggs.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ def _process_config(self):
self.infinite_longer_eggs_first = self.config.get("infinite_longer_eggs_first", False)
self.breakable_longer_eggs_first = self.config.get("breakable_longer_eggs_first", True)
self.min_interval = self.config.get('min_interval', 120)

self.breakable_incubator = self.config.get("breakable", [2,5,10])
self.infinite_incubator = self.config.get("infinite", [2,5,10])

def work(self):
try:
self._check_inventory()
Expand Down Expand Up @@ -80,7 +80,7 @@ def _apply_incubators(self, available_eggs, available_incubators):
for egg in available_eggs:
if egg["used"] or egg["km"] == -1:
continue

self.emit_event(
'incubate_try',
level='debug',
Expand Down Expand Up @@ -124,27 +124,21 @@ def _apply_incubators(self, available_eggs, available_incubators):
egg["used"] = True

def _check_inventory(self, lookup_ids=[]):
inv = {}
if lookup_ids:
inventory.refresh_inventory()
matched_pokemon = []
temp_eggs = []
temp_used_incubators = []
temp_ready_breakable_incubators = []
temp_ready_infinite_incubators = []
inv = reduce(
dict.__getitem__,
["responses", "GET_INVENTORY", "inventory_delta", "inventory_items"],
inventory.jsonify_inventory()
)
inv = inventory.jsonify_inventory()
for inv_data in inv:
inv_data = inv_data.get("inventory_item_data", {})
if "egg_incubators" in inv_data:
temp_used_incubators = []
temp_ready_breakable_incubators = []
temp_ready_infinite_incubators = []
incubators = inv_data.get("egg_incubators", {}).get("egg_incubator",[])
if isinstance(incubators, basestring): # checking for old response
incubators = [incubators]
for incubator in incubators:
for incubator in incubators:
if 'pokemon_id' in incubator:
start_km = incubator.get('start_km_walked', 0)
km_walked = incubator.get('target_km_walked', 0)
Expand Down Expand Up @@ -218,8 +212,8 @@ def _hatch_eggs(self):
else:
pokemon['name'] = "error"
except:
pokemon_data = [{"name":"error","cp":"error","iv":"error"}]
if not pokemon_ids or pokemon_data[0]['name'] == "error":
pokemon_data = [{"name":"error", "cp":"error", "iv":"error"}]
if not pokemon_ids or not pokemon_data or pokemon_data[0]['name'] == "error":
self.emit_event(
'egg_hatched',
data={
Expand Down Expand Up @@ -256,7 +250,7 @@ def _print_eggs(self):
return

self.used_incubators.sort(key=lambda x: x.get("km"))

eggs = ['{:.2f}/{} km'.format(e['km_needed']-e['km']+self.km_walked, e['km_needed']) for e in self.used_incubators]

self.emit_event(
Expand All @@ -268,7 +262,7 @@ def _print_eggs(self):
'eggs': ', '.join(eggs)
}
)

def _should_print(self):
"""
Returns a value indicating whether the eggs should be displayed.
Expand Down
1 change: 1 addition & 0 deletions pokemongo_bot/cell_workers/update_live_stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,7 @@ def _get_stats_line(self, player_stats):

# Gather stats values.
metrics = self.bot.metrics
metrics.capture_stats()
runtime = metrics.runtime()
login = self.bot.config.username
player_data = self.bot.player_data
Expand Down
2 changes: 1 addition & 1 deletion pokemongo_bot/event_handlers/telegram_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def run(self):
"_XP:_ "+str(stats["experience"])+"/"+str(stats["next_level_xp"]),
"_Pokemons Captured:_ "+str(stats["pokemons_captured"])+" ("+str(catch_day)+" _last 24h_)",
"_Poke Stop Visits:_ "+str(stats["poke_stop_visits"])+" ("+str(ps_day)+" _last 24h_)",
"_KM Walked:_ "+str(stats["km_walked"])
"_KM Walked:_ "+str("%.2f" % stats["km_walked"])
)
self._tbot.sendMessage(chat_id=update.message.chat_id, parse_mode='Markdown', text="\n".join(res))
self._tbot.send_location(chat_id=update.message.chat_id, latitude=self.bot.api._position_lat, longitude=self.bot.api._position_lng)
Expand Down
8 changes: 7 additions & 1 deletion pokemongo_bot/inventory.py
Original file line number Diff line number Diff line change
Expand Up @@ -1178,6 +1178,7 @@ def __init__(self, bot):
self.items = Items()
self.pokemons = Pokemons()
self.player = Player(self.bot) # include inventory inside Player?
self.egg_incubators = None
self.refresh()
self.item_inventory_size = None
self.pokemon_inventory_size = None
Expand All @@ -1190,6 +1191,8 @@ def refresh(self, inventory=None):
for i in (self.pokedex, self.candy, self.items, self.pokemons, self.player):
i.refresh(inventory)

self.egg_incubators = [x["inventory_item_data"] for x in inventory if "egg_incubators" in x["inventory_item_data"]]

self.update_web_inventory()

def init_inventory_outfile(self):
Expand Down Expand Up @@ -1234,9 +1237,12 @@ def jsonify_inventory(self):
for item_id, item in self.items._data.items():
json_inventory.append({"inventory_item_data": {"item": {"item_id": item_id, "count": item.count}}})

for pokemon in self.pokemons.all():
for pokemon in self.pokemons.all_with_eggs():
json_inventory.append({"inventory_item_data": {"pokemon_data": pokemon._data}})

for inc in self.egg_incubators:
json_inventory.append({"inventory_item_data": inc})

return json_inventory

def retrieve_inventories_size(self):
Expand Down
35 changes: 13 additions & 22 deletions windows_bat/PokemonGo-Bot-Start.bat
Original file line number Diff line number Diff line change
Expand Up @@ -44,28 +44,19 @@ if '%1'=='ELEV' (del "%vbsGetPrivileges%" 1>nul 2>nul & shift /1)

:startBot
CLS
@ECHO --------------------Verifying PokemonGo-Bot version--------------------
@ECHO.
CD..
git pull
git submodule update --init --recursive
@ECHO.
@ECHO WARNING: Verify if the Config.json file got updated. If Yes, check if your modifications are still valid before proceeding.
@ECHO.
@timeout /t 10
@ECHO.
CLS
@ECHO --------------------Initializing web server--------------------
@ECHO.
@ECHO.
ECHO.
ECHO.
ECHO --------------------Initializing web server--------------------
ECHO.
ECHO.
set BatchPath="%~dp0"
start cmd.exe /k "CD %BatchPath%&CD..&CD web&python -m SimpleHTTPServer"
@ECHO.
@ECHO.
ECHO.
ECHO.
CLS
@ECHO --------------------Starting bot--------------------
@ECHO.
@ECHO.
ECHO --------------------Starting bot--------------------
ECHO.
ECHO.



Expand All @@ -88,9 +79,9 @@ goto:eof


:problem
@ECHO.
@ECHO. Something went wrong and the bot needed to be restarted. Please investigate the cause.
@ECHO.
ECHO.
ECHO. Something went wrong and the bot needed to be restarted. Please investigate the cause.
ECHO.
goto:eof


Expand Down
120 changes: 120 additions & 0 deletions windows_bat/PokemonGo-Bot-Updater.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
TITLE PokemonGo-Bot
CLS
@ECHO Off



:init
setlocal DisableDelayedExpansion
path c:\Program Files\Git\cmd;%PATH%
path C:\Python27;%PATH%
path C:\Python27\Scripts;%PATH%
SET BatPath=%~dp0
SET BotPath=%BatPath:~0,-13%
set "batchPath=%~0"
for %%k in (%0) do set batchName=%%~nk
set "vbsGetPrivileges=%temp%\OEgetPriv_%batchName%.vbs"
setlocal EnableDelayedExpansion



:checkPrivileges
NET FILE 1>NUL 2>NUL
if '%errorlevel%' == '0' ( goto gotPrivileges ) else ( goto getPrivileges )



:getPrivileges
if '%1'=='ELEV' (echo ELEV & shift /1 & goto gotPrivileges)
@ECHO Set UAC = CreateObject^("Shell.Application"^) > "%vbsGetPrivileges%"
@ECHO args = "ELEV " >> "%vbsGetPrivileges%"
@ECHO For Each strArg in WScript.Arguments >> "%vbsGetPrivileges%"
@ECHO args = args ^& strArg ^& " " >> "%vbsGetPrivileges%"
@ECHO Next >> "%vbsGetPrivileges%"
@ECHO UAC.ShellExecute "!batchPath!", args, "", "runas", 1 >> "%vbsGetPrivileges%"
"%SystemRoot%\System32\WScript.exe" "%vbsGetPrivileges%" %*
exit /B



:gotPrivileges
setlocal & pushd .
cd /d %~dp0
if '%1'=='ELEV' (del "%vbsGetPrivileges%" 1>nul 2>nul & shift /1)



:startBot
CLS
ECHO.
ECHO. --------------------Verifying PokemonGo-Bot version--------------------
ECHO.
CD..
FOR /F "usebackq" %%A IN ('%BotPath%\configs\config.json.example') DO set OldSizeNormal=%%~zA
FOR /F "usebackq" %%A IN ('%BotPath%\configs\config.json.cluster.example') DO set OldSizeCluster=%%~zA
FOR /F "usebackq" %%A IN ('%BotPath%\configs\config.json.map.example') DO set OldSizeMap=%%~zA
FOR /F "usebackq" %%A IN ('%BotPath%\configs\config.json.optimizer.example') DO set OldSizeOptimizer=%%~zA
FOR /F "usebackq" %%A IN ('%BotPath%\configs\config.json.path.example') DO set OldSizePath=%%~zA
FOR /F "usebackq" %%A IN ('%BotPath%\configs\config.json.pokemon.example') DO set OldSizePokemon=%%~zA
git pull
git submodule update --init --recursive
FOR /F "usebackq" %%A IN ('%BotPath%\configs\config.json.example') DO set SizeNormal=%%~zA
FOR /F "usebackq" %%A IN ('%BotPath%\configs\config.json.cluster.example') DO set SizeCluster=%%~zA
FOR /F "usebackq" %%A IN ('%BotPath%\configs\config.json.map.example') DO set SizeMap=%%~zA
FOR /F "usebackq" %%A IN ('%BotPath%\configs\config.json.optimizer.example') DO set SizeOptimizer=%%~zA
FOR /F "usebackq" %%A IN ('%BotPath%\configs\config.json.path.example') DO set SizePath=%%~zA
FOR /F "usebackq" %%A IN ('%BotPath%\configs\config.json.pokemon.example') DO set SizePokemon=%%~zA

CLS
ECHO.
ECHO. --------------------Verifying PokemonGo-Bot version--------------------
ECHO.
IF %OldSizeNormal% == %SizeNormal% (
ECHO.
) ELSE (
ECHO. WARNING. Check your config.json if you use config.json.example as standard config.json
ECHO.
ECHO. Changes have been made to the config.json.example, check if your modifications are still valid.
ECHO.
)
IF %OldSizeCluster% == %SizeCluster% (
ECHO.
) ELSE (
ECHO. WARNING. Check your config.json if you use config.json.cluster.example as standard config.json
ECHO.
ECHO. Changes have been made to the config.json.cluster.example, check if your modifications are still valid.
ECHO.
)
IF %OldSizeMap% == %SizeMap% (
ECHO.
) ELSE (
ECHO. WARNING. Check your config.json if you use config.json.map.example as standard config.json
ECHO.
ECHO. Changes have been made to the config.json.map.example, check if your modifications are still valid.
ECHO.
)
IF %OldSizeOptimizer% == %SizeOptimizer% (
ECHO.
) ELSE (
ECHO. WARNING. Check your config.json if you use config.json.optimizer.example as standard config.json
ECHO.
ECHO. Changes have been made to the config.json.optimizer.example, check if your modifications are still valid.
ECHO.
)
IF %OldSizePath% == %SizePath% (
ECHO.
) ELSE (
ECHO. WARNING. Check your config.json if you use config.json.path.example as standard config.json
ECHO.
ECHO. Changes have been made to the config.json.path.example, check if your modifications are still valid.
ECHO.
)
IF %OldSizePokemon% == %SizePokemon% (
ECHO.
) ELSE (
ECHO. WARNING. Check your config.json if you use config.json.pokemon.example as standard config.json
ECHO.
ECHO. Changes have been made to the config.json.pokemon.example, check if your modifications are still valid.
ECHO.
)
pause