-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmidas.py
241 lines (200 loc) · 9.01 KB
/
midas.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
import cloudscraper
import time
CYAN = '\033[96m'
GREEN = '\033[92m'
RED = '\033[91m'
YELLOW = '\033[93m'
RESET = '\033[0m'
def post_request(url, headers, payload=None):
scraper = cloudscraper.create_scraper()
response = scraper.post(url, json=payload, headers=headers)
if response.status_code == 200 or response.status_code == 201:
try:
return response.json(), response.cookies
except ValueError:
return response.text, response.cookies
else:
print(f"Request failed with status code: {response.status_code}")
print(f"Response text: {response.text}")
return None, None
def get_request(url, headers):
scraper = cloudscraper.create_scraper()
response = scraper.get(url, headers=headers)
if response.status_code == 200:
try:
return response.json()
except ValueError:
print("Response is not .JSON")
return None
else:
print(f"Request failed to retrieve information with status code: {response.status_code}")
print(f"Response text: {response.text}")
return None
def read_init_data(filename):
try:
with open(filename, 'r') as file:
init_data_list = [line.strip() for line in file if line.strip()]
return init_data_list
except FileNotFoundError:
print(f"File {filename} Not found.")
return []
def get_streak_info(headers):
url_streak = "https://api-tg-app.midas.app/api/streak"
streak_data = get_request(url_streak, headers)
if streak_data:
streak_days_count = streak_data.get("streakDaysCount", "Not found")
next_rewards = streak_data.get("nextRewards", {})
points = next_rewards.get("points", "Not found")
tickets = next_rewards.get("tickets", "Not found")
claimable = streak_data.get("claimable", False)
print(f"Streak Days Count: {streak_days_count}")
print(f"Prizes that can be claimed - Points: {GREEN}{points}{RESET}, Tickets: {GREEN}{tickets}{RESET}")
if claimable:
print(f"{GREEN}Streak is available to be claimed.{RESET}")
claim_streak(headers)
else:
print(f"{YELLOW}Streak is not available to be claimed.{RESET}")
else:
print("Error: Cannot access the streak API")
def claim_streak(headers):
url_claim = "https://api-tg-app.midas.app/api/streak"
response, _ = post_request(url_claim, headers)
if response:
points = response.get("points", "Not found")
tickets = response.get("tickets", "Not found")
print(f"{GREEN}Claiming daily tickets and points was successful!{RESET}")
else:
print(f"{RED}Error: Failed to claim daily reward.{RESET}")
return 0, 0
def get_user_info(headers):
url_user = "https://api-tg-app.midas.app/api/user"
user_data = get_request(url_user, headers)
if user_data:
telegram_id = user_data.get("telegramId", "Not found")
username = user_data.get("username", "Not found")
first_name = user_data.get("firstName", "Not found")
points = user_data.get("points", "Not found")
tickets = user_data.get("tickets", 0)
games_played = user_data.get("gamesPlayed", "Not found")
streak_days_count = user_data.get("streakDaysCount", "Not found")
print(f"Telegram ID: {telegram_id}")
print(f"Username: {CYAN}{username}{RESET}")
print(f"First Name: {CYAN}{first_name}{RESET}")
print(f"Points: {GREEN}{points}{RESET}")
if tickets == 0:
print(f"Tickets: {RED}{tickets}{RESET}")
else:
print(f"Tickets: {GREEN}{tickets}{RESET}")
print(f"Games Played: {games_played}")
print(f"Streak Days Count: {streak_days_count}")
return tickets, points
else:
print("Error: Cannot access API user.")
return 0, 0
def check_referral_status(headers):
url_referral = "https://api-tg-app.midas.app/api/referral/status"
url_referral_claim = "https://api-tg-app.midas.app/api/referral/claim"
referral_data = get_request(url_referral, headers)
if referral_data:
can_claim = referral_data.get("canClaim", False)
if can_claim:
print(f"{GREEN}Referral claim available! Executing claim...{RESET}")
claim_response, _ = post_request(url_referral_claim, headers)
if claim_response:
total_points = claim_response.get("totalPoints", 0)
total_tickets = claim_response.get("totalTickets", 0)
print(f"{GREEN}Referral claim successful!{RESET} You get {GREEN}{total_points}{RESET} points and {GREEN}{total_tickets}{RESET} tiket.")
return total_points, total_tickets
else:
print(f"{RED}Error while executing referral claim.{RESET}")
return 0, 0
else:
print(f"{YELLOW}There are no referral claims available at the moment.{RESET}")
return 0, 0
else:
print(f"{RED}Request error.{RESET} {YELLOW}Trying again...{RESET}")
return 0, 0
def play_game(headers, tickets):
url_game = "https://api-tg-app.midas.app/api/game/play"
total_points = 0
while tickets > 0:
for i in range(3, 0, -1):
print(f"Starting the game in {YELLOW}{i}{RESET} secods...", end='\r')
time.sleep(1)
print(f"\n{YELLOW}Starting the game ...{RESET}")
game_data, _ = post_request(url_game, headers)
if game_data:
points_earned = game_data.get("points", 0)
total_points += points_earned
tickets -= 1
print(f"Receive{GREEN}{points_earned} points{RESET}, Total Points: {GREEN}{total_points}{RESET}, Remaining Tickets: {YELLOW}{tickets}{YELLOW}")
else:
print(f"{RED}Error while playing the game.{RESET}")
break
return total_points
def process_init_data(init_data):
print(f"\nProcessing initData: {YELLOW}...{init_data[-20:]}{RESET}")
url_register = "https://api-tg-app.midas.app/api/auth/register"
headers_register = {
"Accept": "application/json, text/plain, */*",
"Origin": "https://prod-tg-app.midas.app",
"Referer": "https://prod-tg-app.midas.app/",
"Sec-Ch-Ua": '"Not_A Brand";v="8", "Chromium";v="120"',
"Sec-Ch-Ua-Mobile": "?1",
"Sec-Ch-Ua-Platform": '"Android"',
"Sec-Fetch-Dest": "empty",
"Sec-Fetch-Mode": "cors",
"Sec-Fetch-Site": "same-site",
"User-Agent": "Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Mobile Safari/537.36"
}
payload = {
"initData": init_data
}
response_text, cookies = post_request(url_register, headers_register, payload)
if response_text:
print(f"Token received: {YELLOW}...{response_text[-20:]}{RESET}")
cookies_dict = cookies.get_dict()
cookies_preview = {key: f"...{value[-20:]}" for key, value in cookies_dict.items()}
print(f"Cookies received: {YELLOW}{cookies_preview}{RESET}")
token = response_text
headers_user = {
"Accept": "application/json, text/plain, */*",
"Origin": "https://prod-tg-app.midas.app",
"Referer": "https://prod-tg-app.midas.app/",
"Sec-Ch-Ua": '"Not_A Brand";v="8", "Chromium";v="120"',
"Sec-Ch-Ua-Mobile": "?1",
"Sec-Ch-Ua-Platform": '"Android"',
"Sec-Fetch-Dest": "empty",
"Sec-Fetch-Mode": "cors",
"Sec-Fetch-Site": "same-site",
"User-Agent": "Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Mobile Safari/537.36",
"Authorization": f"Bearer {token}",
"Cookie": "; ".join([f"{key}={value}" for key, value in cookies.get_dict().items()])
}
get_streak_info(headers_user)
check_referral_status(headers_user)
tickets, points = get_user_info(headers_user)
if tickets > 0:
total_points = play_game(headers_user, tickets)
print(f"Total points after playing the game: {GREEN}{total_points}{RESET}")
else:
print(f"{YELLOW}There are no tickets available to play the game.{RESET}")
else:
print("Error: Cannot get token.")
def main():
init_data_list = read_init_data('auth.txt')
while True:
for init_data in init_data_list:
process_init_data(init_data)
print("Countdown 10 seconds before processing the next account...")
for i in range(10, 0, -1):
print(f"{i} seconds...", end="\r")
time.sleep(1)
print("Finished processing all initData. Restarting in 8 hours...")
for i in range(8 * 3600, 0, -1):
hours, remainder = divmod(i, 3600)
minutes, seconds = divmod(remainder, 60)
print(f"{hours:02}:{minutes:02}:{seconds:02}", end="\r")
time.sleep(1)
if __name__ == "__main__":
main()