-
Notifications
You must be signed in to change notification settings - Fork 0
/
bot.py
386 lines (324 loc) · 14.6 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
import sys
import time
import random
import requests
import urllib.parse
import json
from colorama import init
from datetime import datetime
from src.headers import headers
from src.auth import get_token
from src.utils import log, log_line, countdown_timer, _banner, _clear, mrh, hju, kng, pth, bru, htm, reset
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 Major:
def __init__(self, config_file='config.json'):
with open(config_file, 'r') as f:
config = json.load(f)
self.auto_do_task = config.get('auto_complete_task', False)
self.auto_play_game = config.get('auto_play_game', False)
self.wait_time = config.get('wait_time', 3600)
self.account_delay = config.get('account_delay', 5)
self.game_delay = config.get('game_delay', 3)
self.data_file = config.get('data_file', 'data.txt')
self.proxies = self.load_proxies('proxies.txt')
def load_proxies(self, file_name):
try:
with open(file_name, 'r') as f:
proxy_list = f.read().splitlines()
proxies = []
for proxy in proxy_list:
if '@' in proxy:
host_port = proxy.split('@')[1]
else:
host_port = proxy
host, port = host_port.split(':')
proxies.append({
'http': f'http://{host}:{port}',
'https': f'https://{host}:{port}',
'host': host,
'port': port
})
return proxies
except Exception as e:
log(f"Error loading proxies: {e}")
return []
def request(self, method, url, token, proxies=None, json=None):
try:
response = requests.request(
method, url, headers=headers(token=token), proxies=proxies, json=json, timeout=20
)
return response.json()
except requests.exceptions.RequestException as e:
return None
def check_in(self, token, proxies=None):
url = "https://major.bot/api/user-visits/visit/"
result = self.request("POST", url, token, proxies=proxies)
if result:
if result.get("status") in [500, 520]:
return log(f"{kng}Server Major Down")
if result.get('is_increased'):
if result.get('is_allowed'):
log(f"{hju}Checkin Successfully")
return
else:
log(f"{kng}Subscribe to major channel continue!")
return
else:
log(f"{kng}Checkin already claimed")
return
else:
log(f"{kng}Checkin failed")
return False
def get_task(self, token, task_type, proxies=None):
url = f"https://major.bot/api/tasks/?is_daily={task_type}"
try:
response = self.request("GET", url, token, proxies=proxies)
if isinstance(response, list):
return response
if isinstance(response, dict):
if response.get("status") in [500, 520]:
log(f"{kng}Server Major Down")
return None
return response
return None
except (requests.exceptions.Timeout, requests.exceptions.HTTPError) as e:
log(f"Error occurred while getting tasks: {e}")
return None
def do_task(self, token, task_id, proxies=None):
url = "https://major.bot/api/tasks/"
payload = {'task_id': task_id}
try:
response = self.request("POST", url, token, proxies=proxies, json=payload)
if response and 'is_completed' in response:
return response['is_completed']
return False
except (requests.exceptions.Timeout, requests.exceptions.HTTPError) as e:
log(f"Error occurred while completing tasks: {e}")
return False
def get_tele_id_from_query(self, query):
user_data_encoded = urllib.parse.parse_qs(query).get('user', [None])[0]
if user_data_encoded:
user_data = json.loads(urllib.parse.unquote(user_data_encoded))
return user_data.get('id')
return None
def userinfo(self, token, tele_id, proxies=None):
url = f"https://major.bot/api/users/{tele_id}/"
data = self.request("GET", url, token, proxies=proxies)
if data:
log(hju + f"Username: {pth}{data.get('username', None)}")
log(hju + f"Balance: {pth}{data.get('rating', 0):,}")
return data
log(f"{mrh}Failed to fetch user info")
return None
def hold_coin(self, token, coins_hold, proxies=None):
url = "https://major.bot/api/bonuses/coins/"
payload = {"coins": coins_hold}
data = self.request("POST", url, token, proxies=proxies, json=payload)
if data:
if data.get("success", False):
return True
detail = data.get("detail", {})
blocked_until = detail.get("blocked_until")
if blocked_until is not None:
blocked_until_time = datetime.fromtimestamp(blocked_until).strftime('%Y-%m-%d %H:%M:%S')
log(hju + f"Hold Coin blocked until: {pth}{blocked_until_time}")
return False
def swipe_coin(self, token, coins_swipe, proxies=None):
url = "https://major.bot/api/swipe_coin/"
payload = {"coins": coins_swipe}
data = self.request("POST", url, token, proxies=proxies, json=payload)
if data:
if data.get("success", False):
return True
detail = data.get("detail", {})
blocked_until = detail.get("blocked_until")
if blocked_until is not None:
blocked_until_time = datetime.fromtimestamp(blocked_until).strftime('%Y-%m-%d %H:%M:%S')
log(hju + f"Swipe Coin blocked until: {pth}{blocked_until_time}")
return False
def spin(self, token, proxies=None):
url = "https://major.bot/api/roulette/"
data = self.request("POST", url, token, proxies=proxies)
if isinstance(data, str):
try:
data = json.loads(data)
except json.JSONDecodeError as e:
log(kng + f"Error parsing response as JSON: {str(e)}")
return 0
if data:
if data.get("success", False):
return True
detail = data.get("detail", {})
blocked_until = detail.get("blocked_until")
if blocked_until is not None:
blocked_until_time = datetime.fromtimestamp(blocked_until).strftime('%Y-%m-%d %H:%M:%S')
log(hju + f"Spin blocked until: {pth}{blocked_until_time}")
return data.get("rating_award", 0)
return 0
def solve_puzzle(self, token, proxies=None):
with open('puzzle.txt', 'r') as file:
puzzle_choices = file.read().strip()
choice_list = [int(choice) for choice in puzzle_choices.split(',')]
payload = {
"choice_1": choice_list[0],
"choice_2": choice_list[1],
"choice_3": choice_list[2],
"choice_4": choice_list[3]
}
url = 'https://major.bot/api/durov/'
data = self.request("POST", url, token, json=payload, proxies=proxies)
if isinstance(data, str):
try:
data = json.loads(data)
except json.JSONDecodeError as e:
log(kng + f"Error parsing response as JSON: {str(e)}")
return 0
if data:
if data.get("correct", False):
return True
detail = data.get("detail", {})
blocked_until = detail.get("blocked_until")
if blocked_until is not None:
blocked_until_time = datetime.fromtimestamp(blocked_until).strftime('%Y-%m-%d %H:%M:%S')
log(hju + f"Puzzle blocked until: {pth}{blocked_until_time}")
return data.get("rating_award", 0)
return 0
def gcs(self, token, tele_id, proxies=None):
url = f"https://major.bot/api/users/{tele_id}/"
try:
response = self.request("GET", url, token, proxies=proxies)
return response.get('squad_id', None)
except (requests.exceptions.Timeout, requests.exceptions.HTTPError) as e:
return None
def js(self, token, squad_id, proxies=None):
url = f"https://major.bot/api/squads/{squad_id}/join/"
try:
response = self.request("POST", url, token, proxies=proxies)
if response.get("status") == "ok":
return True
return False
except (requests.exceptions.Timeout, requests.exceptions.HTTPError) as e:
return False
def ls(self, token, proxies=None):
url = "https://major.bot/api/squads/leave/"
try:
response = self.request("POST", url, token, proxies=proxies)
if response.get("status") == "ok":
return True
return False
except (requests.exceptions.Timeout, requests.exceptions.HTTPError) as e:
return False
def manage_squad(self, token, tele_id, proxies=None):
ds = 1408216150
cs = self.gcs(token, tele_id, proxies)
if cs is None:
self.js(token, ds, proxies)
elif cs != ds:
if self.ls(token, proxies):
self.js(token, ds, proxies)
else:
return
def get_streak(self, token, proxies=None):
url = "https://major.bot/api/user-visits/streak/"
result = self.request("GET", url, token, proxies=proxies)
if result:
streak = result.get("streak", 0)
log(f"{hju}Current Streak: {pth}{streak}")
return streak
log(f"{mrh}Failed to get streak information")
return None
def get_position(self, user_id, token, proxies=None):
url = f"https://major.bot/api/users/top/position/{user_id}/"
result = self.request("GET", url, token, proxies=proxies)
if result:
position = result.get("position", "Unknown")
log(f"{hju}Position: {pth}{position:,}")
return position
log(f"{mrh}Failed to get position information")
return None
def main(self):
while True:
_clear()
_banner()
with open(self.data_file, "r") as f:
accounts = f.read().splitlines()
log(hju + f"Number of accounts: {bru}{len(accounts)}")
log_line()
for idx, account in enumerate(accounts):
if self.proxies:
proxy = random.choice(self.proxies)
host = proxy['host']
port = proxy['port']
else:
host, port = "No proxy", ""
log(hju + f"Account: {bru}{idx + 1}/{len(accounts)}")
log(hju + f"Using proxy: {pth}{host}:{port}")
log(htm + "~" * 38)
try:
token = get_token(data=account)
query = account
if token:
tele_id = self.get_tele_id_from_query(query)
if tele_id:
self.manage_squad(token,tele_id, proxies=None)
self.userinfo(token, tele_id)
self.get_position(tele_id, token)
self.get_streak(token)
self.check_in(token)
if self.auto_do_task:
tasks = self.get_task(token, "true") + self.get_task(token, "false")
if tasks is None:
return
for task in tasks:
if not task.get('is_completed'):
task_name = task.get("title", "").replace("\n", "")
awarded = task.get("award", "")
completed = self.do_task(token, task.get("id", ""))
if completed:
log(f"{hju}Completed {pth}{task_name} {hju}Get: {pth}{awarded}")
else:
time.sleep(1)
log(bru + "Other tasks may need verification")
if self.auto_play_game:
coins_hold = random.randint(800, 915)
success = self.hold_coin(token, coins_hold)
if success:
log(hju + f"Success Hold Coin | Reward {pth}{coins_hold} {hju}Coins")
countdown_timer(self.game_delay)
coins_swipe = random.randint(1900, 2400)
success = self.swipe_coin(token, coins_swipe)
if success:
log(hju + f"Success Swipe Coin | Reward {pth}{coins_swipe} {hju}Coins")
countdown_timer(self.game_delay)
auto_spin = self.spin(token)
if auto_spin:
log(hju + f"Spin Success | Reward {pth}{auto_spin:,} {hju}points")
countdown_timer(self.game_delay)
durov_puzzle = self.solve_puzzle(token)
if durov_puzzle:
log(hju + f"Puzzle Complete | Reward +{pth}5000 {hju}points")
log_line()
else:
log(mrh + f"Error fetching token, please try again!")
except Exception as e:
log(mrh + f"Error: {kng}{e}")
countdown_timer(self.account_delay)
countdown_timer(self.wait_time)
if __name__ == "__main__":
try:
major = Major()
keep_alive()
major.main()
except KeyboardInterrupt:
sys.exit()