Skip to content

Commit

Permalink
Merge pull request #1 from PokemonGoF/dev
Browse files Browse the repository at this point in the history
Rebase from Mian
  • Loading branch information
MerlionRock authored Jul 31, 2017
2 parents 474a511 + ecf4f9e commit 9130291
Show file tree
Hide file tree
Showing 12 changed files with 77 additions and 50 deletions.
49 changes: 36 additions & 13 deletions MultiBot.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,14 @@ def getProxy():
if proxyCur >= proxyNum:
proxyCur = 0
headers = {'user-agent': 'Niantic App'}
if requests.get('https://pgorelease.nianticlabs.com/plfe/', headers=headers, proxies=proxies).status_code == 200:
if requests.get('https://pgorelease.nianticlabs.com/plfe/', headers=headers, proxies=proxies, timeout=15).status_code == 200:
headers = {'user-agent': 'pokemongo/1 CFNetwork/758.5.3 Darwin/15.6.0'}
if requests.get('https://sso.pokemon.com/', headers=headers, proxies=proxies).status_code == 200:
if requests.get('https://sso.pokemon.com/', headers=headers, proxies=proxies, timeout=15).status_code == 200:
return proxy
else:
Lprint ("Proxy is Banned")
Lprint ("Proxy {} is Banned or offline".format(proxy))
else:
Lprint ("Proxy is Banned")
Lprint ("Proxy {} is Banned or offline".format(proxy))

except Exception as e:
Lprint (e)
Expand Down Expand Up @@ -147,13 +147,37 @@ def MakeConf(CurThread, username, password):
stop()
except:
jsonData.items().append("{u'websocket':,{u'server_url': u'" + MultiBotConfig[u'WebSocket'][u'IP'] + ":" + str(MultiBotConfig[u'WebSocket'][u'Port'] + CurThread) + "u'start_embedded_server': True}")



elif not MultiBotConfig[u'WebSocket'][u'start_embedded_server']:
try:
del jsonData[u'websocket']
except KeyboardInterrupt:
stop()
except:
pass
if MultiBotConfig[u'TelegramTask']:
try:
for i in range(len(jsonData[u'tasks'])):
if jsonData[u'tasks'][1][u'type'] == u'TelegramTask':
jsonData[u'tasks'][i][u'config'][u'enabled'] = True
except KeyboardInterrupt:
stop()
except:
pass

if not MultiBotConfig[u'TelegramTask']:
try:
for i in range(len(jsonData[u'tasks'])):
if jsonData[u'tasks'][1][u'type'] == u'TelegramTask':
jsonData[u'tasks'][i][u'config'][u'enabled'] = False
except KeyboardInterrupt:
stop()
except:
pass

with open('configs/temp/config-' + str(CurThread) + '.json', 'w') as s:
s.write(json.dumps(jsonData))
s.close()

except IOError:
Lprint ('config file error')
time.sleep(30)
Expand Down Expand Up @@ -181,15 +205,14 @@ def run(self):
Lprint ('Thread-{0} using account {1}'.format(self.CurThread, self.username))
try:
MakeConf(self.CurThread, self.username, self.password)
StartCmd = "python pokecli.py -af configs/temp/auth-{0}.json -cf configs/temp/config-{0}.json --walker_limit_output {1}".format(self.CurThread, MultiBotConfig[u'walker_limit_output'])
if MultiBotConfig[u'UseProxy']:
self.proxy = getProxy()
if platform.system() == "Linux":
self.os.system('export HTTP_PROXY="http://' + proxy + '"; export HTTPS_PROXY="https://' + proxy + '"')
os.system('export HTTP_PROXY="http://' + proxy + '"; export HTTPS_PROXY="https://' + proxy + '"; ' + StartCmd)
if platform.system() == "Windows":
self.os.system('')
os.system(
"python pokecli.py -af configs/temp/auth-{0}.json -cf configs/temp/config-{0}.json --walker_limit_output {1}".format(
self.CurThread, MultiBotConfig[u'walker_limit_output']))
os.system('set HTTP_PROXY="http://' + proxy + '" & set HTTPS_PROXY="https://' + proxy + '" & ' + StartCmd)
os.system(StartCmd)
except Exception as e:
import traceback
Lprint ((e))
Expand Down
5 changes: 5 additions & 0 deletions configs/MultiBotConfig.json.example
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
{
"Threads": "set it to (account number / 2)",
"Threads": 2,
"HashKeyFile": "MultiBotConfigHashkey.txt",
"UseProxy": false,
"ProxyFile": "MultiBotConfigProxy.txt",
"AccountsFile": "MultiBotConfigAccounts.txt",
"AuthJsonFile": "auth.json",
"ConfigJsonFile": "config.json",
"CompleteTutorialNickName": "set to true to use login as username",
"CompleteTutorialNickName": true,
"TelegramTask": "should be false or Telegram maybe crash the bot",
"TelegramTask": false,
"WebSocket": {
"start_embedded_server": false,
"IP": "127.0.0.1",
"Port": 4000
},
"walker_limit_output": "set to true to reduce spam in console",
"walker_limit_output": true
}
2 changes: 1 addition & 1 deletion data/items.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,5 @@
"1301": "Rare Candy",
"1401": "Free Raid Ticket",
"1402": "Paid Raid Ticket",
"1403": "Legendart Raid Ticket"
"1403": "Legendary Raid Ticket"
}
7 changes: 3 additions & 4 deletions docs/manual_installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ rm -f get-pip.py

(Please keep in mind that `master` is stable and tested but `dev` is bleeding edge. In the installation note below change `master` to `dev` if you want to get and use the latest version.)
```bash
git clone --recursive -b master https://github.com/PokemonGoF/PokemonGo-Bot
git clone --recursive -b master https://github.com/PokemonGoF/PokemonGo-Bot.git
cd PokemonGo-Bot
```

Expand All @@ -73,15 +73,14 @@ source bin/activate
- install the requirements
```bash
pip install -r requirements.txt
make
cd ../../
```

####

- copy and edit the config
(after copying it you can use any editor you like if you don't like `vi`)
```bash
cd ../PokemonGo-Bot/configs/
cp configs/config.json.example configs/config.json
vi configs/config.json
cp configs/auth.json.example configs/auth.json
Expand Down Expand Up @@ -132,7 +131,7 @@ cd C:\Python27\
pip install --upgrade pip
cd ..
cd to PokemonGo-Bot directory
git clone --recursive -b dev https://github.com/PokemonGoF/PokemonGo-Bot
git clone --recursive -b dev https://github.com/PokemonGoF/PokemonGo-Bot.git
pip install --upgrade -r requirements.txt
git pull
cd web
Expand Down
3 changes: 3 additions & 0 deletions pokemongo_bot/cell_workers/buddy_pokemon.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,9 @@ def work(self):
if not self.buddy:
return WorkerResult.SUCCESS

if not self.buddy.has_key('last_km_awarded'):
self.buddy['last_km_awarded'] = 0

if self._km_walked() - self.buddy['last_km_awarded'] >= self.buddy_distance_needed:
self.buddy['last_km_awarded'] += self.buddy_distance_needed
if not self._get_award():
Expand Down
16 changes: 8 additions & 8 deletions pokemongo_bot/cell_workers/complete_tutorial.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,19 +113,19 @@ def _encounter_tutorial(self):
def _random_avatar(self):
avatar= {}
# 0 = Male, 1 = Female
avatar['gender']=random.randint(0,1)
avatar['avatar']=random.randint(0,1)
# What is the max value of each parameter ?
# Default is 0, anyway human player will stop
# at the first choices in general, so fully
# random on the whole avatar space is not the way to go either
avatar['skin']=random.randint(0,3)
avatar['avartar_hair']=random.randint(0,3)
avatar['avartar_shirt']=random.randint(0,3)
avatar['avartar_pants']=random.randint(0,3)
avatar['avartar_hat']=random.randint(0,3)
avatar['avartar_shoes']=random.randint(0,3)
avatar['avartar_eyes']=random.randint(0,3)
avatar['avartar_backpack']=random.randint(0,3)
avatar['hair']=random.randint(0,3)
avatar['shirt']=random.randint(0,3)
avatar['pants']=random.randint(0,3)
avatar['hat']=random.randint(0,3)
avatar['shoes']=random.randint(0,3)
avatar['eyes']=random.randint(0,3)
avatar['backpack']=random.randint(0,3)
return avatar

def _set_avatar(self):
Expand Down
22 changes: 11 additions & 11 deletions pokemongo_bot/cell_workers/move_to_fort.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ def work(self):
moving = noised_dist > Constants.MAX_DISTANCE_FORT_IS_REACHABLE if self.bot.config.replicate_gps_xy_noise else dist > Constants.MAX_DISTANCE_FORT_IS_REACHABLE

distance_to_target = int(noised_dist if self.bot.config.replicate_gps_xy_noise else dist)

if len(self.previous_distance) == 0:
self.previous_distance.append(distance_to_target)
elif self.target_id is not fort_name:
Expand All @@ -86,15 +87,16 @@ def work(self):
if self.walker is not self.config.get('walker', 'StepWalker'):
self.walker = self.config.get('walker', 'StepWalker')
else:
# self.logger.info("Previous distances: %s" % self.previous_distance)
if len(self.previous_distance) > 5:
self.previous_distance.pop(0)
error_moving = False
times_found = 0
for prev_distance in self.previous_distance:
if prev_distance == distance_to_target:
error_moving = True
break
if len(self.previous_distance) < 10:
self.previous_distance.append(distance_to_target) # collect more previous distance data
error_moving = False
else:
if sum(self.previous_distance[0:5]) <= sum(self.previous_distance[5:10]):
error_moving = True # if previous distance data trend is increasing we're stuck
else:
self.previous_distance.pop(0)
self.previous_distance.append(distance_to_target) # collect more previous distance data
error_moving = False

if error_moving:
if self.walker == 'StepWalker':
Expand All @@ -105,8 +107,6 @@ def work(self):
self.logger.info("Having difficulty walking to %s. Changing walker." % fort_name)
self.walker = 'StepWalker'
self.previous_distance = [distance_to_target]
else:
self.previous_distance.append(distance_to_target)

if moving:
self.wait_log_sent = None
Expand Down
3 changes: 1 addition & 2 deletions runMultiBot.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ then
fi
git fetch -a
installed=(`pip list 2>/dev/null |sed -e 's/ //g' -e 's/(/:/' -e 's/)//' -e 's/[-_]//g' | awk '{print tolower($0)}'`)
required=(`cat requirements.txt | sed -e 's/.*pgoapi$/pgoapi==1.2.0/' -e 's/[-_]//g' -e 's/==\(.*\)/:\1/' | awk '{print tolower($0)}'`)
required=(`cat requirements.txt | sed -e 's/.*pgoapi$/pgoapi==1.2.1/' -e 's/[-_]//g' -e 's/==\(.*\)/:\1/' | awk '{print tolower($0)}'`)
for package in ${required[@]}
do
if [[ ! (${installed[*]} =~ $package) ]];
Expand All @@ -31,5 +31,4 @@ then
fi
fi
python MultiBot.py
done
exit 0
3 changes: 3 additions & 0 deletions setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,12 @@ Configure userdata.js for web
"
read -p "Input E-Mail (Google) or Username (PTC)
" webusername
read -p "Input Friendly Name For Your Bot (Name you want bot to show up as on the map)
" webfriendlyname
read -p "Input Google API Key (gmapkey)
" webgmapkey
sed -e "s/username1/$webusername/g" -e "s/YOUR_API_KEY_HERE/$webgmapkey/g" \
-e "s/FriendlyName1/$webfriendlyname/g" \
config/userdata.js.example > config/userdata.js
echo "Your userdata.js is now configured."
else
Expand Down
2 changes: 1 addition & 1 deletion web
2 changes: 2 additions & 0 deletions windows_bat/PokemonGo-Bot-Configurator.bat
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,8 @@ ECHO. users: [{>>%UserData%
ECHO. enable: true,>>%UserData%
Set /p users="What's the username to use ?: "
ECHO. username: "%users%",>>%UserData%
Set /p friendlyname="What's the friendly/display name to use ?: "
ECHO. alias: "%friendlyname%",>>%UserData%
ECHO. socketAddress: "127.0.0.1:4000",>>%UserData%
ECHO. enableSocket: true>>%UserData%
ECHO. }],>>%UserData%
Expand Down
13 changes: 3 additions & 10 deletions windows_bat/PokemonGo-Bot-MultiBot-Start.bat
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,10 @@ if '%1'=='ELEV' (del "%vbsGetPrivileges%" 1>nul 2>nul & shift /1)


:startBot
REM CLS
REM ECHO.
REM ECHO.
REM ECHO --------------------Initializing web server--------------------
REM ECHO.
REM ECHO.
REM set BatchPath="%~dp0"
REM start cmd.exe /k "CD %BatchPath%&CD..&CD web&python -m SimpleHTTPServer"
REM ECHO.
REM ECHO.
CLS
set BatchPath="%~dp0"
ECHO.
ECHO.
ECHO --------------------Starting bot--------------------
ECHO.
ECHO.
Expand Down

0 comments on commit 9130291

Please sign in to comment.