forked from jagauthier/whserver
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_webhook.py
executable file
·215 lines (178 loc) · 7.2 KB
/
test_webhook.py
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
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
#!/usr/bin/env python
from base64 import b64encode
import string
import random
import time
import requests
from optparse import OptionParser
UNOWN = 201
def get_pokemon(options):
lst = [random.choice(
string.ascii_letters + string.digits) for n in xrange(16)]
encounter = b64encode("".join(lst))
spawnpoint = [random.choice(
string.ascii_letters + string.digits) for n in xrange(12)]
spawnpoint = "".join(spawnpoint)
despawn = random.randint(15 * 60, 60 * 60)
location = options.location.split(",")
variance = options.variance
pokemon = {
'encounter_id': encounter,
'spawnpoint_id': spawnpoint,
'disappear_time': int(time.time()) + despawn,
'gender': random.randint(1, 2),
'height': random.random(),
'individual_attack': random.randint(0, 15),
'individual_defense': random.randint(0, 15),
'individual_stamina': random.randint(0, 15),
'last_modified_time': int(time.time() * 1000) + 3600,
'latitude': float(
location[0]) + random.uniform(0 - variance, variance),
'longitude': float(
location[1]) + random.uniform(0 - variance, variance),
'move_1': random.randint(1, 137),
'move_2': random.randint(200, 281),
'pokemon_id': random.randint(1, 251),
'seconds_until_despawn': despawn,
'spawn_start': random.randint(500, 3000),
'spawn_end': random.randint(500, 3000),
'time_until_hidden_ms': int(time.time() * 1000) + 7200,
'verified': True,
'weight': random.uniform(5, 15)
}
if pokemon['pokemon_id'] == UNOWN:
pokemon.update({'form': random.randint(1, 26)})
return pokemon
def get_pokestop(options):
lst = [random.choice(string.ascii_letters + string.digits)
for n in xrange(16)]
id = b64encode("".join(lst))
location = options.location.split(",")
variance = options.variance
pokestop = {
'last_modified_time': int(time.time() +
random.randint(-3600, 0)) * 1000,
'lure_expiration': None,
'active_fort_modifier': None,
'latitude': float(
location[0]) + random.uniform(0 - variance, variance),
'longitude': float(
location[1]) + random.uniform(0 - variance, variance),
'enabled': True,
'pokestop_id': id
}
return pokestop
def get_gymdetails(gym):
adj = ["Decorative", "Beautiful", "Fancy", "Groovy", "Wonderful"]
name = ["store", "bridge", "walkway", "mural", "church", "park"]
trainer_names = ["anthonycelaya", "AnthonyTrain51", "AoifeHehewut",
"ApertureMik3", "Apocryphal62", "APoorLoser",
"APsczulkoski", "ArachnidDeat", "Archercoebhan",
"Arcteryx65", "ArekMarr", "arielitus", "Aristotol",
"Arshaa", "arunns", "AshCaughtEm42", "AsherTrasherMan"]
gymdetails = {
'name': random.choice(adj) + " " + random.choice(name),
'description': "There really isn't a description",
'id': gym['gym_id'],
'team': gym['team_id'],
'latitude': gym['latitude'],
'longitude': gym['latitude'],
'url': 'http://lh6.ggpht.com/Iiipbi8mrGZf5VFnPJa7ff5kvi40' +
'BdBLyfvE0Vq1tdjsbOnDLm2HKP0JCAwJgs7CDahZd3KIV5M72WyImY4J',
}
gym_pokes = []
for i in range(1, 10):
gym_pokes.append(
{'additional_cp_multiplier': random.random(),
'cp': random.randint(500, 3000),
'cp_multiplier': random.random(),
'height': random.random(),
'iv_attack': random.randint(0, 15),
'iv_defense': random.randint(0, 15),
'iv_stamina': random.randint(0, 15),
'move_1': random.randint(1, 137),
'move_2': random.randint(200, 281),
'pokemon_id': random.randint(1, 251),
'weight': random.uniform(5, 15),
'num_upgrades': random.randint(1, 5),
'stamina': random.randint(100, 281),
'stamina_max': random.randint(1, 281),
'trainer_level': random.randint(1, 40),
'pokemon_uid': random.randint(10000, 20000),
'trainer_name': random.choice(trainer_names)
})
gymdetails.update({'pokemon': gym_pokes})
return gymdetails
def get_gym(options):
lst = [random.choice(string.ascii_letters + string.digits)
for n in xrange(16)]
id = b64encode("".join(lst))
location = options.location.split(",")
variance = options.variance
gym = {
'gym_id': id,
'team_id': random.randint(1, 3),
'guard_pokemon_id': random.randint(1, 251),
'gym_points': random.randint(1000, 50000),
'enabled': 1,
'latitude': float(
location[0]) + random.uniform(0 - variance, variance),
'longitude': float(
location[1]) + random.uniform(0 - variance, variance),
'last_modified': int(time.time() + random.randint(-3600, 0)) * 1000
}
return gym
def process_post(message, payload, options):
data = {
'type': message,
'message': payload
}
requests.post(options.webhook_url, json=data, headers={
'Content-Type': 'application/json'})
if __name__ == '__main__':
parser = OptionParser()
parser.add_option("-i", "--iterations", type="int",
dest="iterations", default=1,
help="Iterations to process.")
parser.add_option("-m", "--minutes",
dest="minutes", type="int",
help="Minutes to run.")
parser.add_option("-w", "--webhook", dest="webhook_url",
help="Webhook url")
parser.add_option("-l", "--location", dest="location",
help="Location")
parser.add_option("-v", "--variance", dest="variance",
default=.2000, type="float",
help="Location variance")
parser.add_option("-d", "--delay", dest="delay",
default=.05, type="float",
help="delay between sends")
(options, args) = parser.parse_args()
if not options.webhook_url or not options.location:
print "Webhook url and location are required."
parser.print_help()
exit(0)
start = time.time()
i = 0
while i < options.iterations:
pokemon = get_pokemon(options)
process_post('pokemon', pokemon, options)
# below here, these are pokestop, and gyms.
# The intent is that when you run this for thousands
# you will only get some of these.
if random.randint(0, 1000) > 990:
pokestop = get_pokestop(options)
process_post('pokestop', pokestop, options)
if random.randint(0, 1000) > 999:
gym = get_gym(options)
gymdetails = get_gymdetails(gym)
process_post('gym', gym, options)
process_post('gym_details', gymdetails, options)
if options.minutes:
# reset the iterations, we basically ignore it
if time.time() - start > options.minutes * 60:
break
else:
i += 1
# just a gentle pause
time.sleep(options.delay)