Skip to content

Commit f10f359

Browse files
authored
Merge pull request #1 from Vanderlay/xphour-restart-process
xp/hour and restart the process if you completed all the pokestops
2 parents 0e8e67e + a364db1 commit f10f359

File tree

2 files changed

+45
-13
lines changed

2 files changed

+45
-13
lines changed

dirty.py

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,27 @@
44
import pokemon_pb2
55
import location
66
import config
7+
import main
78
from multiprocessing import Process
89

910
multi=False
1011

12+
argsStored = []
13+
startTime = time.time()
14+
accessToken=None
15+
globalltype=None
16+
17+
def restartProcess():
18+
global argsStored
19+
if accessToken is not None and globalltype is not None:
20+
start_private_show(accessToken,globalltype,argsStored.location)
21+
else:
22+
access_token,ltype=main.get_acces_token(argsStored.username,argsStored.password,argsStored.type.lower())
23+
if access_token is not None:
24+
start_private_show(access_token,ltype,argsStored.location)
25+
else:
26+
print '[-] access_token bad'
27+
1128
def start_private_show(access_token,ltype,loc):
1229
location.set_location(loc)
1330
print '[+] Token:',access_token[:40]+'...'
@@ -30,11 +47,11 @@ def split_list(a_list):
3047
half = len(a_list)/2
3148
return a_list[:half], a_list[half:]
3249

33-
def work_half_list(part,local_ses,new_rcp_point):
50+
def work_half_list(part,ses,new_rcp_point):
3451
for t in part:
3552
if config.debug:
3653
print '[!] farming pokestop..'
37-
work_with_stops(t,local_ses.ses,new_rcp_point)
54+
work_with_stops(t,ses,new_rcp_point)
3855

3956
def work_stop(local_ses,new_rcp_point):
4057
proto_all=logic.all_stops(local_ses)
@@ -82,11 +99,24 @@ def work_with_stops(current_stop,ses,new_rcp_point):
8299
print "[!] charging"
83100
elif st==1:
84101
print "[!] walking.."
102+
expPerHour()
85103
time.sleep(14)
86104
work_with_stops(current_stop,ses,new_rcp_point)
87105
else:
88106
print "[?]:",st
89107
else:
90108
print '[-] tmp_api empty'
91109
except:
92-
print '[-] error work_with_stops'
110+
print '[-] error work_with_stops - Trying to restart process'
111+
restartProcess()
112+
113+
def expPerHour():
114+
diff = time.time() - startTime
115+
minutesRun = diff/60.
116+
hoursRun = minutesRun/60.
117+
earned = float(config.earned_xp)
118+
if hoursRun > 0:
119+
expHour = int(earned/hoursRun)
120+
else:
121+
expHour = "n/a"
122+
print "[!] Gained: %s (%s exp/h)"%(config.earned_xp,expHour)

main.py

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ def get_acces_token(usr,pws,type):
3535
print '[!] I am a poketrainer..'
3636
access_token= login.login_pokemon(usr,pws)
3737
ltype='ptc'
38+
dirty.accessToken = access_token
39+
dirty.globalltype = ltype
3840
return access_token,ltype
3941

4042
def main():
@@ -50,20 +52,20 @@ def main():
5052
parser.add_argument("-t", "--type", help="Google/PTC", required=True)
5153
parser.add_argument("-l", "--location", help="Location", required=True)
5254
#parser.add_argument("-d", "--distance", help="Distance", required=True)
53-
args = parser.parse_args()
54-
if not args.username:
55-
args.username = getpass("Username: ")
56-
if not args.password:
57-
args.password = getpass("Password: ")
58-
if 'ptc' in args.type.lower() or 'goo' in args.type.lower():
59-
#config.distance=args.distance
60-
access_token,ltype=get_acces_token(args.username,args.password,args.type.lower())
55+
dirty.argsStored = parser.parse_args()
56+
if not dirty.argsStored.username:
57+
dirty.argsStored.username = getpass("Username: ")
58+
if not dirty.argsStored.password:
59+
dirty.argsStored.password = getpass("Password: ")
60+
if 'ptc' in dirty.argsStored.type.lower() or 'goo' in dirty.argsStored.type.lower():
61+
#config.distance=dirty.argsStored.distance
62+
access_token,ltype=get_acces_token(dirty.argsStored.username,dirty.argsStored.password,dirty.argsStored.type.lower())
6163
if access_token is not None:
62-
dirty.start_private_show(access_token,ltype,args.location)
64+
dirty.start_private_show(access_token,ltype,dirty.argsStored.location)
6365
else:
6466
print '[-] access_token bad'
6567
else:
66-
print '[!] used type "%s" only Google or PTC valid'%(args.type.lower())
68+
print '[!] used type "%s" only Google or PTC valid'%(dirty.argsStored.type.lower())
6769

6870
if __name__ == '__main__':
6971
main()

0 commit comments

Comments
 (0)