This repository has been archived by the owner on Aug 7, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathbot.py
342 lines (300 loc) · 12.7 KB
/
bot.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
import os
import sys
import json
import time
import hmac
import hashlib
import argparse
import requests
from colorama import *
from datetime import datetime, timezone
from urllib.parse import unquote, quote, parse_qs
init(autoreset=True)
merah = Fore.LIGHTRED_EX
hijau = Fore.LIGHTGREEN_EX
kuning = Fore.LIGHTYELLOW_EX
biru = Fore.LIGHTBLUE_EX
hitam = Fore.LIGHTBLACK_EX
reset = Style.RESET_ALL
putih = Fore.LIGHTWHITE_EX
class Data:
def __init__(self, init_data, userid, username, secret):
self.init_data = init_data
self.userid = userid
self.username = username
self.secret = secret
class PixelTapTod:
def __init__(self):
self.base_headers = {
"Accept": "application/json, text/plain, */*",
"Accept-Language": "en,en-US;q=0.9",
"Host": "api-clicker.pixelverse.xyz",
"X-Requested-With": "org.telegram.messenger",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:125.0) Gecko/20100101 Firefox/125.0",
}
self.marin_kitagawa = lambda data: {
key: value[0] for key, value in parse_qs(data).items()
}
def get_secret(self, userid):
rawr = "adwawdasfajfklasjglrejnoierjboivrevioreboidwa"
secret = hmac.new(
rawr.encode("utf-8"), str(userid).encode("utf-8"), hashlib.sha256
).hexdigest()
return secret
def data_parsing(self, data):
redata = {}
for i in unquote(data).split("&"):
key, value = i.split("=")
redata[key] = value
return redata
def get_me(self, data: Data):
url = "https://api-clicker.pixelverse.xyz/api/users"
headers = self.base_headers.copy()
headers["initData"] = data.init_data
headers["secret"] = data.secret
headers["tg-id"] = data.userid
if data.username is not None:
headers["username"] = data.username
while True:
res = self.http(url, headers)
balance = res.json().get("clicksCount", None)
if balance is None:
self.log(f"{kuning}failed fetch balance !")
time.sleep(2)
continue
self.log(f"{hijau}total balance : {putih}{balance}")
self.user_balance = balance
return
def daily_reward(self, data: Data):
url = "https://api-clicker.pixelverse.xyz/api/daily-rewards"
headers = self.base_headers.copy()
headers["initData"] = data.init_data
headers["secret"] = data.secret
headers["tg-id"] = data.userid
if data.username is not None:
headers["username"] = data.username
res = self.http(url, headers)
today_reward = res.json().get("todaysRewardAvailable")
if today_reward is None:
self.log(f"{merah}failed fetch today reward !")
return
if today_reward:
url_claim = "https://api-clicker.pixelverse.xyz/api/daily-rewards/claim"
res = self.http(url_claim, headers, "")
amount = res.json().get("amount")
if amount is None:
self.log(f"{merah}failed claim today reward !")
return
self.log(f"{hijau}success claim today reward : {putih}{amount}")
return
self.log(f"{kuning}already claim today reward !")
return
def get_mining_proccess(self, data: Data):
url = "https://api-clicker.pixelverse.xyz/api/mining/progress"
headers = self.base_headers.copy()
headers["initData"] = data.init_data
headers["secret"] = data.secret
headers["tg-id"] = data.userid
if data.username is not None:
headers["username"] = data.username
while True:
res = self.http(url, headers)
if res.json().get("currentlyAvailable", None) is None:
continue
break
available = res.json()["currentlyAvailable"]
min_claim = res.json()["minAmountForClaim"]
self.log(f"{putih}amount available : {hijau}{available}")
if available > min_claim:
url_claim = "https://api-clicker.pixelverse.xyz/api/mining/claim"
res = self.http(url_claim, headers, "")
if "claimedAmount" not in res.json().keys():
self.log(f"{merah}claim failed, maybe to many request !")
return
claim_amount = res.json()["claimedAmount"]
self.log(f"{hijau}claim amount : {putih}{claim_amount}")
return
self.log(f"{kuning}amount too small to make claim !")
return
def daily_combo(self, data: Data):
url = "https://api-clicker.pixelverse.xyz/api/cypher-games/current"
headers = self.base_headers.copy()
headers["initData"] = data.init_data
headers["secret"] = data.secret
headers["tg-id"] = data.userid
if data.username is not None:
headers["username"] = data.username
res = self.http(url, headers)
if res.status_code != 200:
self.log(f"{kuning}you have complete daily combo !")
return
today = datetime.now(timezone.utc).isoformat().split("T")[0]
list_combo = open("combo.txt").read().strip().split(",")
if len(list_combo) <= 1:
self.log(f"{kuning}skip apply daily combo, because combo.txt is empty !")
return
list_option = res.json().get("availableOptions")
if list_option is None:
self.log(f"{merah}failed fetch combo option !")
return
list_option = [i["id"] for i in list_option]
combo = {list_option[int(v) - 1]: k for k, v in enumerate(list_combo)}
combo_id = res.json()["id"]
answer_url = (
f"https://api-clicker.pixelverse.xyz/api/cypher-games/{combo_id}/answer"
)
res = requests.post(answer_url, headers=headers, json=combo)
if res.status_code != 201:
self.log(f"{merah}failed apply daily combo !")
return
self.log(f"{hijau}success apply daily combo !")
reward = res.json().get("rewardAmount", None)
self.log(f"{hijau}reward daily combo : {putih}{reward}")
def pets(self, data: Data):
url = "https://api-clicker.pixelverse.xyz/api/pets"
headers = self.base_headers.copy()
headers["initData"] = data.init_data
headers["secret"] = data.secret
headers["tg-id"] = data.userid
if data.username is not None:
headers["username"] = data.username
while True:
if self.AUTO_BUY_PET:
self.log(f"{putih}auto buy pet is {hijau}enable !")
res = self.http(f"{url}/buy", headers, "")
_pet = res.json().get("id")
if _pet is None:
self.log(f"{merah}failed buy new pet !")
else:
_pet_name = res.json()["pet"]["name"]
self.log(
f"{hijau}success buy new pet, pet name : {putih}{_pet_name} !"
)
res = self.http(url, headers)
data_pets = res.json().get("data", [])
if len(data_pets) <= 0:
self.log(f"{merah}failed fetch data pets !")
continue
for pet in data_pets:
user_pet_name = pet["name"]
user_pet_id = pet["userPet"]["id"]
user_pet_level = pet["userPet"]["level"]
user_level_up_price = pet["userPet"]["levelUpPrice"]
self.log(f"{hijau}pet id : {putih}{user_pet_id}")
self.log(f"{hijau}pet name : {putih}{user_pet_name}")
self.log(f"{hijau}pet level : {putih}{user_pet_level}")
if self.AUTO_UPGRADE_PET:
if user_pet_level > self.MAX_LEVEL_UPGRADE_PET:
self.log(f"{kuning}limit max level pet reacted from config !")
continue
if user_level_up_price > self.user_balance:
self.log(
f"{kuning}balance not enough to upgrade {putih}{user_pet_name}{kuning} !"
)
continue
upgrade_url = f"https://api-clicker.pixelverse.xyz/api/pets/user-pets/{user_pet_id}/level-up"
res = self.http(upgrade_url, headers, "")
if res.status_code != 201:
self.log(f"{merah}failed upgrade pet {user_pet_name}")
continue
self.log(f"{hijau}success upgrade pet {putih}{user_pet_name}")
self.user_balance -= user_level_up_price
continue
break
def main(self):
banner = f"""
{hijau}AUTO CLAIM PIXELTAP BY {biru}PIXELVERSE
{putih}By : {hijau}t.me/AkasakaID
{hijau}Github : {putih}@AkasakaID
"""
arg = argparse.ArgumentParser()
arg.add_argument("--marin", action="store_true")
arg.add_argument("--data", default="data.txt", help="")
args = arg.parse_args()
if args.marin is False:
os.system("cls" if os.name == "nt" else "clear")
print(banner)
print("~" * 50)
self.load_config()
while True:
for no, data in enumerate(self.load_data(args.data)):
self.log(f"{hijau}account number : {putih}{no + 1}")
parser = self.marin_kitagawa(data)
user = json.loads(parser["user"])
userid = str(user["id"])
first_name = user["first_name"]
last_name = user["last_name"]
username = None
if "username" in user.keys():
username = user["username"]
self.log(f"{hijau}login as : {putih}{first_name} {last_name}")
secret = self.get_secret(userid)
new_data = Data(data, userid, username, secret)
self.get_me(new_data)
self.daily_combo(new_data)
self.daily_reward(new_data)
self.get_mining_proccess(new_data)
self.pets(new_data)
print("~" * 50)
self.countdown(self.DEFAULT_INTERVAL)
self.countdown(self.DEFAULT_COUNTDOWN)
def load_config(self):
config = json.loads(open("config.json").read())
self.DEFAULT_COUNTDOWN = config["countdown"]
self.DEFAULT_INTERVAL = config["interval"]
self.AUTO_BUY_PET = config["auto_buy_pet"]
self.AUTO_UPGRADE_PET = config["auto_upgrade_pet"]
self.MAX_LEVEL_UPGRADE_PET = config["max_level_upgrade_pet"]
self.MAX_PET = config["max_pet"]
def load_data(self, file):
if not os.path.exists(file):
self.log(f"{merah}{file} not found !")
sys.exit()
datas = open(file).read().splitlines()
if len(datas) <= 0:
self.log(f"{merah}there no account detected, fill {file} first !")
sys.exit()
self.log(f"{hijau}account detected : {putih}{len(datas)}")
return datas
def countdown(self, t):
while t:
menit, detik = divmod(t, 60)
jam, menit = divmod(menit, 60)
jam = str(jam).zfill(2)
menit = str(menit).zfill(2)
detik = str(detik).zfill(2)
print(f"{putih}waiting until {jam}:{menit}:{detik} ", flush=True, end="\r")
t -= 1
time.sleep(1)
print(" ", flush=True, end="\r")
def log(self, message):
now = datetime.now().isoformat(" ").split(".")[0]
print(f"{hitam}[{now}]{reset} {message}")
def http(self, url, headers, data=None):
while True:
try:
if data is None:
res = requests.get(url, headers=headers, timeout=30)
open("http.log", "a", encoding="utf-8").write(f"{res.text}\n")
return res
if data == "":
res = requests.post(url, headers=headers, timeout=30)
open("http.log", "a", encoding="utf-8").write(f"{res.text}\n")
return res
res = requests.post(url, headers=headers, data=data, timeout=30)
open("http.log", "a", encoding="utf-8").write(f"{res.text}\n")
return res
except (
requests.exceptions.ConnectionError,
requests.exceptions.ConnectTimeout,
requests.exceptions.ReadTimeout,
requests.exceptions.Timeout,
):
self.log(f"{merah}connection error / connection timeout !")
continue
if __name__ == "__main__":
try:
app = PixelTapTod()
app.main()
except KeyboardInterrupt:
sys.exit()