FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
RocketMap/tools/levelup.py at develop · RocketMap/RocketMap · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
RocketMap
/
RocketMap
Public
Notifications
You must be signed in to change notification settings
Fork
1.4k
Star
2.8k
Code
Issues
34
Pull requests
31
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
RocketMap
/
tools
/
levelup.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
196 lines (154 loc) · 5.68 KB
Breadcrumbs
RocketMap
/
tools
/
levelup.py
Copy path
File metadata and controls
196 lines (154 loc) · 5.68 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
#!/usr/bin/python
# -*- coding: utf-8 -*-
import
os
import
sys
import
logging
import
time
from
threading
import
Thread
from
queue
import
Queue
,
Empty
from
enum
import
Enum
sys
.
path
.
append
(
'.'
)
from
pogom
.
schedulers
import
KeyScheduler
# noqa: E402
from
pogom
.
account
import
(
check_login
,
setup_api
,
pokestop_spinnable
,
spin_pokestop
,
TooManyLoginAttempts
)
# noqa: E402
from
pogom
.
utils
import
get_args
,
gmaps_reverse_geolocate
# noqa: E402
from
pogom
.
apiRequests
import
(
get_map_objects
as
gmo
,
AccountBannedException
)
# noqa: E402
from
runserver
import
(
set_log_and_verbosity
,
startup_db
,
extract_coordinates
)
# noqa: E402
from
pogom
.
proxy
import
initialize_proxies
# noqa: E402
from
pogom
.
models
import
PlayerLocale
# noqa: E402
class
FakeQueue
:
def
put
(
self
,
something
):
pass
class
ErrorType
(
Enum
):
generic
=
1
captcha
=
2
no_stops
=
3
banned
=
4
login_error
=
5
def
get_location_forts
(
api
,
account
,
location
):
response
=
gmo
(
api
,
account
,
location
)
if
len
(
response
[
'responses'
][
'CHECK_CHALLENGE'
].
challenge_url
)
>
1
:
log
.
error
(
'account: %s got captcha: %s'
,
account
[
'username'
],
response
[
'responses'
][
'CHECK_CHALLENGE'
].
challenge_url
)
return
(
ErrorType
.
captcha
,
None
)
cells
=
response
[
'responses'
][
'GET_MAP_OBJECTS'
].
map_cells
forts
=
[]
for
cell
in
cells
:
for
fort
in
cell
.
forts
:
# Only use Pokestops.
if
fort
.
type
==
1
:
forts
.
append
(
fort
)
if
not
forts
:
return
(
ErrorType
.
no_stops
,
None
)
return
(
None
,
forts
)
def
level_up_account
(
args
,
location
,
accounts
,
errors
):
while
True
:
try
:
# Loop the queue.
try
:
(
account
,
error_count
)
=
accounts
.
get
(
False
)
except
Empty
:
break
log
.
info
(
'Starting account %s'
,
account
[
'username'
])
status
=
{
'type'
:
'Worker'
,
'message'
:
'Creating thread...'
,
'success'
:
0
,
'fail'
:
0
,
'noitems'
:
0
,
'skip'
:
0
,
'captcha'
:
0
,
'username'
:
''
,
'proxy_display'
:
None
,
'proxy_url'
:
None
,
}
api
=
setup_api
(
args
,
status
,
account
)
key
=
key_scheduler
.
next
()
api
.
set_position
(
*
location
)
api
.
activate_hash_server
(
key
)
check_login
(
args
,
account
,
api
,
status
[
'proxy_url'
])
log
.
info
(
'Logged in account %s, level %d.'
,
account
[
'username'
],
account
[
'level'
])
(
error
,
forts
)
=
get_location_forts
(
api
,
account
,
location
)
if
error
:
errors
[
error
].
append
(
account
)
accounts
.
task_done
()
continue
spinnable_pokestops
=
filter
(
lambda
fort
:
pokestop_spinnable
(
fort
,
location
),
forts
)
# No stops in spin range.
first_fort
=
forts
[
0
]
if
not
spinnable_pokestops
:
log
.
critical
(
'No Pokestops in spinnable range. Please move'
" the location. There's a Pokestop at"
' %s, %s.'
,
first_fort
.
latitude
,
first_fort
.
longitude
)
os
.
_exit
(
1
)
# Past this point, guaranteed to have a spinnable stop.
fort
=
spinnable_pokestops
[
0
]
spin_pokestop
(
api
,
account
,
args
,
fort
,
location
)
log
.
info
(
'Spun Pokestop with account %s, level %d.'
,
account
[
'username'
],
account
[
'level'
])
except
TooManyLoginAttempts
:
errors
[
ErrorType
.
login_error
].
append
(
account
)
except
AccountBannedException
:
errors
[
ErrorType
.
banned
].
append
(
account
)
except
Exception
as
e
:
if
error_count
<
2
:
log
.
exception
(
'Exception in worker: %s. Retrying.'
,
e
)
accounts
.
put
((
account
,
error_count
+
1
))
else
:
errors
[
ErrorType
.
generic
].
append
(
account
)
accounts
.
task_done
()
log
=
logging
.
getLogger
()
set_log_and_verbosity
(
log
)
args
=
get_args
()
# Abort if we don't have a hash key set.
if
not
args
.
hash_key
:
log
.
critical
(
'Hashing key is required. Exiting.'
)
sys
.
exit
(
1
)
fake_queue
=
FakeQueue
()
key_scheduler
=
KeyScheduler
(
args
.
hash_key
,
fake_queue
)
position
=
extract_coordinates
(
args
.
location
)
args
.
player_locale
=
PlayerLocale
.
get_locale
(
args
.
location
)
if
not
args
.
player_locale
:
args
.
player_locale
=
gmaps_reverse_geolocate
(
args
.
gmaps_key
,
args
.
locale
,
str
(
position
[
0
])
+
', '
+
str
(
position
[
1
]))
startup_db
(
None
,
args
.
clear_db
)
initialize_proxies
(
args
)
account_queue
=
Queue
()
errors
=
{}
for
error
in
ErrorType
:
errors
[
error
]
=
[]
for
account
in
args
.
accounts
:
account_queue
.
put
((
account
,
0
))
for
i
in
range
(
0
,
args
.
workers
):
log
.
debug
(
'Starting level-up worker thread %d...'
,
i
)
t
=
Thread
(
target
=
level_up_account
,
name
=
'worker-{}'
.
format
(
i
),
args
=
(
args
,
position
,
account_queue
,
errors
))
t
.
daemon
=
True
t
.
start
()
try
:
while
True
:
if
account_queue
.
unfinished_tasks
>
0
:
time
.
sleep
(
1
)
else
:
break
except
KeyboardInterrupt
:
log
.
info
(
'Process killed.'
)
exit
(
1
)
account_queue
.
join
()
log
.
info
(
'Process finished.'
)
for
error_type
in
ErrorType
:
if
len
(
errors
[
error_type
])
>
0
:
log
.
warning
(
'Some accounts did not finish properly (%s):'
,
error_type
.
name
)
for
account
in
errors
[
error_type
]:
log
.
warning
(
'
\t
%s'
,
account
[
'username'
])
Back
|
FazBrowse Home
|
New Git URL