This repository has been archived by the owner on Oct 19, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 30
/
tapswap.py
352 lines (273 loc) · 12.3 KB
/
tapswap.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
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
import requests
import urllib.parse
import json
import time
import random
import cloudscraper
import sys
import js2py
from bs4 import BeautifulSoup
from BypassTLS import BypassTLSv1_3
class TapSwap:
def __init__(self, url: str, chq_bypass, auto_upgrade:bool, max_charge_level:int, max_energy_level:int, max_tap_level:int):
if auto_upgrade:
self.max_charge_level = max_charge_level
self.max_energy_level = max_energy_level
self.max_tap_level = max_tap_level
else:
self.max_charge_level = 1
self.max_energy_level = 1
self.max_tap_level = 1
self.webappurl = url
self.init_data = urllib.parse.unquote(url).split('tgWebAppData=')[1].split('&tgWebAppVersion')[0]
self.x_cv = "617"
self.access_token = ""
self.chq_bypass = chq_bypass
self.headers = {
"accept": "*/*",
"accept-language": "en-US,en;q=0.9,fa;q=0.8",
"content-type": "application/json",
"sec-fetch-dest": "empty",
"sec-fetch-mode": "cors",
"sec-fetch-site": "same-site",
"user-agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 13; iPhone 15 Pro Max) AppleWebKit/533.2 (KHTML, like Gecko) Version/122.0 Mobile/15E148 Safari/533.2"
}
self.headers_requests = self.headers.copy()
self.headers_requests.update({
"Authorization": f"Bearer {self.access_token}",
"x-cv": self.x_cv,
"X-App": "tapswap_server",
"x-bot": "no",
})
self.session = requests.Session()
self.session.mount("https://", BypassTLSv1_3())
self.prepare_prerequisites()
def prepare_prerequisites(self):
uph = self.update_headers()
if uph == False:
print("[!] We ran into trouble with the updates to the headers! 🚫 The script is stopping.")
sys.exit()
atk = self.get_auth_token()
if atk == False:
print("[!] We ran into trouble with the get auth token! 🚫 The script is stopping.")
sys.exit()
def extract_chq_result(self, chq):
return self.chq_bypass(chq)
def get_auth_token(self):
payload = {
"init_data": self.init_data,
"referrer": ""
}
maxtries = 5
while maxtries >= 0:
try:
response = self.session.post(
'https://api.tapswap.ai/api/account/login',
headers=self.headers,
data=json.dumps(payload)
).json()
if 'wait_s' in response:
sleep_time = response["wait_s"]
if sleep_time > 70:
maxtries += 1
continue
time.sleep(sleep_time/10)
continue
if 'chq' in response:
chq_result = self.extract_chq_result(response['chq'])
payload['chr'] = chq_result
print("[~] ByPass CHQ: ", chq_result)
response = requests.post(
'https://api.tapswap.ai/api/account/login',
headers=self.headers,
data=json.dumps(payload)
).json()
if not 'access_token' in response:
print('[!] There is no access_token in response')
continue
self.client_id = response['player']['id']
self.headers_requests['Authorization'] = f"Bearer {response['access_token']}"
self.balance = response['player']['shares']
energy_level = response['player']['energy_level']
charge_level = response['player']['charge_level']
self._time_to_recharge = (energy_level*500) / charge_level
try:
self.check_update(response)
except Exception as e:
print('[!] Error in upgrade: ', e)
return response['access_token']
except Exception as e:
print("[!] Error in auth:", e)
time.sleep(3)
finally:
maxtries -=1
return False
def update_headers(self):
maxtries = 5
while maxtries >= 0:
try:
headers = {
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Safari/537.36"
}
session = requests.Session()
session.mount("https://", BypassTLSv1_3())
session.headers = headers
scraper = cloudscraper.create_scraper(sess=session)
headers_json = scraper.get(f'https://poeai.click/tapswap/headers.json').json()
if 'dont_run_code' in headers_json:
continue
self.headers.update(headers_json['login'])
self.headers_requests.update(headers_json['send_tap'])
print(self.headers_requests)
return self.headers_requests
except Exception as e:
print("[!] Error in update headers:", e)
time.sleep(3)
finally:
maxtries -= 1
return False
def check_update(self, response):
charge_level = response['player']['charge_level']
energy_level = response['player']['energy_level']
tap_level = response['player']['tap_level']
shares = response['player']['shares']
if charge_level < self.max_charge_level:
price = 0
while shares >= price:
for item in response['conf']['charge_levels']:
if item['rate'] == charge_level + 1:
price = item['price']
if price > shares or charge_level >= self.max_charge_level:
break
print('[+] Updating Charge Level')
self.upgrade_boost('charge')
shares -= price
charge_level += 1
if energy_level < self.max_energy_level:
price = 0
while shares >= price:
for item in response['conf']['energy_levels']:
if item['limit'] == (energy_level + 1)*500:
price = item['price']
if price > shares or energy_level >= self.max_energy_level:
break
print('[+] Updating energy')
self.upgrade_boost('energy')
shares -= price
energy_level += 1
if tap_level < self.max_tap_level:
price = 0
while shares >= price:
for item in response['conf']['tap_levels']:
if item['rate'] == tap_level + 1:
price = item['price']
if price > shares or tap_level >= self.max_tap_level:
break
print('[+] Updating taps')
self.upgrade_boost('tap')
shares -= price
tap_level += 1
def tap_stats(self):
response = self.session.get(
'https://api.tapswap.ai/api/stat',
headers=self.headers_requests,
).json()
return response
def upgrade_boost(self, boost_type: str = "energy"):
payload = {"type": boost_type}
response = self.session.post(
'https://api.tapswap.ai/api/player/upgrade',
headers=self.headers_requests,
json=payload
).json()
return response
def apply_boost(self, boost_type: str = "energy"):
payload = {"type": boost_type}
response = self.session.post(
'https://api.tapswap.ai/api/player/apply_boost',
headers=self.headers_requests,
json=payload
).json()
return response
def submit_taps(self, taps: int = 1):
o = int(time.time() * 1000)
result = o * self.client_id
result = result * self.client_id
result = result / self.client_id
result = result % self.client_id
result = result % self.client_id
content_id = int(result)
payload = {"taps": taps, "time": o}
self.headers_requests['Content-Id'] = str(content_id)
while True:
try:
response = self.session.post(
'https://api.tapswap.ai/api/player/submit_taps',
headers=self.headers_requests,
json=payload
).json()
return response
except Exception as e:
print("[!] Error in Tapping:", e)
time.sleep(1)
def sleep_time(self, num_clicks):
time_to_sleep = 0
for _ in range(num_clicks):
time_to_sleep += random.uniform(0.1, 0.7)
return time_to_sleep
def click_turbo(self):
xtap = self.submit_taps(random.randint(60, 70))
for boost in xtap['player']['boost']:
if boost['type'] == 'turbo' and boost['end'] > time.time():
for i in range(random.randint(3, 7)):
taps = random.randint(84, 86)
sleepTime = self.sleep_time(taps)
print(f'[~] Sleeping {sleepTime/6} for next tap.')
time.sleep(sleepTime/6)
print(f'[+] Turbo: {taps} ...')
xtap = self.submit_taps(taps)
shares = xtap['player']['shares']
print(f'[+] Balance : {shares}')
self.balance = shares
if boost['cnt'] > 0:
print('[+] Activing Turbo ...')
self.apply_boost("turbo")
self.click_turbo()
def click_all(self):
self.prepare_prerequisites()
xtap = self.submit_taps(random.randint(1, 10))
energy = xtap['player']['energy']
tap_level = xtap['player']['tap_level']
energy_level = xtap['player']['energy_level']
charge_level = xtap['player']['charge_level']
shares = xtap['player']['shares']
while energy > tap_level*3:
maxClicks = min([round(energy/tap_level)-1, random.randint(66, 84)])
if maxClicks > 1:
sleepTime = self.sleep_time(maxClicks)
print(f'[~] Sleeping {sleepTime} for next tap.')
time.sleep(sleepTime)
xtap = self.submit_taps(maxClicks)
energy = xtap['player']['energy']
tap_level = xtap['player']['tap_level']
shares = xtap['player']['shares']
print(f'[+] Balance : {shares}')
self.balance = shares
else:
break
for boost in xtap['player']['boost']:
if boost['type'] == 'energy' and boost['cnt'] > 0:
print('[+] Activing Full Tank ...')
self.apply_boost()
self.click_all()
if boost['type'] == 'turbo' and boost['cnt'] > 0:
print('[+] Activing Turbo ...')
self.apply_boost("turbo")
self.click_turbo()
time_to_recharge = ((energy_level*500)-energy) / charge_level
return time_to_recharge
def shares(self):
return self.balance
def time_to_recharge(self):
return self._time_to_recharge + random.randint(60*2, 60*12)