-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbot.py
920 lines (811 loc) · 44.4 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
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
import sys
import json
import requests
from datetime import datetime, time as datetime_time
from colorama import init, Fore, Style
from urllib.parse import unquote
import cloudscraper
import hashlib
import random
from zoneinfo import ZoneInfo
from settings import config
from functions import calculate_bet, calculate_best_skill, improve_possible, number_short, calculate_tap_power
import time
from pydantic import BaseModel, Field
from keep_alive import keep_alive
import websockets
from loguru import logger
from flask import Flask
# Flask application
app = Flask(__name__)
@app.route('/')
def index():
return "Hello World!"
def run_flask():
app.run(debug=True)
init(autoreset=True)
class FundHelper(BaseModel):
funds: set = Field(default_factory=set)
youtube: dict
def time_now():
return int(time.time())
class Data:
def __init__(self, apiKey_us, username, id_us):
self.apiKey = apiKey_us
self.username = username
self.id = id_us
class PixelTod:
def __init__(self):
self.scraper = cloudscraper.create_scraper()
self.DEFAULT_COUNTDOWN = config.SLEEP_ALL
self.INTERVAL_DELAY = config.SLEEP_MULT
self.base_headers = {
"Accept": "*/*",
"Accept-Language": "en-US,en;q=0.9,ru;q=0.8",
"Content-Type": "application/json",
"Origin": "https://game.xempire.io",
"Referer": "https://game.xempire.io/",
"Sec-Fetch-Dest": "empty",
"Sec-Fetch-Mode": "cors",
"Sec-Fetch-Site": "same-site",
"User-Agent": "Mozilla/5.0 (Linux; Android 9; SM-N971N Build/PQ3B.190801.07101020; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/124.0.6367.82 Safari/537.36",
"X-Requested-With": "org.telegram.messenger.web",
}
self.level = 0
self.gmt_timezone = ZoneInfo('GMT')
self.dbData = {}
self.balance = 0
self.mph = 0
self.taps_limit = False
self.taps_limit_date = ''
def data_parsing(self, data):
return {key: value for key, value in (i.split('=') for i in unquote(data).split('&'))}
def main(self):
with open("initdata.txt", "r") as file:
datas = file.read().splitlines()
self.log(f'{Fore.LIGHTYELLOW_EX}Hesaplar algılandı: {len(datas)}')
if not datas:
self.log(f'{Fore.LIGHTYELLOW_EX}Lütfen bilgilerinizi girin initdata.txt')
sys.exit()
print('-' * 50)
while True:
for no, data in enumerate(datas):
self.log(f'{Fore.LIGHTYELLOW_EX}Hesap numarası: {Fore.LIGHTWHITE_EX}{no + 1}')
data_parse = self.data_parsing(data)
user = json.loads(data_parse['user'])
username = user.get('first_name')
id_us = user.get('id')
apiKey_us = data_parse.get('hash')
chat_instance = data_parse.get('chat_instance')
sender = data_parse.get('sender')
utm_bot_inline = data_parse.get('utm_bot_inline')
self.log(f'{Fore.LIGHTYELLOW_EX}Аккаунт: {Fore.LIGHTWHITE_EX}{username} ')
url = "https://api.xempire.io/telegram/auth"
payload = {
"data": {
"chatId": "",
"chatInstance": f"{chat_instance}",
"chatType": f"{sender}",
"initData": f"{data}",
"platform": "android",
"startParam": f"{utm_bot_inline}",
}
}
headers = self.base_headers.copy()
self.api_call(url, data=json.dumps(payload), headers=headers, method='POST')
Data(apiKey_us, username, id_us)
self.process_account(apiKey=apiKey_us, id_data=id_us)
print('-' * 50)
self.countdown(self.INTERVAL_DELAY)
self.countdown(self.DEFAULT_COUNTDOWN)
def process_account(self, apiKey: str, id_data):
full_profile = self.get_profile(full=True, apiKey=apiKey)
self.dbData = full_profile.get('dbData', {})
if self.dbData:
del full_profile['dbData']
self.balance = int(full_profile['hero']['money'] or 0)
self.update_level(level=int(full_profile['hero']['level'] or 0))
self.mph = int(full_profile['hero']['moneyPerHour'] or 0)
offline_bonus = int(full_profile['hero']['offlineBonus'] or 0)
if offline_bonus > 0:
time.sleep(random.randint(1, 2))
if self.get_offline_bonus(apiKey=apiKey):
self.log(f"{Fore.LIGHTYELLOW_EX}Çevrimdışı bonus: {Fore.LIGHTWHITE_EX}+{number_short(value=offline_bonus)}")
else:
self.log(f"{Fore.LIGHTRED_EX}Çevrimdışı bonus yok")
time.sleep(random.randint(2, 4))
profile = self.get_profile(full=False, apiKey=apiKey)
self.update_level(level=int(profile['hero']['level'] or 0))
self.balance = int(profile['hero']['money'] or 0)
self.mph = int(profile['hero']['moneyPerHour'] or 0)
self.level = int(profile['hero']['level'] or 0)
self.log(f"{Fore.LIGHTYELLOW_EX}seviye: {Fore.LIGHTWHITE_EX}{self.level} | "
f"{Fore.LIGHTYELLOW_EX}Denge: {Fore.LIGHTWHITE_EX}+{number_short(value=self.balance)} "
f"{Fore.LIGHTYELLOW_EX}Saat başına gelir: {Fore.LIGHTWHITE_EX}+{number_short(value=self.mph)}")
cur_time_gmt = datetime.now(self.gmt_timezone)
cur_time_gmt_s = cur_time_gmt.strftime('%Y-%m-%d')
new_day_gmt = cur_time_gmt.replace(hour=7, minute=0, second=0, microsecond=0)
daily_rewards = full_profile['dailyRewards']
daily_index = None
for day, status in daily_rewards.items():
if status == 'canTake':
daily_index = day
break
if daily_index is not None:
time.sleep(random.randint(2, 4))
daily_claimed = self.daily_reward(index=daily_index, apiKey=apiKey)
if daily_claimed:
self.log(f"{Fore.LIGHTYELLOW_EX}Günün ödülünü topladık")
else:
self.log(f"{Fore.LIGHTRED_EX}Günlük ödül mevcut değil")
unrewarded_quests = [quest['key'] for quest in full_profile['quests'] if not quest['isRewarded']]
if unrewarded_quests:
self.log(f"{Fore.LIGHTYELLOW_EX}Mevcut görevler var")
time.sleep(random.randint(2, 4))
for quest in unrewarded_quests:
time.sleep(random.randint(1, 2))
if self.quest_reward(quest=quest, apiKey=apiKey):
self.log(f"{Fore.LIGHTYELLOW_EX}Görev ödülü {Fore.LIGHTWHITE_EX}{quest} {Fore.LIGHTYELLOW_EX}получена")
time.sleep(random.randint(2, 4))
self.daily_quests(apiKey=apiKey)
time.sleep(random.randint(2, 4))
self.open_boxes(apiKey=apiKey)
time.sleep(random.randint(2, 4))
unrewarded_friends = [int(friend['id']) for friend in full_profile['friends'] if friend['bonusToTake'] > 0]
if unrewarded_friends:
self.log(f"{Fore.LIGHTYELLOW_EX}Arkadaşlık ödülü mevcut")
while len(unrewarded_friends) >= 10:
success, friends = self.friend_reward(batch=True, apiKey=apiKey)
if success:
self.log(f"{Fore.LIGHTYELLOW_EX}10 arkadaşa ödül verildi")
unrewarded_friends = [int(friend['id']) for friend in friends if friend['bonusToTake'] > 0]
time.sleep(random.randint(2, 4))
for friend in unrewarded_friends:
success, _ = self.friend_reward(batch=False, friend=friend, apiKey=apiKey)
if success:
self.log(f"{Fore.LIGHTYELLOW_EX}Bir arkadaşa ödül {Fore.LIGHTWHITE_EX}{friend} {Fore.LIGHTYELLOW_EX}получена")
time.sleep(random.randint(1, 2))
quests_completed = 0
for dbQuest in self.dbData['dbQuests']:
if quests_completed >= 2:
break
if dbQuest['isArchived']:
continue
if dbQuest['checkType'] != 'fakeCheck':
continue
if not any(dbQuest['key'] in quest['key'] for quest in full_profile['quests']):
if self.quest_reward(quest=dbQuest['key'], apiKey=apiKey):
quests_completed += 1
self.log(f"{Fore.LIGHTYELLOW_EX}Görev ödülü {Fore.LIGHTWHITE_EX}{dbQuest['key']} {Fore.LIGHTYELLOW_EX}получена")
time.sleep(random.randint(10, 20))
quiz_key = ''
quiz_answer = ''
quiz_req_level = 0
rebus_key = ''
rebus_answer = ''
rebus_req_level = 0
for quest in self.dbData['dbQuests']:
if quest['isArchived']:
continue
date_start = datetime.strptime(quest['dateStart'], '%Y-%m-%d %H:%M:%S') if quest.get('dateStart') else None
date_end = datetime.strptime(quest['dateEnd'], '%Y-%m-%d %H:%M:%S') if quest.get('dateEnd') else None
if date_start:
date_start = date_start.replace(tzinfo=self.gmt_timezone)
if date_end:
date_end = date_end.replace(tzinfo=self.gmt_timezone)
if date_start and date_end and not (date_start <= cur_time_gmt <= date_end):
continue
if 'riddle' in quest['key']:
quiz_key = quest['key']
quiz_answer = quest['checkData']
quiz_req_level = int(quest['requiredLevel'] or 0)
if 'rebus' in quest['key']:
rebus_key = quest['key']
rebus_answer = quest['checkData']
rebus_req_level = int(quest['requiredLevel'] or 0)
need_quiz = bool(quiz_key and quiz_answer) and not any(
quiz_key in quest['key'] for quest in full_profile['quests'])
need_rebus = bool(rebus_key and rebus_answer) and not any(
rebus_key in quest['key'] for quest in full_profile['quests'])
if need_quiz:
day_end = datetime_time(random.randint(22, 23), random.randint(0, 59))
self.log(f"{Fore.LIGHTYELLOW_EX}Bugün gece dönemi başlayacak {Fore.LIGHTWHITE_EX}{str(day_end)}")
if self.level >= quiz_req_level:
time.sleep(random.randint(2, 4))
if self.complete_quest(quest=quiz_key, code=quiz_answer, apiKey=apiKey):
self.log(f"{Fore.LIGHTYELLOW_EX}Alınan günlük sınav için ödül")
if need_rebus:
day_start = datetime_time(random.randint(8, 9), random.randint(0, 59))
self.log(f"{Fore.LIGHTYELLOW_EX}Yarın günlük süre şu saatte başlayacak: {Fore.LIGHTWHITE_EX}{str(day_start)}")
if self.level >= rebus_req_level:
time.sleep(random.randint(2, 4))
if self.complete_quest(quest=rebus_key, code=rebus_answer, apiKey=apiKey):
self.log(f"{Fore.LIGHTYELLOW_EX}Alınan günlük bulmaca ödülü")
if config.INVEST_ENABLED:
helper = self.get_helper(apiKey=apiKey)
if cur_time_gmt >= new_day_gmt and cur_time_gmt_s in helper:
helper = helper[cur_time_gmt_s]
if 'funds' in helper:
regular_funds = helper['funds'].get('regular', [])
special_fund = helper['funds'].get('special', None)
special_fund = special_fund if any(
fund['key'] == special_fund for fund in self.dbData['dbFunds']) else None
current_funds = self.get_funds_info(apiKey=apiKey)
time.sleep(random.randint(4, 8))
if regular_funds and 'funds' in current_funds and not current_funds['funds']:
funds_to_invest = [special_fund] if special_fund else []
funds_to_invest += regular_funds[:2] if special_fund else regular_funds
for fund in funds_to_invest:
self.invest(fund=fund, apiKey=apiKey, amount=calculate_bet(level=self.level, mph=self.mph, balance=self.balance))
time.sleep(random.randint(2, 4))
if config.MINING_SKILLS_LEVEL > 0:
my_skills = full_profile['skills']
friends_count = int(full_profile['profile']['friends'] or 0)
for skill in self.dbData['dbSkills']:
if skill['category'] != 'mining':
continue
if skill['key'] in my_skills:
if my_skills[skill['key']]['level'] >= config.MINING_SKILLS_LEVEL:
continue
possible_skill = improve_possible(skill, my_skills, self.level, self.balance, friends_count)
if possible_skill is not None:
if self.balance - possible_skill['price'] >= config.PROTECTED_BALANCE:
time.sleep(random.randint(1, 2))
improve_data = self.improve_skill(skill=possible_skill['key'], apiKey=apiKey)
if improve_data is not None:
self.log(
f"{Fore.LIGHTYELLOW_EX}Madencilik Becerisi {Fore.LIGHTWHITE_EX}{possible_skill['key']} {Fore.LIGHTYELLOW_EX}yükseltildi {Fore.LIGHTWHITE_EX}{possible_skill['newlevel']}")
else:
break
if config.SKILLS_COUNT > 0:
improved_skills = 0
improve_data = None
while improved_skills < config.SKILLS_COUNT:
skill = calculate_best_skill(skills=self.dbData['dbSkills'], ignored_skills=config.IGNORED_SKILLS,
profile=full_profile, level=self.level, balance=self.balance,
improve=improve_data)
if skill is None:
break
if self.balance - skill['price'] < config.PROTECTED_BALANCE:
self.log(f"{Fore.LIGHTYELLOW_EX}Beceri gelişimi durduruldu (denge koruması)")
break
time.sleep(random.randint(2, 4))
improve_data = self.improve_skill(skill=skill['key'], apiKey=apiKey)
if improve_data is None:
break
improved_skills += 1
self.log(f"{Fore.LIGHTYELLOW_EX}Yetenek {Fore.LIGHTWHITE_EX}{skill['key']} {Fore.LIGHTYELLOW_EX}улучшен до уровня {Fore.LIGHTWHITE_EX}{skill['newlevel']}")
time.sleep(random.randint(2, 4))
profile = self.get_profile(full=False, apiKey=apiKey)
self.update_level(level=int(profile['hero']['level'] or 0))
self.balance = int(profile['hero']['money'] or 0)
self.mph = int(profile['hero']['moneyPerHour'] or 0)
self.log(f"{Fore.LIGHTYELLOW_EX}Лвл: {Fore.LIGHTWHITE_EX}{self.level} | "
f"{Fore.LIGHTYELLOW_EX}Баланс: {Fore.LIGHTWHITE_EX}{number_short(value=self.balance)} | "
f"{Fore.LIGHTYELLOW_EX}Доход в час: {Fore.LIGHTWHITE_EX}+{number_short(value=self.mph)}")
if config.PVP_ENABLED:
if self.dbData:
league_data = None
selected_league = None
for league in self.dbData['dbNegotiationsLeague']:
if config.PVP_LEAGUE == 'auto':
if self.level >= league['requiredLevel'] and self.level <= league['maxLevel']:
if league_data is None or league['requiredLevel'] < league_data['requiredLevel']:
league_data = league
else:
if league['key'] == config.PVP_LEAGUE:
selected_league = league
if self.level >= league['requiredLevel'] and self.level <= league['maxLevel']:
league_data = league
break
if config.PVP_LEAGUE != 'auto' and league_data is None:
if selected_league:
if config.PVP_UPGRADE_LEAGUE:
for league in self.dbData['dbNegotiationsLeague']:
if league['requiredLevel'] > selected_league['requiredLevel'] and self.level >= league['requiredLevel']:
league_data = league
break
self.log(
f"{Fore.LIGHTYELLOW_EX}Seçilen lig artık mevcut değil. Yeni lig: {Fore.LIGHTWHITE_EX}{league_data['key']}.")
else:
config.PVP_ENABLED = False
self.log(
f"{Fore.LIGHTRED_EX}Seçilen lig artık mevcut değil. PvP devre dışı")
else:
config.PVP_ENABLED = False
self.log(f"{Fore.LIGHTRED_EX}PVP_LEAGUE parametresi geçersiz. PvP devre dışı")
if league_data is not None:
self.strategies = [strategy['key'] for strategy in self.dbData['dbNegotiationsStrategy']]
if config.PVP_STRATEGY == 'random' or config.PVP_STRATEGY in self.strategies:
time.sleep(random.randint(2, 4))
self.perform_pvp(league=league_data, strategy=config.PVP_STRATEGY, count=config.PVP_COUNT, apiKey=apiKey, id_data=id_data)
else:
config.PVP_ENABLED = False
self.log(f"{Fore.LIGHTRED_EX}PVP_STRATEGY parametresi geçersiz. PvP devre dışı")
else:
self.log(f"{Fore.LIGHTRED_EX}Veritabanı yok. PvP bu sefer atlanacak")
if config.TAPS_ENABLED:
per_tap = int(profile['hero']['earns']['task']['moneyPerTap'] or 0)
max_energy = int(profile['hero']['earns']['task']['limit'] or 0)
energy = int(profile['hero']['earns']['task']['energy'] or 0)
bonus_chance = float(profile['hero']['earns']['task']['bonusChance'] or 0)
bonus_mult = float(profile['hero']['earns']['task']['bonusMultiplier'] or 0)
if energy == max_energy and not self.taps_limit:
time.sleep(random.randint(2, 4))
self.perform_taps(per_tap=per_tap, energy=energy, bonus_chance=bonus_chance, bonus_mult=bonus_mult, apiKey=apiKey)
time.sleep(random.randint(2, 4))
def countdown(self, t):
while t:
one, two = divmod(t, 3600)
three, four = divmod(two, 60)
print(f"{Fore.LIGHTWHITE_EX}Şu ana kadar bekliyorum {one:02}:{three:02}:{four:02} ", flush=True, end="\r")
t -= 1
time.sleep(1)
print(" ", flush=True, end="\r")
def api_call(self, url, data=None, headers=None, method='GET'):
while True:
try:
if method == 'GET':
res = self.scraper.get(url, headers=headers)
elif method == 'POST':
res = self.scraper.post(url, headers=headers, data=data)
else:
raise ValueError(f'Не desteklenen yöntem: {method}')
if res.status_code == 401:
self.log(f'{Fore.LIGHTRED_EX}{res.text}')
return res
except (requests.exceptions.ConnectionError, requests.exceptions.ConnectTimeout, requests.exceptions.ReadTimeout, requests.exceptions.Timeout):
self.log(f'{Fore.LIGHTRED_EX}Bağlantı bağlantı hatası!')
break
def set_sign_headers(self, data: dict, apiKey: str) -> dict:
time_string = str(int(time_now()))
json_string = json.dumps(data)
hash_object = hashlib.md5()
hash_object.update(f"{time_string}_{json_string}".encode('utf-8'))
hash_string = hash_object.hexdigest()
headers = self.base_headers.copy()
headers["Api-Key"] = f"{apiKey}"
headers["Api-Time"] = f"{time_string}"
headers["Api-Hash"] = f"{hash_string}"
return headers
def get_profile(self, full: bool, apiKey: str) -> dict:
full_url = 'https://api.xempire.io/user/data/all'
after_url = 'https://api.xempire.io/user/data/after'
sync_url = 'https://api.xempire.io/hero/balance/sync'
try:
if full:
json_data = {'data': {}}
headers = self.set_sign_headers(data=json_data, apiKey=apiKey)
response = self.api_call(full_url, headers=headers, data=json.dumps(json_data), method='POST')
response_text = response.text
response_json = json.loads(response_text)
data = response_json['data']
lang = data.get('settings', {}).get('lang', 'en')
json_data2 = {'data': {'lang': f"{lang}"}}
headers2 = self.set_sign_headers(data=json_data2, apiKey=apiKey)
response2 = self.api_call(after_url, headers=headers2, data=json.dumps(json_data2), method='POST')
response_text2 = response2.text
response_json2 = json.loads(response_text2)
data.update(response_json2['data'])
return data
else:
json_data = {}
headers = self.set_sign_headers(data=json_data, apiKey=apiKey)
response = self.api_call(sync_url, headers=headers, data=json.dumps(json_data), method='POST')
response.raise_for_status()
response_text = response.text
response_json = json.loads(response_text)
return response_json['data']
except Exception as error:
self.log(f"{Fore.LIGHTRED_EX}Profil veri hatası: {error}")
time.sleep(3)
return {}
def update_level(self, level: int) -> None:
if self.level > 0 and level > self.level:
self.log(f"{Fore.LIGHTYELLOW_EX}Yeni lvl alındı: {level}")
self.level = level
def get_offline_bonus(self, apiKey: str) -> bool:
url = 'https://api.xempire.io/hero/bonus/offline/claim'
try:
json_data = {}
headers = self.set_sign_headers(data=json_data, apiKey=apiKey)
response = self.api_call(url, headers=headers, data=json.dumps(json_data), method='POST')
response.raise_for_status()
response_text = response.text
response_json = json.loads(response_text)
success = response_json.get('success', False)
if success:
self.update_level(level=int(response_json['data']['hero']['level']))
self.balance = int(response_json['data']['hero']['money'])
self.mph = int(response_json['data']['hero']['moneyPerHour'])
return True
else:
return False
except Exception as error:
self.log(f"{Fore.LIGHTRED_EX}Çevrimdışı bonus hatası: {error}")
time.sleep(3)
return False
def daily_reward(self, index: int, apiKey: str) -> bool:
url = 'https://api.xempire.io/quests/daily/claim'
try:
json_data = {'data': f"{index}"}
headers = self.set_sign_headers(data=json_data, apiKey=apiKey)
response = self.api_call(url, headers=headers, data=json.dumps(json_data), method='POST')
response.raise_for_status()
response_text = response.text
response_json = json.loads(response_text)
success = response_json.get('success', False)
if success:
self.update_level(level=int(response_json['data']['hero']['level']))
self.balance = int(response_json['data']['hero']['money'])
self.mph = int(response_json['data']['hero']['moneyPerHour'])
return True
else:
return False
except Exception as error:
self.log(f"{Fore.LIGHTRED_EX}Ошибка дневной награды: {str(error)}")
return False
def quest_reward(self, apiKey: str, quest: str, code: str = None) -> bool:
url = 'https://api.xempire.io/quests/claim'
try:
json_data = {'data': [quest, code]}
headers = self.set_sign_headers(data=json_data, apiKey=apiKey)
response = self.api_call(url, headers=headers, data=json.dumps(json_data), method='POST')
response.raise_for_status()
response_text = response.text
response_json = json.loads(response_text)
success = response_json.get('success', False)
if success:
self.update_level(level=int(response_json['data']['hero']['level']))
self.balance = int(response_json['data']['hero']['money'])
self.mph = int(response_json['data']['hero']['moneyPerHour'])
return True
else:
return False
except Exception as error:
self.log(f"{Fore.LIGHTRED_EX}Görev hatası: {str(error)}")
return False
def daily_quests(self, apiKey: str) -> None:
url = 'https://api.xempire.io/quests/daily/progress/all'
try:
json_data = {}
headers = self.set_sign_headers(data=json_data, apiKey=apiKey)
response = self.api_call(url, headers=headers, data=json.dumps(json_data), method='POST')
response.raise_for_status()
response_text = response.text
response_json = json.loads(response_text)
success = response_json.get('success', False)
if success:
for name, quest in response_json['data'].items():
if 'youtube' in name and not quest["isRewarded"]:
continue
except Exception as error:
self.log(f"{Fore.LIGHTRED_EX}Ошибка ежедневного квеста: {str(error)}")
def daily_quest_reward(self, apiKey: str, quest: str, code: str = None) -> bool:
url = 'https://api.xempire.io/quests/daily/progress/claim'
try:
json_data = {'data': {'quest': quest, 'code': code}}
headers = self.set_sign_headers(data=json_data, apiKey=apiKey)
response = self.api_call(url, headers=headers, data=json.dumps(json_data), method='POST')
response.raise_for_status()
response_text = response.text
response_json = json.loads(response_text)
success = response_json.get('success', False)
if success:
self.update_level(level=int(response_json['data']['hero']['level']))
self.balance = int(response_json['data']['hero']['money'])
self.mph = int(response_json['data']['hero']['moneyPerHour'])
return True
else:
return False
except Exception as error:
self.log(f"{Fore.LIGHTRED_EX}Günlük görev ödülü hatası: {str(error)}")
return False
def open_boxes(self, apiKey: str) -> None:
url_list = 'https://api.xempire.io/box/list'
url_open = 'https://api.xempire.io/box/open'
try:
json_data = {}
headers = self.set_sign_headers(data=json_data, apiKey=apiKey)
response = self.api_call(url_list, headers=headers, data=json.dumps(json_data), method='POST')
response.raise_for_status()
response_text = response.text
response_json = json.loads(response_text)
success = response_json.get('success', False)
if success and response_json['data']:
for name, _ in response_json['data'].items():
json_data = {'data': name}
headers2 = self.set_sign_headers(data=json_data, apiKey=apiKey)
res = self.api_call(url_open, headers=headers2, data=json.dumps(json_data), method='POST')
res.raise_for_status()
res_text = res.text
res_json = json.loads(res_text)
success = res_json.get('success', False)
if success and res_json['data']['loot']:
self.log(f"Box {name} opened")
except Exception as error:
self.log(f"{Fore.LIGHTRED_EX}Kutular açılırken hata oluştu: {str(error)}")
def friend_reward(self, apiKey: str, batch: bool = False, friend: int = 0) -> tuple[bool, list]:
url_claim = 'https://api.xempire.io/friends/claim'
url_batch = 'https://api.xempire.io/friends/claim/batch'
try:
if batch:
json_data = {}
url = url_batch
else:
json_data = {'data': friend}
url = url_claim
headers = self.set_sign_headers(data=json_data, apiKey=apiKey)
response = self.api_call(url, headers=headers, data=json.dumps(json_data), method='POST')
response.raise_for_status()
response_text = response.text
response_json = json.loads(response_text)
success = response_json.get('success', False)
if success:
self.update_level(level=int(response_json['data']['hero']['level']))
self.balance = int(response_json['data']['hero']['money'])
self.mph = int(response_json['data']['hero']['moneyPerHour'])
return True, response_json['data']['friends']
else:
return False, []
except Exception as error:
self.log(f"{Fore.LIGHTRED_EX}Arkadaş ödülü hatası: {str(error)}")
return False, []
def complete_quest(self, quest: str, code: str, apiKey: str) -> bool:
url = 'https://api.xempire.io/quests/check'
try:
json_data = {'data': [quest, code]}
headers = self.set_sign_headers(data=json_data, apiKey=apiKey)
response = self.api_call(url, headers=headers, data=json.dumps(json_data), method='POST')
response.raise_for_status()
response_text = response.text
response_json = json.loads(response_text)
if response_json.get('success', False) and response_json['data'].get('result', False):
time.sleep(2)
if self.quest_reward(quest=quest, code=code, apiKey=apiKey):
return True
return False
except Exception as error:
self.log(f"{Fore.LIGHTRED_EX}Görev tamamlama hatası: {str(error)}")
return False
def get_helper(self, apiKey: str) -> dict:
url = 'https://eeyjey.pro/crypto/x-empire/data/'
try:
json_data = {'data': 'eeyjey'}
headers = self.set_sign_headers(data=json_data, apiKey=apiKey)
response = self.api_call(url, headers=headers, data=json.dumps(json_data), method='POST')
print(f'{response}')
if response.status_code in {200, 400, 401, 403}:
response_json = response.json()
print(f'{response_json}')
success = response_json.get('success', False)
print(f'{success}')
if success:
return response_json.get('result', {})
else:
self.log(
f"{Fore.LIGHTRED_EX}Yardımcı hata: {response.status_code} {response_json.get('message', '')}")
return {}
except Exception as error:
self.log(f"{Fore.LIGHTRED_EX}Yardımcı hata: {str(error)}")
return {}
def get_funds_info(self, apiKey: str) -> dict:
url = 'https://api.xempire.io/fund/info'
try:
json_data = {}
headers = self.set_sign_headers(data=json_data, apiKey=apiKey)
response = self.api_call(url, headers=headers, data=json.dumps(json_data), method='POST')
response.raise_for_status()
response_text = response.text
response_json = json.loads(response_text)
return response_json['data']
except Exception as error:
self.log(f"{Fore.LIGHTRED_EX}Yatırım hatası: {error}")
time.sleep(3)
return {}
def invest(self, fund: str, amount: int, apiKey: str) -> None:
url = 'https://api.xempire.io/fund/invest'
if self.balance < amount:
self.log(f"{Fore.LIGHTRED_EX}Yatırıma para yok")
return
if self.balance - amount < config.PROTECTED_BALANCE:
self.log(f"{Fore.LIGHTRED_EX}Yatırımı atla (Denge koruması)")
return
try:
json_data = {'data': {'fund': fund, 'money': amount}}
headers = self.set_sign_headers(data=json_data, apiKey=apiKey)
response = self.api_call(url, headers=headers, data=json.dumps(json_data), method='POST')
response.raise_for_status()
response_text = response.text
response_json = json.loads(response_text)
success = response_json.get('success', False)
if success:
self.update_level(level=int(response_json['data']['hero']['level']))
self.balance = int(response_json['data']['hero']['money'])
self.mph = int(response_json['data']['hero']['moneyPerHour'])
for fnd in response_json['data']['funds']:
if fnd['fundKey'] == fund:
money = fnd['moneyProfit']
money_str = f"{Fore.LIGHTYELLOW_EX}Profit: +{number_short(value=money)}" if money > 0 else (
f"{Fore.LIGHTRED_EX}Loss: {number_short(value=money)}" if money < 0 else "Profit: 0")
self.log(
f"{Fore.LIGHTYELLOW_EX}Yatırım yapıldı {Fore.LIGHTWHITE_EX}{number_short(value=amount)} {Fore.LIGHTYELLOW_EX}в {Fore.LIGHTWHITE_EX}{fund} {money_str}")
break
except Exception as error:
self.log(f"{Fore.LIGHTRED_EX}Yatırım hatası: {str(error)}")
def improve_skill(self, skill: str, apiKey: str) -> dict | None:
url = 'https://api.xempire.io/skills/improve'
try:
json_data = {'data': skill}
headers = self.set_sign_headers(data=json_data, apiKey=apiKey)
response = self.api_call(url, headers=headers, data=json.dumps(json_data), method='POST')
response.raise_for_status()
response_text = response.text
response_json = json.loads(response_text)
success = response_json.get('success', False)
if success:
self.update_level(level=int(response_json['data']['hero']['level']))
self.balance = int(response_json['data']['hero']['money'])
self.mph = int(response_json['data']['hero']['moneyPerHour'])
return response_json['data']
else:
return None
except Exception as error:
self.log(f"{Fore.LIGHTRED_EX}Beceri Yükseltme Hatası: {str(error)}")
return None
def perform_pvp(self, league: dict, strategy: str, count: int, apiKey: str, id_data: Data) -> None:
url_fight = 'https://api.xempire.io/pvp/start/fight'
url_cancel = 'https://api.xempire.io/pvp/fight/cancel'
url_claim = 'https://api.xempire.io/pvp/claim'
self.log(f"{Fore.LIGHTYELLOW_EX}Началось PvP. Лига: {Fore.LIGHTWHITE_EX}{league['key']} {Fore.LIGHTYELLOW_EX}Стратегия: {Fore.LIGHTWHITE_EX}{strategy}")
time.sleep(3)
curent_strategy = strategy
money = 0
search_attempts = 0
while count > 0:
if self.balance < int(league['maxContract']):
money_str = f"Profit: +{number_short(value=money)}" if money > 0 else (
f"Loss: {number_short(value=money)}" if money < 0 else "Profit: 0")
self.log(f"{Fore.LIGHTRED_EX}PvP остановлен (нету денег) {Fore.LIGHTWHITE_EX}{money_str}")
break
if self.balance - int(league['maxContract']) < config.PROTECTED_BALANCE:
money_str = f"Profit: +{number_short(value=money)}" if money > 0 else (
f"Loss: {number_short(value=money)}" if money < 0 else "Profit: 0")
self.log(f"{Fore.LIGHTRED_EX}PvP остановлен (защита баланса) {Fore.LIGHTWHITE_EX}{money_str}")
break
if strategy == 'random':
curent_strategy = random.choice(self.strategies)
self.log(f"Bir rakip arayın...")
try:
search_attempts += 1
json_data = {'data': {'league': league['key'], 'strategy': curent_strategy}}
headers = self.set_sign_headers(data=json_data, apiKey=apiKey)
response = self.api_call(url_fight, headers=headers, data=json.dumps(json_data), method='POST')
response.raise_for_status()
response_text = response.text
response_json = json.loads(response_text)
success = response_json.get('success', False)
op = response_json['data']
op2 = response_json["data"].get("opponent")
print(f"{op}")
print(f"{op2}")
if success:
if response_json['data']['opponent'] is None:
if search_attempts > 2:
json_data = {}
headers = self.set_sign_headers(data=json_data, apiKey=apiKey)
self.api_call(url_cancel, headers=headers, data=json.dumps(json_data),
method='POST')
search_attempts = 0
self.log(f"Поиск закрыт")
time.sleep(random.randint(5, 10))
continue
time.sleep(random.randint(6, 7))
count -= 1
search_attempts = 0
if int(response_json['data']['fight']['player1']) == id_data.id:
opponent_strategy = response_json['data']['fight']['player2Strategy']
else:
opponent_strategy = response_json['data']['fight']['player1Strategy']
money_contract = response_json['data']['fight']['moneyContract']
money_profit = response_json['data']['fight']['moneyProfit']
winner = int(response_json['data']['fight']['winner'])
if winner == id_data.id:
money += money_profit
self.log(f"{Fore.LIGHTYELLOW_EX}Risk altındaki tutar: {Fore.LIGHTWHITE_EX}{number_short(value=money_contract)} | "
f"{Fore.LIGHTYELLOW_EX}Stratejiniz: {Fore.LIGHTWHITE_EX}{curent_strategy} | "
f"{Fore.LIGHTYELLOW_EX}Rakibin stratejisi: {Fore.LIGHTWHITE_EX}{opponent_strategy} | "
f"{Fore.LIGHTYELLOW_EX}KAZANMAK {Fore.LIGHTWHITE_EX}(+{number_short(value=money_profit)})")
else:
money -= money_contract
self.log(f"{Fore.LIGHTYELLOW_EX}Risk altındaki tutar: {Fore.LIGHTWHITE_EX}{number_short(value=money_contract)} | "
f"{Fore.LIGHTYELLOW_EX}Stratejiniz: {Fore.LIGHTWHITE_EX}{curent_strategy} | "
f"{Fore.LIGHTYELLOW_EX}Rakibin stratejisi: {Fore.LIGHTWHITE_EX}{opponent_strategy} | "
f"{Fore.LIGHTRED_EX}KAYIP {Fore.LIGHTWHITE_EX}(-{number_short(value=money_contract)})")
json_data = {}
headers = self.set_sign_headers(data=json_data, apiKey=apiKey)
response = self.api_call(url_claim, headers=headers, data=json.dumps(json_data), method='POST')
response.raise_for_status()
response_text = response.text
response_json = json.loads(response_text)
success = response_json.get('success', False)
if success:
self.update_level(level=int(response_json['data']['hero']['level']))
self.balance = int(response_json['data']['hero']['money'])
self.mph = int(response_json['data']['hero']['moneyPerHour'])
time.sleep(random.randint(3, 5))
except Exception as error:
self.log(f"PvP error: {str(error)}")
time.sleep(3)
time.sleep(random.randint(15, 20))
money_str = f"Profit: +{number_short(value=money)}" if money > 0 else (
f"Loss: {number_short(value=money)}" if money < 0 else "Profit: 0")
self.log(f"{Fore.LIGHTYELLOW_EX}PvP окончен {Fore.LIGHTWHITE_EX}{money_str}")
def get_tap_limit(self) -> int:
for level_info in self.dbData['dbLevels']:
if level_info['level'] == self.level:
return int(level_info['tapLimit'] or 0)
return 0
def perform_taps(self, per_tap: int, energy: int, bonus_chance: float, bonus_mult: float, apiKey: str) -> None:
url = 'https://api.xempire.io/hero/action/tap'
self.log(f"{Fore.LIGHTYELLOW_EX}Начал тапать. Монет за тап: {Fore.LIGHTWHITE_EX}{per_tap} | {Fore.LIGHTYELLOW_EX}Бонус: {Fore.LIGHTWHITE_EX}{bonus_chance:.2f} | {Fore.LIGHTYELLOW_EX}Мультипликатор: {Fore.LIGHTWHITE_EX}{bonus_mult:.2f}")
tap_limit = self.get_tap_limit()
taps_over = False
last = False
while not last:
taps_per_second = random.randint(*config.TAPS_PER_SECOND)
seconds = random.randint(4, 6)
taps_sum = taps_per_second * seconds
earned_money = 0
for i in range(1, taps_sum + 1):
tap_power = calculate_tap_power(per_tap, energy, bonus_chance, bonus_mult)
earned_money += tap_power
energy -= 0.7 * tap_power
if energy < per_tap: last = True
time.sleep(seconds)
try:
json_data = {
'data': {'data': {'task': {'amount': earned_money, 'currentEnergy': energy}}, 'seconds': seconds}}
headers = self.set_sign_headers(data=json_data, apiKey=apiKey)
response = self.api_call(url, headers=headers, data=json.dumps(json_data), method='POST')
response.raise_for_status()
response_text = response.text
response_json = json.loads(response_text)
success = response_json.get('success', False)
error = response_json.get('error', '')
if success:
self.update_level(level=int(response_json['data']['hero']['level']))
self.balance = int(response_json['data']['hero']['money'])
self.mph = int(response_json['data']['hero']['moneyPerHour'])
energy = int(response_json['data']['hero']['earns']['task']['energy'])
tapped_today = int(response_json['data']['tapped_today'])
self.log(f"{Fore.LIGHTYELLOW_EX}Получил: {Fore.LIGHTWHITE_EX}+{number_short(value=earned_money)} {Fore.LIGHTYELLOW_EX}Осталось энергии: {Fore.LIGHTWHITE_EX}{number_short(value=energy)}")
if tapped_today >= tap_limit:
taps_over = True
if last and not taps_over:
self.log(f"{Fore.LIGHTRED_EX}Muslukları durdurun (enerji yok))")
elif 'too many taps' in error:
taps_over = True
if taps_over:
self.log(f"{Fore.LIGHTRED_EX}Dokunmaları durdurun (dokunma sınırına ulaşıldı))")
self.taps_limit = True
cur_time_gmt = datetime.now(self.gmt_timezone)
self.taps_limit_date = cur_time_gmt.strftime('%Y-%m-%d')
last = True
except Exception as error:
self.log(f"Taps error: {str(error)}")
break
def log(self, message):
now = datetime.now().isoformat(" ").split(".")[0]
print(f"{Fore.LIGHTBLACK_EX}[{now}]{Style.RESET_ALL} {message}")
if Data is None:
def log(message):
now = datetime.now().isoformat(" ").split(".")[0]
print(f"{Fore.LIGHTBLACK_EX}[{now}]{Style.RESET_ALL} {message}")
if __name__ == "__main__":
try:
app = PixelTod()
keep_alive()
app.main()
except KeyboardInterrupt:
sys.exit()