PIDRIGG commited on
Commit
1d28bf8
·
verified ·
1 Parent(s): 42c874f

Delete main.py

Browse files
Files changed (1) hide show
  1. main.py +0 -2207
main.py DELETED
@@ -1,2207 +0,0 @@
1
-
2
- import requests, os, psutil, sys, jwt, pickle, json, binascii, time, urllib3, base64, datetime, re, socket, threading
3
- import asyncio
4
- import random
5
- from protobuf_decoder.protobuf_decoder import Parser
6
- from byte import *
7
- from byte import xSendTeamMsg
8
- from byte import Auth_Chat
9
- from xHeaders import *
10
- from datetime import datetime
11
- from google.protobuf.timestamp_pb2 import Timestamp
12
- from concurrent.futures import ThreadPoolExecutor
13
- from threading import Thread
14
- import telebot
15
- from telebot import types
16
- import tempfile
17
-
18
- urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
19
-
20
- # BoT SeT
21
- TELEGRAM_BOT_TOKEN = "8591409332:AAHInmn3F5EsWxreiMEB6zHl1AOWKmhyUH8"
22
- ADMIN_USER_IDS = [7576327999]
23
- # FiLeS SeT
24
- USERS_FILE = 'users.json'
25
- ACTIVATIONS_FILE = 'activations.json'
26
- ACTIVATION_CODES_FILE = 'activation_codes.json'
27
- ALLOWED_GROUPS_FILE = 'allowed_groups.json'
28
- OWNERS_FILE = 'owners.json'
29
- LOG_FILE = 'bot_log.txt'
30
-
31
- bot = telebot.TeleBot(TELEGRAM_BOT_TOKEN, parse_mode='HTML')
32
-
33
- # DaTa SeT
34
- connected_clients = {}
35
- connected_clients_lock = threading.Lock()
36
- active_spam_targets = {}
37
- active_spam_lock = threading.Lock()
38
- activation_codes = {}
39
-
40
- #TiMp GrOuPs
41
- allowed_groups_cache = {}
42
- cache_last_updated = 0
43
- CACHE_TIMEOUT = 60
44
-
45
- def clean_text(text):
46
- if not text:
47
- return ""
48
- return str(text).replace('<', '&lt;').replace('>', '&gt;').replace('&', '&amp;')
49
-
50
- def log_action(action, user_id=None, details=""):
51
- timestamp = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
52
- log_entry = f"[{timestamp}] {action}"
53
- if user_id:
54
- log_entry += f" | User: {user_id}"
55
- if details:
56
- log_entry += f" | Details: {clean_text(details)}"
57
-
58
- with open(LOG_FILE, 'a', encoding='utf-8') as f:
59
- f.write(log_entry + "\n")
60
-
61
- def load_data(filename):
62
- max_retries = 3
63
- for attempt in range(max_retries):
64
- try:
65
- if not os.path.exists(filename):
66
- return {}
67
-
68
- with open(filename, 'r', encoding='utf-8') as f:
69
- data = json.load(f)
70
- return data
71
-
72
- except json.JSONDecodeError as e:
73
- if attempt == max_retries - 1:
74
- backup_file = f"{filename}.backup.{int(time.time())}"
75
- try:
76
- os.rename(filename, backup_file)
77
- except:
78
- pass
79
- return {}
80
- time.sleep(0.5)
81
-
82
- except Exception as e:
83
- if attempt == max_retries - 1:
84
- return {}
85
- time.sleep(0.5)
86
-
87
- return {}
88
-
89
- def save_data(data, filename):
90
- max_retries = 3
91
- for attempt in range(max_retries):
92
- try:
93
- os.makedirs(os.path.dirname(os.path.abspath(filename)), exist_ok=True)
94
-
95
- temp_file = None
96
- try:
97
- temp_file = tempfile.NamedTemporaryFile(
98
- mode='w',
99
- encoding='utf-8',
100
- delete=False,
101
- dir=os.path.dirname(filename) if os.path.dirname(filename) else '.',
102
- suffix='.tmp'
103
- )
104
-
105
- json.dump(data, temp_file, indent=4, ensure_ascii=False, sort_keys=True)
106
- temp_file.flush()
107
- os.fsync(temp_file.fileno())
108
- temp_file.close()
109
-
110
- if os.path.exists(filename):
111
- os.replace(temp_file.name, filename)
112
- else:
113
- os.rename(temp_file.name, filename)
114
-
115
- return
116
-
117
- except Exception as e:
118
- if temp_file and os.path.exists(temp_file.name):
119
- try:
120
- os.unlink(temp_file.name)
121
- except:
122
- pass
123
- raise e
124
-
125
- except Exception as e:
126
- if attempt == max_retries - 1:
127
- print(f"❌ فشل حفظ {filename} بعد {max_retries} محاولات")
128
- time.sleep(0.5)
129
-
130
- # OwNeRs SeT
131
- def load_owners():
132
- return load_data(OWNERS_FILE)
133
-
134
- def save_owners(owners_list):
135
- save_data(owners_list, OWNERS_FILE)
136
-
137
- def is_owner(user_id):
138
- owners = load_owners()
139
- return str(user_id) in owners
140
-
141
- def add_owner(user_id):
142
- owners = load_owners()
143
- owners[str(user_id)] = {
144
- "added_at": datetime.now().strftime('%Y-%m-%d %H:%M:%S'),
145
- "added_by": "system"
146
- }
147
- save_owners(owners)
148
- log_action("OWNER_ADDED", details=f"New owner: {user_id}")
149
-
150
- def remove_owner(user_id):
151
- owners = load_owners()
152
- if str(user_id) in owners:
153
- del owners[str(user_id)]
154
- save_owners(owners)
155
- log_action("OWNER_REMOVED", details=f"Removed owner: {user_id}")
156
- return True
157
- return False
158
-
159
- # GrOuP SeT
160
- def load_allowed_groups():
161
- global allowed_groups_cache, cache_last_updated
162
-
163
- current_time = time.time()
164
- if current_time - cache_last_updated < CACHE_TIMEOUT and allowed_groups_cache:
165
- return allowed_groups_cache
166
-
167
- data = load_data(ALLOWED_GROUPS_FILE)
168
-
169
- current_time = time.time()
170
- cleaned_data = {}
171
- expired_count = 0
172
-
173
- for group_id, group_data in data.items():
174
- expire_time = group_data.get('expire_at', 0)
175
- if expire_time > current_time:
176
- cleaned_data[group_id] = group_data
177
- else:
178
- expired_count += 1
179
-
180
- if expired_count > 0:
181
- save_data(cleaned_data, ALLOWED_GROUPS_FILE)
182
-
183
- allowed_groups_cache = cleaned_data
184
- cache_last_updated = current_time
185
-
186
- return cleaned_data
187
-
188
- def save_allowed_groups(data):
189
- global allowed_groups_cache, cache_last_updated
190
- save_data(data, ALLOWED_GROUPS_FILE)
191
- allowed_groups_cache = data
192
- cache_last_updated = time.time()
193
-
194
- def is_group_allowed(group_id):
195
- allowed_groups = load_allowed_groups()
196
- group_data = allowed_groups.get(str(group_id), {})
197
- expire_time = group_data.get('expire_at', 0)
198
-
199
- return expire_time > time.time()
200
-
201
- def add_allowed_group(group_id, days=365):
202
- allowed_groups = load_allowed_groups()
203
- expire_time = int(time.time()) + (days * 24 * 60 * 60)
204
-
205
- allowed_groups[str(group_id)] = {
206
- "expire_at": expire_time,
207
- "added_at": datetime.now().strftime('%Y-%m-%d %H:%M:%S'),
208
- "days": days,
209
- "expire_date": datetime.fromtimestamp(expire_time).strftime('%Y-%m-%d %H:%M:%S')
210
- }
211
-
212
- save_allowed_groups(allowed_groups)
213
-
214
- expire_date = datetime.fromtimestamp(expire_time).strftime('%Y-%m-%d %H:%M:%S')
215
- print(f"✅ تم تفعيل المجموعة {group_id} لمدة {days} يوم، تنتهي في: {expire_date}")
216
- log_action("GROUP_ADDED", details=f"Group: {group_id}, Days: {days}, Expire: {expire_date}")
217
-
218
- return expire_time
219
-
220
- def remove_allowed_group(group_id):
221
- allowed_groups = load_allowed_groups()
222
- group_id_str = str(group_id)
223
-
224
- if group_id_str in allowed_groups:
225
- del allowed_groups[group_id_str]
226
- save_allowed_groups(allowed_groups)
227
- print(f"🗑️ تم إلغاء تفعيل المجموعة: {group_id}")
228
- log_action("GROUP_REMOVED", details=f"Group: {group_id}")
229
-
230
- try:
231
- bot.send_message(group_id, "👋 GOOD BYE! - تم إلغاء تفعيل المجموعة.")
232
- time.sleep(1)
233
- bot.leave_chat(group_id)
234
- print(f"👋 غادر البوت المجموعة: {group_id}")
235
- log_action("GROUP_LEFT", details=f"Group: {group_id} - Removed by owner")
236
- except Exception as e:
237
- print(f"⚠️ لم يتمكن البوت من مغادرة المجموعة {group_id}: {e}")
238
- log_action("GROUP_LEAVE_ERROR", details=f"Group: {group_id} | Error: {str(e)}")
239
-
240
- return True
241
-
242
- print(f"⚠️ المجموعة {group_id} غير موجودة في القائمة")
243
- return False
244
-
245
- def check_and_leave_expired_groups():
246
- allowed_groups = load_allowed_groups()
247
- current_time = time.time()
248
- expired_groups = []
249
-
250
- for group_id, group_data in allowed_groups.items():
251
- if group_data.get('expire_at', 0) < current_time:
252
- expired_groups.append(group_id)
253
-
254
- for group_id in expired_groups:
255
- try:
256
- print(f"👋 مغادرة المجموعة المنتهية: {group_id}")
257
- bot.send_message(group_id, "👋 GOOD BYE! - انتهت فترة تفعيل المجموعة.")
258
- time.sleep(1)
259
- bot.leave_chat(group_id)
260
- log_action("GROUP_LEFT", details=f"Group: {group_id} - Subscription expired")
261
- except Exception as e:
262
- print(f"⚠️ خطأ في مغادرة المجموعة {group_id}: {e}")
263
- log_action("GROUP_LEAVE_ERROR", details=f"Group: {group_id} | Error: {str(e)}")
264
- finally:
265
- remove_allowed_group(group_id)
266
-
267
- if expired_groups:
268
- print(f"🧹 تمت مغادرة {len(expired_groups)} مجموعة منتهية الصلاحية")
269
-
270
- #LoGiN CoDe SeT
271
- def load_activation_codes():
272
- return load_data(ACTIVATION_CODES_FILE)
273
-
274
- def save_activation_codes(data):
275
- save_data(data, ACTIVATION_CODES_FILE)
276
-
277
- def generate_activation_code(days=365):
278
- code = ''.join(random.choices('ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789', k=16))
279
- activation_codes = load_activation_codes()
280
- activation_codes[code] = {
281
- "days": days,
282
- "created_at": datetime.now().strftime('%Y-%m-%d %H:%M:%S'),
283
- "used_by": None,
284
- "expire_at": int(time.time()) + (365 * 24 * 60 * 60),
285
- "expire_date": datetime.fromtimestamp(int(time.time()) + (365 * 24 * 60 * 60)).strftime('%Y-%m-%d %H:%M:%S')
286
- }
287
- save_activation_codes(activation_codes)
288
- log_action("CODE_GENERATED", details=f"Code: {code}, Days: {days}")
289
- return code
290
-
291
- def use_activation_code(code, user_id):
292
- activation_codes = load_activation_codes()
293
- code_data = activation_codes.get(code, {})
294
-
295
- if not code_data:
296
- return False, "الكود غير صالح"
297
-
298
- if code_data.get('used_by'):
299
- return False, "الكود مستخدم مسبقاً"
300
-
301
- if code_data.get('expire_at', 0) < time.time():
302
- return False, "الكود منتهي الصلاحية"
303
-
304
- days = code_data['days']
305
- expire_time = add_activation(user_id, days)
306
-
307
- code_data['used_by'] = user_id
308
- code_data['used_at'] = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
309
- activation_codes[code] = code_data
310
- save_activation_codes(activation_codes)
311
-
312
- log_action("CODE_USED", user_id, f"Code: {code}, Days: {days}")
313
- return True, f"تم تفعيل حسابك لمدة {days} يوم"
314
-
315
- # UsErS & AtTeMpTs SeT
316
- def add_user(user_id, username):
317
- users = load_data(USERS_FILE)
318
- users[str(user_id)] = {
319
- "username": clean_text(username),
320
- "spam_attempts": 3, # UsErS AtTeMpTs
321
- "last_reset": time.time(),
322
- "first_seen": datetime.now().strftime('%Y-%m-%d %H:%M:%S'),
323
- "last_active": datetime.now().strftime('%Y-%m-%d %H:%M:%S'),
324
- "is_owner": is_owner(user_id)
325
- }
326
- save_data(users, USERS_FILE)
327
- log_action("NEW_USER", user_id, f"Username: {username}")
328
-
329
- def get_user_attempts(user_id, command_type):
330
- users = load_data(USERS_FILE)
331
- user_data = users.get(str(user_id), {})
332
-
333
- if not user_data:
334
- username = "unknown"
335
- add_user(user_id, username)
336
- user_data = users.get(str(user_id), {})
337
-
338
- if has_unlimited_attempts(user_id) and command_type == 'spam':
339
- return float('inf')
340
-
341
- last_reset = user_data.get('last_reset', 0)
342
- current_time = time.time()
343
-
344
- if current_time - last_reset >= 2 * 60 * 60:
345
- user_data['spam_attempts'] = 3
346
- user_data['last_reset'] = current_time
347
- users[str(user_id)] = user_data
348
- save_data(users, USERS_FILE)
349
-
350
- if command_type == 'spam':
351
- return user_data.get('spam_attempts', 3)
352
- return 0
353
-
354
- def use_attempt(user_id, command_type):
355
- if has_unlimited_attempts(user_id) and command_type == 'spam':
356
- return True
357
-
358
- users = load_data(USERS_FILE)
359
- user_data = users.get(str(user_id), {})
360
-
361
- if command_type == 'spam':
362
- current_attempts = user_data.get('spam_attempts', 3)
363
- if current_attempts > 0:
364
- user_data['spam_attempts'] = current_attempts - 1
365
- users[str(user_id)] = user_data
366
- save_data(users, USERS_FILE)
367
- return True
368
- else:
369
- return False
370
-
371
- return False
372
-
373
- def has_unlimited_attempts(user_id):
374
- return is_owner(user_id) or is_user_activated(user_id)
375
-
376
- def update_user_activity(user_id):
377
- users = load_data(USERS_FILE)
378
- if str(user_id) in users:
379
- users[str(user_id)]['last_active'] = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
380
- save_data(users, USERS_FILE)
381
-
382
- def restore_expired_attempts():
383
- users = load_data(USERS_FILE)
384
- current_time = time.time()
385
- restored_count = 0
386
-
387
- for user_id, user_data in users.items():
388
- last_reset = user_data.get('last_reset', 0)
389
- if current_time - last_reset >= 2 * 60 * 60:
390
- if not has_unlimited_attempts(int(user_id)):
391
- user_data['spam_attempts'] = 3
392
- user_data['last_reset'] = current_time
393
- restored_count += 1
394
-
395
- if restored_count > 0:
396
- save_data(users, USERS_FILE)
397
- print(f"🔄 تم استعادة المحاولات لـ {restored_count} مستخدم")
398
-
399
- return restored_count
400
-
401
- def background_tasks():
402
- while True:
403
- try:
404
- expired_activations = check_expired_activations()
405
- check_and_leave_expired_groups()
406
- restore_expired_attempts()
407
- time.sleep(60 * 30)
408
-
409
- except Exception as e:
410
- time.sleep(60)
411
- # TeMpOrArY AcTiVaTiOn SeT
412
- def add_activation(user_id, days):
413
- activations = load_data(ACTIVATIONS_FILE)
414
- expire_time = int(time.time()) + (days * 24 * 60 * 60)
415
- activations[str(user_id)] = {
416
- "expire_at": expire_time,
417
- "activated_at": datetime.now().strftime('%Y-%m-%d %H:%M:%S'),
418
- "days": days,
419
- "expire_date": datetime.fromtimestamp(expire_time).strftime('%Y-%m-%d %H:%M:%S')
420
- }
421
- save_data(activations, ACTIVATIONS_FILE)
422
- log_action("USER_ACTIVATED", user_id, f"Days: {days}")
423
- return expire_time
424
-
425
- def is_user_activated(user_id):
426
- if is_owner(user_id):
427
- return True
428
-
429
- activations = load_data(ACTIVATIONS_FILE)
430
- user_activation = activations.get(str(user_id), {})
431
- expire_time = user_activation.get('expire_at', 0)
432
-
433
- if expire_time > time.time():
434
- return True
435
- else:
436
- if str(user_id) in activations:
437
- del activations[str(user_id)]
438
- save_data(activations, ACTIVATIONS_FILE)
439
- return False
440
-
441
- def has_unlimited_attempts(user_id):
442
- return is_owner(user_id) or is_user_activated(user_id)
443
-
444
- def get_activation_info(user_id):
445
- activations = load_data(ACTIVATIONS_FILE)
446
- return activations.get(str(user_id))
447
-
448
- def check_expired_activations():
449
- activations = load_data(ACTIVATIONS_FILE)
450
- current_time = time.time()
451
- expired = []
452
-
453
- for user_id, data in activations.items():
454
- if data.get('expire_at', 0) < current_time:
455
- expired.append(user_id)
456
-
457
- for user_id in expired:
458
- del activations[user_id]
459
-
460
- if expired:
461
- save_data(activations, ACTIVATIONS_FILE)
462
- log_action("ACTIVATIONS_EXPIRED", details=f"Count: {len(expired)}")
463
-
464
- return expired
465
-
466
- # VeRiFy PeRmIsSiOnS SeT
467
- def is_private_chat(message):
468
- return message.chat.type == 'private'
469
-
470
- def check_access(message):
471
- user_id = message.from_user.id
472
-
473
- if is_owner(user_id):
474
- return True
475
-
476
- if not is_private_chat(message):
477
- return is_group_allowed(message.chat.id)
478
-
479
- if is_private_chat(message):
480
- return is_user_activated(user_id)
481
-
482
- return False
483
-
484
- def should_respond(message):
485
- user_id = message.from_user.id
486
-
487
- if is_owner(user_id):
488
- return True
489
-
490
- if not is_private_chat(message):
491
- return is_group_allowed(message.chat.id)
492
-
493
- if is_private_chat(message):
494
- return is_user_activated(user_id)
495
-
496
- return False
497
-
498
- # RaNdOm CoLoR SeT
499
- def generate_random_color():
500
- color_list = [
501
- "[00FF00][b][c]", "[FFDD00][b][c]", "[3813F3][b][c]", "[FF0000][b][c]",
502
- "[0000FF][b][c]", "[FFA500][b][c]", "[DF07F8][b][c]", "[11EAFD][b][c]",
503
- "[DCE775][b][c]", "[A8E6CF][b][c]", "[7CB342][b][c]", "[FFB300][b][c]",
504
- "[90EE90][b][c]", "[FF4500][b][c]", "[FFD700][b][c]", "[32CD32][b][c]",
505
- "[87CEEB][b][c]", "[9370DB][b][c]", "[FF69B4][b][c]", "[8A2BE2][b][c]",
506
- "[00BFFF][b][c]", "[1E90FF][b][c]", "[20B2AA][b][c]", "[00FA9A][b][c]",
507
- "[008000][b][c]", "[FFFF00][b][c]", "[FF8C00][b][c]", "[DC143C][b][c]"
508
- ]
509
- return random.choice(color_list)
510
-
511
- def get_random_accounts(count=1):
512
- with connected_clients_lock:
513
- if not connected_clients:
514
- return []
515
- available_clients = list(connected_clients.values())
516
- if count >= len(available_clients):
517
- return available_clients
518
- return random.sample(available_clients, count)
519
-
520
- def AuTo_ResTartinG():
521
- time.sleep(6 * 60 * 60)
522
- print('\n - AuTo ResTartinG The BoT ... ! ')
523
- p = psutil.Process(os.getpid())
524
- for handler in p.open_files():
525
- try:
526
- os.close(handler.fd)
527
- except Exception as e:
528
- print(f" - Error CLose Files : {e}")
529
- for conn in p.net_connections():
530
- try:
531
- if hasattr(conn, 'fd'):
532
- os.close(conn.fd)
533
- except Exception as e:
534
- print(f" - Error CLose Connection : {e}")
535
- sys.path.append(os.path.dirname(os.path.abspath(sys.argv[0])))
536
- python = sys.executable
537
- os.execl(python, python, *sys.argv)
538
-
539
- def ResTarT_BoT():
540
- print('\n - ResTartinG The BoT ... ! ')
541
- p = psutil.Process(os.getpid())
542
- open_files = p.open_files()
543
- connections = p.net_connections()
544
- for handler in open_files:
545
- try:
546
- os.close(handler.fd)
547
- except Exception:
548
- pass
549
- for conn in connections:
550
- try:
551
- conn.close()
552
- except Exception:
553
- pass
554
- sys.path.append(os.path.dirname(os.path.abspath(sys.argv[0])))
555
- python = sys.executable
556
- os.execl(python, python, *sys.argv)
557
- # GhOsT SeT
558
- def execute_ghost_command(client, teamcode, name, user_id, client_number, clients_list):
559
- success = False
560
- try:
561
- if hasattr(client, 'CliEnts2') and client.CliEnts2 and hasattr(client, 'key') and client.key and hasattr(client, 'iv') and client.iv:
562
-
563
- join_packet = JoinTeamCode(teamcode, client.key, client.iv)
564
- client.CliEnts2.send(join_packet)
565
-
566
- start_time = time.time()
567
- response_received = False
568
-
569
- while time.time() - start_time < 8:
570
- try:
571
- if hasattr(client, 'DaTa2') and client.DaTa2 and len(client.DaTa2.hex()) > 30:
572
- hex_data = client.DaTa2.hex()
573
- if '0500' in hex_data[0:4]:
574
-
575
- try:
576
- if "08" in hex_data:
577
- decoded_data = DeCode_PackEt(f'08{hex_data.split("08", 1)[1]}')
578
- else:
579
- decoded_data = DeCode_PackEt(hex_data[10:])
580
-
581
- dT = json.loads(decoded_data)
582
-
583
- if "5" in dT and "data" in dT["5"]:
584
- team_data = dT["5"]["data"]
585
-
586
- if "31" in team_data and "data" in team_data["31"]:
587
- sq = team_data["31"]["data"]
588
- idT = team_data["1"]["data"]
589
-
590
- client.CliEnts2.send(ExitBot('000000', client.key, client.iv))
591
- time.sleep(0.2)
592
-
593
- ghost_packet = GhostPakcet(idT, name, sq, client.key, client.iv)
594
- client.CliEnts2.send(ghost_packet)
595
-
596
- success = True
597
- response_received = True
598
- break
599
-
600
- except Exception as decode_error:
601
- try:
602
- if len(hex_data) > 20:
603
- alternative_data = DeCode_PackEt(hex_data)
604
- if alternative_data:
605
- pass
606
- except:
607
- pass
608
-
609
- time.sleep(0.1)
610
-
611
- except Exception as loop_error:
612
- time.sleep(0.1)
613
-
614
- if not response_received:
615
- try:
616
- ghost_packet_alt = GhostPakcet(teamcode, name, "1", client.key, client.iv)
617
- client.CliEnts2.send(ghost_packet_alt)
618
- time.sleep(0.5)
619
- success = True
620
- except Exception as alt_error:
621
- pass
622
-
623
- else:
624
- pass
625
-
626
- except Exception as e:
627
- pass
628
-
629
- return success
630
-
631
- # SpAm SoLo & Sq SeT
632
- def infinite_spam_worker(target_id):
633
- while True:
634
- with active_spam_lock:
635
- if target_id not in active_spam_targets:
636
- break
637
-
638
- try:
639
- send_spam_from_all_accounts(target_id)
640
- time.sleep(0.1)
641
- except Exception as e:
642
- time.sleep(0.1)
643
-
644
- def send_spam_from_all_accounts(target_id):
645
- with connected_clients_lock:
646
- for account_id, client in connected_clients.items():
647
- try:
648
- if (hasattr(client, 'CliEnts2') and client.CliEnts2 and
649
- hasattr(client, 'key') and client.key and
650
- hasattr(client, 'iv') and client.iv):
651
-
652
- for i in range(10):
653
- try:
654
- client.CliEnts2.send(SEnd_InV(1, target_id, client.key, client.iv))
655
- client.CliEnts2.send(OpEnSq(client.key, client.iv))
656
- client.CliEnts2.send(SPamSq(target_id, client.key, client.iv))
657
- except (BrokenPipeError, ConnectionResetError, OSError) as e:
658
- break
659
- except Exception as e:
660
- break
661
- else:
662
- pass
663
- except Exception as e:
664
- pass
665
-
666
- # GhOsT LaG SeT
667
- def execute_blrx_command(client, teamcode, name, user_id, client_number):
668
- success = False
669
- try:
670
-
671
- if hasattr(client, 'CliEnts2') and client.CliEnts2 and hasattr(client, 'key') and client.key and hasattr(client, 'iv') and client.iv:
672
-
673
- join_packet = JoinTeamCode(teamcode, client.key, client.iv)
674
- client.CliEnts2.send(join_packet)
675
-
676
- start_time = time.time()
677
- response_received = False
678
- idT = None
679
- sq = None
680
-
681
- while time.time() - start_time < 8:
682
- try:
683
- if hasattr(client, 'DaTa2') and client.DaTa2 and len(client.DaTa2.hex()) > 30:
684
- hex_data = client.DaTa2.hex()
685
- if '0500' in hex_data[0:4]:
686
-
687
- try:
688
- if "08" in hex_data:
689
- decoded_data = DeCode_PackEt(f'08{hex_data.split("08", 1)[1]}')
690
- else:
691
- decoded_data = DeCode_PackEt(hex_data[10:])
692
-
693
- dT = json.loads(decoded_data)
694
-
695
- if "5" in dT and "data" in dT["5"]:
696
- team_data = dT["5"]["data"]
697
-
698
- if "31" in team_data and "data" in team_data["31"]:
699
- sq = team_data["31"]["data"]
700
- idT = team_data["1"]["data"]
701
-
702
- response_received = True
703
- break
704
-
705
- except Exception as decode_error:
706
- try:
707
- if len(hex_data) > 20:
708
- alternative_data = DeCode_PackEt(hex_data)
709
- if alternative_data:
710
- pass
711
- except:
712
- pass
713
-
714
- time.sleep(0.1)
715
-
716
- except Exception as loop_error:
717
- time.sleep(0.1)
718
-
719
- if response_received and idT and sq:
720
-
721
- for i in range(999):
722
- try:
723
- client.CliEnts2.send(JoinTeamCode(teamcode, client.key, client.iv))
724
- client.CliEnts2.send(GhostPakcet(idT, name, sq, client.key, client.iv))
725
- time.sleep(0.1)
726
- client.CliEnts2.send(ExitBot('000000', client.key, client.iv))
727
- client.CliEnts2.send(GhostPakcet(idT, name, sq, client.key, client.iv))
728
- except Exception as e:
729
- break
730
-
731
- success = True
732
-
733
- else:
734
- pass
735
-
736
- except Exception as e:
737
- pass
738
-
739
- return success
740
-
741
- # LaG SET
742
- def execute_lag_command(client, teamcode, user_id, client_number):
743
- success = False
744
- try:
745
-
746
- if hasattr(client, 'CliEnts2') and client.CliEnts2 and hasattr(client, 'key') and client.key and hasattr(client, 'iv') and client.iv:
747
-
748
- for i in range(400):
749
- try:
750
- client.CliEnts2.send(JoinTeamCode(teamcode, client.key, client.iv))
751
- client.CliEnts2.send(ExitBot('000000', client.key, client.iv))
752
- time.sleep(0.1)
753
- except Exception as e:
754
- break
755
-
756
- success = True
757
-
758
- else:
759
- pass
760
-
761
- except Exception as e:
762
- pass
763
-
764
- return success
765
-
766
- #C OnLiNe MeRo KInG SeT
767
- class FF_CLient():
768
-
769
- def __init__(self, id, password):
770
- self.id = id
771
- self.password = password
772
- self.key = None
773
- self.iv = None
774
- self.Get_FiNal_ToKen_0115()
775
-
776
- def Connect_SerVer_OnLine(self , Token , tok , host , port , key , iv , host2 , port2):
777
- try:
778
- self.AutH_ToKen_0115 = tok
779
- self.CliEnts2 = socket.create_connection((host2 , int(port2)))
780
- self.CliEnts2.send(bytes.fromhex(self.AutH_ToKen_0115))
781
- except:pass
782
- while True:
783
- try:
784
- self.DaTa2 = self.CliEnts2.recv(99999)
785
- if '0500' in self.DaTa2.hex()[0:4] and len(self.DaTa2.hex()) > 30:
786
- self.packet = json.loads(DeCode_PackEt(f'08{self.DaTa2.hex().split("08", 1)[1]}'))
787
- self.AutH = self.packet['5']['data']['7']['data']
788
-
789
- except:pass
790
-
791
- def Connect_SerVer(self , Token , tok , host , port , key , iv , host2 , port2):
792
- self.AutH_ToKen_0115 = tok
793
- self.CliEnts = socket.create_connection((host , int(port)))
794
- self.CliEnts.send(bytes.fromhex(self.AutH_ToKen_0115))
795
- self.DaTa = self.CliEnts.recv(1024)
796
- threading.Thread(target=self.Connect_SerVer_OnLine, args=(Token , tok , host , port , key , iv , host2 , port2)).start()
797
- self.Exemple = xMsGFixinG('12345678')
798
-
799
- self.key = key
800
- self.iv = iv
801
-
802
- with connected_clients_lock:
803
- connected_clients[self.id] = self
804
-
805
- while True:
806
- try:
807
- self.DaTa = self.CliEnts.recv(1024)
808
- if len(self.DaTa) == 0 or (hasattr(self, 'DaTa2') and len(self.DaTa2) == 0):
809
- try:
810
- self.CliEnts.close()
811
- if hasattr(self, 'CliEnts2'):
812
- self.CliEnts2.close()
813
- self.Connect_SerVer(Token , tok , host , port , key , iv , host2 , port2)
814
- except:
815
- try:
816
- self.CliEnts.close()
817
- if hasattr(self, 'CliEnts2'):
818
- self.CliEnts2.close()
819
- self.Connect_SerVer(Token , tok , host , port , key , iv , host2 , port2)
820
- except:
821
- self.CliEnts.close()
822
- if hasattr(self, 'CliEnts2'):
823
- self.CliEnts2.close()
824
- ResTarT_BoT()
825
- # MeRo KiNg MsG In BoT xFFx
826
- if '1200' in self.DaTa.hex()[0:4] and 900 > len(self.DaTa.hex()) > 100:
827
- if b"***" in self.DaTa:
828
- self.DaTa = self.DaTa.replace(b"***",b"106")
829
- try:
830
- self.BesTo_data = json.loads(DeCode_PackEt(self.DaTa.hex()[10:]))
831
- self.input_msg = 'besto_love' if '8' in self.BesTo_data["5"]["data"] else self.BesTo_data["5"]["data"]["4"]["data"]
832
- except:
833
- self.input_msg = None
834
- self.DeCode_CliEnt_Uid = self.BesTo_data["5"]["data"]["1"]["data"]
835
- self.CliEnt_Uid = EnC_Uid(self.DeCode_CliEnt_Uid , Tp = 'Uid')
836
-
837
- if 'besto_love' in self.input_msg[:10]:
838
- self.CliEnts.send(GenResponsMsg(f'''
839
- [C][B][000000]━━━━━━━━━━━━
840
-
841
- [FFD700]🇾🇪 رافينيااااااااا الله الله الله 🤫
842
-
843
- [FF4500]🔥.ميسي لديكم. لاخوف عليكم 🔥
844
-
845
- [00FF7F]😋 انا مش الكمال بس الجمال فيني
846
- [87CEEB]🤤 والي تعرفني تبغئ تخليني 🙄
847
-
848
- [C][B][000000]━━━━━━━━━━━━
849
-
850
- [FFD700]🇾🇪:اللهـم صل وسلم على نبينا محمد وعلى آله وصحبه أجمعين
851
- [00BFFF]💞 صنع البوت ليكون الأفضل
852
- [00BFFF]🇾🇪:دمت لتأريخ ياوطني 🇾🇪
853
-
854
- [ff0000]██‌█‌██
855
- [ffffff]█████
856
- [000000]██‌███
857
-
858
- [C][B][000000]━━━━━━━━━━━━''', 2 , self.DeCode_CliEnt_Uid , self.DeCode_CliEnt_Uid , key , iv))
859
- time.sleep(0.3)
860
- self.CliEnts.close()
861
- if hasattr(self, 'CliEnts2'):
862
- self.CliEnts2.close()
863
- self.Connect_SerVer(Token , tok , host , port , key , iv , host2 , port2)
864
-
865
-
866
- except Exception as e:
867
- try:
868
- self.CliEnts.close()
869
- if hasattr(self, 'CliEnts2'):
870
- self.CliEnts2.close()
871
- except:
872
- pass
873
- self.Connect_SerVer(Token , tok , host , port , key , iv , host2 , port2)
874
-
875
- def GeT_Key_Iv(self , serialized_data):
876
- my_message = xKEys.MyMessage()
877
- my_message.ParseFromString(serialized_data)
878
- timestamp , key , iv = my_message.field21 , my_message.field22 , my_message.field23
879
- timestamp_obj = Timestamp()
880
- timestamp_obj.FromNanoseconds(timestamp)
881
- timestamp_seconds = timestamp_obj.seconds
882
- timestamp_nanos = timestamp_obj.nanos
883
- combined_timestamp = timestamp_seconds * 1_000_000_000 + timestamp_nanos
884
- return combined_timestamp , key , iv
885
-
886
- def Guest_GeneRaTe(self , uid , password):
887
- self.url = "https://100067.connect.garena.com/oauth/guest/token/grant"
888
- self.headers = {
889
- "Host": "100067.connect.garena.com",
890
- "User-Agent": "GarenaMSDK/4.0.19P4(G011A ;Android 9;en;US;)",
891
- "Content-Type": "application/x-www-form-urlencoded",
892
- "Accept-Encoding": "gzip, deflate, br",
893
- "Connection": "close"
894
- }
895
- self.dataa = {
896
- "uid": f"{uid}",
897
- "password": f"{password}",
898
- "response_type": "token",
899
- "client_type": "2",
900
- "client_secret": "2ee44819e9b4598845141067b281621874d0d5d7af9d8f7e00c1e54715b7d1e3",
901
- "client_id": "100067"
902
- }
903
-
904
- try:
905
- if not uid or not password:
906
- print(f"❌ بيانات الحساب غير صالحة: {uid}")
907
- time.sleep(5)
908
- return self.Guest_GeneRaTe(uid, password)
909
-
910
- self.response = requests.post(self.url, headers=self.headers, data=self.dataa, timeout=30)
911
-
912
- if self.response.status_code != 200:
913
- print(f"❌ خطأ في الاستجابة: {self.response.status_code}")
914
- time.sleep(5)
915
- return self.Guest_GeneRaTe(uid, password)
916
-
917
- response_data = self.response.json()
918
-
919
- if 'access_token' not in response_data or 'open_id' not in response_data:
920
- print(f"❌ بيانات الاستجابة غير مكتملة: {response_data}")
921
- time.sleep(5)
922
- return self.Guest_GeneRaTe(uid, password)
923
-
924
- self.Access_ToKen = response_data['access_token']
925
- self.Access_Uid = response_data['open_id']
926
-
927
- print(f'✅ تم الحصول على التوكن للحساب: {uid}')
928
- time.sleep(0.5)
929
-
930
- return self.ToKen_GeneRaTe(self.Access_ToKen , self.Access_Uid)
931
-
932
- except requests.exceptions.RequestException as e:
933
- print(f"❌ خطأ في الاتصال للحساب {uid}: {e}")
934
- time.sleep(5)
935
- return self.Guest_GeneRaTe(uid, password)
936
- except Exception as e:
937
- print(f"❌ خطأ غير متوقع للحساب {uid}: {e}")
938
- time.sleep(2)
939
- return self.Guest_GeneRaTe(uid, password)
940
-
941
- def GeT_LoGin_PorTs(self , JwT_ToKen , PayLoad):
942
- self.UrL = 'https://clientbp.ggwhitehawk.com/GetLoginData'
943
- self.HeadErs = {
944
- 'Expect': '100-continue',
945
- 'Authorization': f'Bearer {JwT_ToKen}',
946
- 'X-Unity-Version': '2018.4.11f1',
947
- 'X-GA': 'v1 1',
948
- 'ReleaseVersion': 'OB52',
949
- 'Content-Type': 'application/x-www-form-urlencoded',
950
- 'User-Agent': 'Dalvik/2.1.0 (Linux; U; Android 9; G011A Build/PI)',
951
- 'Host': 'clientbp.ggwhitehawk.com',
952
- 'Connection': 'close',
953
- 'Accept-Encoding': 'gzip, deflate, br'
954
- }
955
- try:
956
- self.Res = requests.post(self.UrL, headers=self.HeadErs, data=PayLoad, verify=False, timeout=30)
957
-
958
- if self.Res.content:
959
- hex_content = self.Res.content.hex()
960
- try:
961
- self.BesTo_data = json.loads(DeCode_PackEt(hex_content))
962
- address = self.BesTo_data['32']['data']
963
- address2 = self.BesTo_data['14']['data']
964
-
965
- ip = address[:len(address) - 6]
966
- ip2 = address2[:len(address) - 6]
967
- port = address[len(address) - 5:]
968
- port2 = address2[len(address2) - 5:]
969
-
970
- return ip , port , ip2 , port2
971
- except Exception as e:
972
- print(f"❌ خطأ في معالجة بيانات البورت: {e}")
973
- return None, None, None, None
974
- else:
975
- print("❌ لا توجد بيانات في الاستجابة")
976
- return None, None, None, None
977
-
978
- except requests.RequestException as e:
979
- print(f"❌ خطأ في طلب البورتات: {e}")
980
- return None, None, None, None
981
- except Exception as e:
982
- print(f"❌ خطأ غير متوقع في طلب البورتات: {e}")
983
- return None, None, None, None
984
- #PyL MeRo
985
- def ToKen_GeneRaTe(self , Access_ToKen , Access_Uid):
986
- self.UrL = "https://loginbp.ggwhitehawk.com/MajorLogin"
987
- self.HeadErs = {
988
- 'X-Unity-Version': '2018.4.11f1',
989
- 'ReleaseVersion': 'OB52',
990
- 'Content-Type': 'application/x-www-form-urlencoded',
991
- 'X-GA': 'v1 1',
992
- 'Content-Length': '928',
993
- 'User-Agent': 'Dalvik/2.1.0 (Linux; U; Android 7.1.2; ASUS_Z01QD Build/QKQ1.190825.002)',
994
- 'Host': 'clientbp.ggwhitehawk.com',
995
- 'Connection': 'Keep-Alive',
996
- 'Accept-Encoding': 'gzip'
997
- }
998
-
999
- base_data = '1a13323032352d31312d32362030313a35313a3238220966726565206669726528013a07312e3132302e314232416e64726f6964204f532039202f204150492d3238202850492f72656c2e636a772e32303232303531382e313134313333294a0848616e6468656c64520c4d544e2f537061636574656c5a045749464960800a68d00572033234307a2d7838362d3634205353453320535345342e3120535345342e32204156582041565832207c2032343030207c20348001e61e8a010f416472656e6f2028544d292036343092010d4f70656e474c20455320332e329a012b476f6f676c657c36323566373136662d393161372d343935622d396631362d303866653964336336353333a2010e3137362e32382e3133392e313835aa01026172b201203433303632343537393364653836646134323561353263616164663231656564ba010134c2010848616e6468656c64ca010d4f6e65506c7573204135303130ea014063363961653230386661643732373338623637346232383437623530613361316466613235643161313966616537343566633736616334613065343134633934f00101ca020c4d544e2f537061636574656cd2020457494649ca03203161633462383065636630343738613434323033626638666163363132306635e003b5ee02e8039a8002f003af13f80384078004a78f028804b5ee029004a78f029804b5ee02b00404c80401d2043d2f646174612f6170702f636f6d2e6474732e667265656669726574682d66705843537068495636644b43376a4c2d574f7952413d3d2f6c69622f61726de00401ea045f65363261623933353464386662356662303831646233333861636233333439317c2f646174612f6170702f636f6d2e6474732e667265656669726574682d66705843537068495636644b43376a4c2d574f7952413d3d2f626173652e61706bf00406f804018a050233329a050a32303139313139303236a80503b205094f70656e474c455332b805ff01c00504e005be7eea05093372645f7061727479f205704b717348543857393347646347335a6f7a454e6646775648746d377171316552554e6149444e67526f626f7a4942744c4f695943633459367a767670634943787a514632734f453463627974774c7334785a62526e70524d706d5752514b6d654f35766373386e51594268777148374bf805e7e4068806019006019a060134a2060134b2062213521146500e590349510e460900115843395f005b510f685b560a6107576d0f0366'
1000
-
1001
- try:
1002
- self.dT = bytes.fromhex(base_data)
1003
-
1004
- current_time = str(datetime.now())[:-7].encode()
1005
- self.dT = self.dT.replace(b'2025-07-30 14:11:20', current_time)
1006
- self.dT = self.dT.replace(b'c69ae208fad72738b674b2847b50a3a1dfa25d1a19fae745fc76ac4a0e414c94', Access_ToKen.encode())
1007
- self.dT = self.dT.replace(b'4306245793de86da425a52caadf21eed', Access_Uid.encode())
1008
-
1009
- try:
1010
- hex_data = self.dT.hex()
1011
- if all(c in '0123456789abcdef' for c in hex_data):
1012
- encoded_data = EnC_AEs(hex_data)
1013
- self.PaYload = bytes.fromhex(encoded_data)
1014
- else:
1015
- print("❌ بيانات غير صالحة للتشفير")
1016
- self.PaYload = self.dT
1017
- except Exception as encoding_error:
1018
- print(f"❌ خطأ في التشفير: {encoding_error}")
1019
- self.PaYload = self.dT
1020
-
1021
- except ValueError as e:
1022
- print(f"❌ خطأ في تحويل البيانات: {e}")
1023
- self.PaYload = f"uid={Access_Uid}&token={Access_ToKen}".encode()
1024
-
1025
- try:
1026
- self.ResPonse = requests.post(self.UrL, headers=self.HeadErs, data=self.PaYload, verify=False, timeout=30)
1027
-
1028
- if self.ResPonse.status_code == 200 and len(self.ResPonse.text) > 10:
1029
- try:
1030
- if self.ResPonse.content:
1031
- hex_content = self.ResPonse.content.hex()
1032
- self.BesTo_data = json.loads(DeCode_PackEt(hex_content))
1033
- self.JwT_ToKen = self.BesTo_data['8']['data']
1034
- self.combined_timestamp , self.key , self.iv = self.GeT_Key_Iv(self.ResPonse.content)
1035
- ip , port , ip2 , port2 = self.GeT_LoGin_PorTs(self.JwT_ToKen , self.PaYload)
1036
- return self.JwT_ToKen , self.key , self.iv, self.combined_timestamp , ip , port , ip2 , port2
1037
- else:
1038
- print("❌ لا توجد بيانات في استجابة التوكن")
1039
- raise Exception("No data in token response")
1040
- except Exception as e:
1041
- print(f"❌ خطأ في تحليل استجابة التوكن: {e}")
1042
- time.sleep(2)
1043
- return self.ToKen_GeneRaTe(Access_ToKen, Access_Uid)
1044
- else:
1045
- print(f"❌ خطأ في استجابة التوكن، الحالة: {self.ResPonse.status_code}")
1046
- time.sleep(2)
1047
- return self.ToKen_GeneRaTe(Access_ToKen, Access_Uid)
1048
-
1049
- except requests.RequestException as e:
1050
- print(f"❌ خطأ في طلب التوكن: {e}")
1051
- time.sleep(5)
1052
- return self.ToKen_GeneRaTe(Access_ToKen, Access_Uid)
1053
- except Exception as e:
1054
- print(f"❌ خطأ غير متوقع في طلب التوكن: {e}")
1055
- time.sleep(2)
1056
- return self.ToKen_GeneRaTe(Access_ToKen, Access_Uid)
1057
-
1058
- def Get_FiNal_ToKen_0115(self):
1059
- try:
1060
- result = self.Guest_GeneRaTe(self.id , self.password)
1061
- if not result:
1062
- print("❌ فشل في الحصول على التوكنات، إعادة المحاولة...")
1063
- time.sleep(2)
1064
- return self.Get_FiNal_ToKen_0115()
1065
-
1066
- token , key , iv , Timestamp , ip , port , ip2 , port2 = result
1067
-
1068
- if not all([ip, port, ip2, port2]):
1069
- print("❌ فشل في الحصول على البورتات، إعادة المحاولة...")
1070
- time.sleep(2)
1071
- return self.Get_FiNal_ToKen_0115()
1072
-
1073
- self.JwT_ToKen = token
1074
- try:
1075
- self.AfTer_DeC_JwT = jwt.decode(token, options={"verify_signature": False})
1076
- self.AccounT_Uid = self.AfTer_DeC_JwT.get('account_id')
1077
- self.EncoDed_AccounT = hex(self.AccounT_Uid)[2:]
1078
- self.HeX_VaLue = DecodE_HeX(Timestamp)
1079
- self.TimE_HEx = self.HeX_VaLue
1080
- self.JwT_ToKen_ = token.encode().hex()
1081
- except Exception as e:
1082
- print(f"❌ خطأ في فك التوكن: {e}")
1083
- time.sleep(2)
1084
- return self.Get_FiNal_ToKen_0115()
1085
-
1086
- try:
1087
- self.Header = hex(len(EnC_PacKeT(self.JwT_ToKen_, key, iv)) // 2)[2:]
1088
- length = len(self.EncoDed_AccounT)
1089
- self.__ = '00000000'
1090
- if length == 9: self.__ = '0000000'
1091
- elif length == 8: self.__ = '00000000'
1092
- elif length == 10: self.__ = '000000'
1093
- elif length == 7: self.__ = '000000000'
1094
- else:
1095
- print('Unexpected length encountered')
1096
- self.Header = f'0115{self.__}{self.EncoDed_AccounT}{self.TimE_HEx}00000{self.Header}'
1097
- self.FiNal_ToKen_0115 = self.Header + EnC_PacKeT(self.JwT_ToKen_ , key , iv)
1098
- except Exception as e:
1099
- print(f"❌ خطأ في التوكن النهائي: {e}")
1100
- time.sleep(5)
1101
- return self.Get_FiNal_ToKen_0115()
1102
-
1103
- self.AutH_ToKen = self.FiNal_ToKen_0115
1104
- self.Connect_SerVer(self.JwT_ToKen , self.AutH_ToKen , ip , port , key , iv , ip2 , port2)
1105
- return self.AutH_ToKen , key , iv
1106
-
1107
- except Exception as e:
1108
- print(f"❌ خطأ في Get_FiNal_ToKen_0115: {e}")
1109
- time.sleep(10)
1110
- return self.Get_FiNal_ToKen_0115()
1111
-
1112
- #AcSS MeRo SeT
1113
- ACCOUNTS = []
1114
-
1115
- def load_accounts_from_file(filename="accs.txt"):
1116
- accounts = []
1117
- try:
1118
- with open(filename, "r", encoding="utf-8") as file:
1119
- for line in file:
1120
- line = line.strip()
1121
- if line and not line.startswith("#"):
1122
- if ":" in line:
1123
- parts = line.split(":")
1124
- if len(parts) >= 2:
1125
- account_id = parts[0].strip()
1126
- password = parts[1].strip()
1127
- accounts.append({'id': account_id, 'password': password})
1128
- else:
1129
- accounts.append({'id': line.strip(), 'password': ''})
1130
- print(f"تم تحميل {len(accounts)} حساب من {filename}")
1131
- except FileNotFoundError:
1132
- print(f"ملف {filename} غير موجود!")
1133
- except Exception as e:
1134
- print(f"حدث خطأ أثناء قراءة الملف: {e}")
1135
-
1136
- return accounts
1137
-
1138
- ACCOUNTS = load_accounts_from_file()
1139
-
1140
- if not ACCOUNTS:
1141
- ACCOUNTS = [{'id': '3994798222', 'password': '54B0B5C7CC48EFB7BAE3F4B49CC49DC9F433322C34185CC320B581FC48CAA1AF'}]
1142
-
1143
- def start_account(account):
1144
- try:
1145
- FF_CLient(account['id'], account['password'])
1146
- except Exception as e:
1147
- print(f"❌ Error starting account {account['id']}: {e}")
1148
- time.sleep(2)
1149
- start_account(account)
1150
-
1151
- # 5 Sq & 6 Sq SeT
1152
- def execute_5x_command(client, target_id, user_id, client_number):
1153
- success = False
1154
- try:
1155
-
1156
- if hasattr(client, 'CliEnts2') and client.CliEnts2 and hasattr(client, 'key') and client.key and hasattr(client, 'iv') and client.iv:
1157
-
1158
- account_uid = getattr(client, 'AccounT_Uid', client.id)
1159
-
1160
- client.CliEnts2.send(OpEnSq(client.key, client.iv))
1161
- time.sleep(0.5)
1162
-
1163
- client.CliEnts2.send(cHSq(5, account_uid, client.key, client.iv))
1164
- time.sleep(0.5)
1165
-
1166
- client.CliEnts2.send(SEnd_InV(1, target_id, client.key, client.iv))
1167
- time.sleep(5)
1168
- client.CliEnts2.send(ExitBot('000000' , client.key, client.iv))
1169
- success = True
1170
-
1171
- else:
1172
- pass
1173
-
1174
- except Exception as e:
1175
- pass
1176
-
1177
- return success
1178
-
1179
- def execute_6x_command(client, target_id, user_id, client_number):
1180
- success = False
1181
- try:
1182
-
1183
- if hasattr(client, 'CliEnts2') and client.CliEnts2 and hasattr(client, 'key') and client.key and hasattr(client, 'iv') and client.iv:
1184
-
1185
- account_uid = getattr(client, 'AccounT_Uid', client.id)
1186
-
1187
- client.CliEnts2.send(OpEnSq(client.key, client.iv))
1188
- time.sleep(0.5)
1189
-
1190
- client.CliEnts2.send(cHSq(6, account_uid, client.key, client.iv))
1191
- time.sleep(0.5)
1192
-
1193
- client.CliEnts2.send(SEnd_InV(1, target_id, client.key, client.iv))
1194
- time.sleep(5)
1195
- client.CliEnts2.send(ExitBot('000000' , client.key, client.iv))
1196
- success = True
1197
-
1198
- else:
1199
- pass
1200
-
1201
- except Exception as e:
1202
- pass
1203
-
1204
- return success
1205
-
1206
- # BaCk TaSk MeRo SeT
1207
- def background_tasks():
1208
- while True:
1209
- try:
1210
- expired_activations = check_expired_activations()
1211
- check_and_leave_expired_groups()
1212
- time.sleep(60 * 30)
1213
-
1214
- except Exception as e:
1215
- time.sleep(60)
1216
-
1217
- # BoT TeLeGrAm SeT
1218
- def silent_ignore(message):
1219
- pass
1220
-
1221
- # LoGin CoDe SeT
1222
- def handle_activation_code(message):
1223
- user_id = message.from_user.id
1224
- code = message.text.upper()
1225
-
1226
- # الحصول على معلومات المستخدم الحقيقية
1227
- username = message.from_user.username
1228
- first_name = message.from_user.first_name
1229
- last_name = message.from_user.last_name
1230
-
1231
- # بناء اسم المستخدم
1232
- if username:
1233
- display_username = f"@{username}"
1234
- else:
1235
- display_username = first_name or "مستخدم"
1236
- if last_name:
1237
- display_username += f" {last_name}"
1238
-
1239
- # إضافة المستخدم إذا لم يكن موجوداً
1240
- if not load_data(USERS_FILE).get(str(user_id)):
1241
- add_user(user_id, display_username)
1242
-
1243
- try:
1244
- success, message_text = use_activation_code(code, user_id)
1245
-
1246
- if success:
1247
- activation_info = get_activation_info(user_id)
1248
- expire_date = datetime.fromtimestamp(activation_info['expire_at']).strftime('%Y-%m-%d %H:%M:%S')
1249
-
1250
- response_text = f"""
1251
- ✅ <b>تم تفعيل حسابك بنجاح!</b>
1252
-
1253
- 📝 <b>تفاصيل التفعيل:</b>
1254
- 👤 المستخدم: {display_username}
1255
- 🆔 المعرف: <code>{user_id}</code>
1256
- ⏰ تاريخ الانتهاء: {expire_date}
1257
- 🔑 الكود المستخدم: <code>{code}</code>
1258
-
1259
- 💎 <b>الآن يمكنك استخدام جميع أوامر البوت</b>
1260
- """
1261
- else:
1262
- response_text = f"❌ <b>{message_text}</b>"
1263
-
1264
- bot.send_message(message.chat.id, response_text, reply_to_message_id=message.message_id)
1265
- update_user_activity(user_id)
1266
-
1267
- except Exception as e:
1268
- bot.send_message(message.chat.id, f"❌ <b>حدث خطأ أثناء التفعيل:</b> {str(e)}", reply_to_message_id=message.message_id)
1269
- log_action("DIRECT_ACTIVATION_ERROR", user_id, str(e))
1270
-
1271
- # xC MsG SeT
1272
- def is_command(message, command_name):
1273
- text = message.text.lower().strip()
1274
- command_name = command_name.lower()
1275
-
1276
- if text.startswith(f'/{command_name}') or f'/{command_name}' in text:
1277
- return True
1278
-
1279
- return False
1280
-
1281
- # HeLp MsG SeT
1282
- @bot.message_handler(func=lambda message: is_command(message, 'help'))
1283
- def handle_help_command(message):
1284
- if not should_respond(message):
1285
- return silent_ignore(message)
1286
-
1287
- user_id = message.from_user.id
1288
-
1289
- help_text = """
1290
- <b>🤖 أوامر البوت:</b>
1291
-
1292
- ┌─────────────
1293
- │ <code>/ghost</code> [كود الفريق] - دخول أشباح للفريق
1294
- │ <code>/blrx</code> [كود الفريق] - هجوم أشباح على الفريق
1295
- │ <code>/hex</code> [آيدي اللاعب] - بدء المقبرة على اللاعب
1296
- │ <code>/stop</code> [آيدي اللاعب] - إيقاف المقبرة
1297
- │ <code>/5</code> [آيدي اللاعب] - إرسال فريق 5
1298
- │ <code>/6</code> [آيدي اللاعب] - إرسال فريق 6
1299
- │ <code>/lag</code> [كود الفريق] - تنفيذ هجوم على الفريق
1300
- │ <code>/add</code> [آيدي اللاعب] [الوقت] - إضافة البوت للاعب
1301
- │ <code>/remove</code> [آيدي اللاعب] - إزالة البوت من اللاعب
1302
- │ <code>/report</code> [النص] - إرسال ملاحظات للمالك
1303
- └─────────────
1304
- """
1305
-
1306
- if is_owner(user_id):
1307
- help_text += """
1308
- <b>👑 أوامر المطور:</b>
1309
-
1310
- ┌─────────────
1311
- │ <code>/login</code> [الوقت] - إنشاء كود تفعيل
1312
- │ <code>/allow</code> [آيدي المجموعة] [الوقت] - تفعيل المجموعة
1313
- │ <code>/unallow</code> [آيدي المجموعة] - إلغاء التفعيل
1314
- │ <code>/addowner</code> [آيدي المستخدم] - إضافة مالك
1315
- │ <code>/removeowner</code> [آيدي المستخدم] - إزالة مالك
1316
- │ <code>/listowners</code> - قائمة المالكين
1317
- │ <code>/restart</code> - إعادة التشغيل
1318
- │ <code>/status</code> - حالة البوت
1319
- │ <code>/accounts</code> - الحسابات المتصلة
1320
- │ <code>/list</code> - عرض المعرفات المضافة للبوت
1321
- │ <code>/removeall</code> - حذف جميع المعرفات
1322
- └─────────────
1323
- """
1324
-
1325
- bot.send_message(message.chat.id, help_text, parse_mode='HTML', reply_to_message_id=message.message_id)
1326
- log_action("HELP_REQUESTED", user_id)
1327
- update_user_activity(user_id)
1328
- # RePoRt MsG SeT
1329
- @bot.message_handler(func=lambda message: is_command(message, 'report'))
1330
- def handle_report_command(message):
1331
- if not should_respond(message):
1332
- return silent_ignore(message)
1333
-
1334
- user_id = message.from_user.id
1335
-
1336
- try:
1337
- parts = message.text.split(maxsplit=1)
1338
- if len(parts) < 2:
1339
- bot.send_message(message.chat.id,
1340
- "⚠️ <b>يرجى إدخال نص البلاغ</b>\n"
1341
- "📝 <b>مثال:</b> <code>/report يوجد مشكلة في البوت</code>",
1342
- reply_to_message_id=message.message_id)
1343
- return
1344
-
1345
- report_text = parts[1]
1346
-
1347
- clean_report = clean_text(report_text)
1348
-
1349
- #GeT UeSr InFo XXXXXX
1350
- user_info = bot.get_chat(user_id)
1351
- username = f"@{user_info.username}" if user_info.username else user_info.first_name
1352
-
1353
- report_message = f"""
1354
- 🚨 <b>NeW RePoRt MsG</b>
1355
-
1356
- 👤 <b>UsEr:</b> {username}
1357
- 🆔 <b>UsEr Id:</b> <code>{user_id}</code>
1358
- ⏰ <b>TiMe:</b> {datetime.now().strftime('%Y-%m-%d %H:%M:%S')}
1359
-
1360
- 📝 <b>TeXt RePoRt:</b>
1361
- {clean_report}
1362
- """
1363
-
1364
- owners = load_owners()
1365
- sent_count = 0
1366
-
1367
- for owner_id in owners.keys():
1368
- try:
1369
- bot.send_message(int(owner_id), report_message)
1370
- sent_count += 1
1371
- time.sleep(0.5) # WaRNiNg WaRNiNg WaRNiNg WaRNiNg WaRNiNg To NoT BaN BoT FrOm TeLe
1372
- except Exception as e:
1373
- print(f"❌ لم يتمكن من إرسال البلاغ للمالك {owner_id}: {e}")
1374
-
1375
- if sent_count > 0:
1376
- bot.send_message(message.chat.id,
1377
- f"✅ <b>تم إرسال بلاغك بنجاح إلى المالكين</b>\n"
1378
- f"📝 سيتم مراجعة بلاغك في أقرب وقت",
1379
- reply_to_message_id=message.message_id)
1380
- else:
1381
- bot.send_message(message.chat.id,
1382
- "❌ <b>لم يتم إرسال بلاغك - لا توجد حسابات مالكين نشطة</b>",
1383
- reply_to_message_id=message.message_id)
1384
-
1385
- log_action("REPORT_SENT", user_id, f"Recipients: {sent_count}, Text: {clean_report[:100]}...")
1386
- update_user_activity(user_id)
1387
-
1388
- except Exception as e:
1389
- bot.send_message(message.chat.id,
1390
- f"❌ <b>حدث خطأ أثناء إرسال البلاغ:</b> {str(e)}",
1391
- reply_to_message_id=message.message_id)
1392
- log_action("REPORT_COMMAND_ERROR", user_id, str(e))
1393
- # TeMp MsG SeT
1394
- def send_temp_message(chat_id, text, reply_to_message_id=None):
1395
- try:
1396
- sent_message = bot.send_message(chat_id, text, reply_to_message_id=reply_to_message_id)
1397
- return sent_message.message_id
1398
- except Exception as e:
1399
- print(f"❌ خطأ في إرسال الرسالة المؤقتة: {e}")
1400
- return None
1401
- # DeLeT MsG SeT
1402
- def delete_message(chat_id, message_id):
1403
- try:
1404
- bot.delete_message(chat_id, message_id)
1405
- return True
1406
- except Exception as e:
1407
- print(f"❌ خطأ في حذف الرسالة: {e}")
1408
- return False
1409
- # GhOsT MsG SeT
1410
- @bot.message_handler(func=lambda message: is_command(message, 'ghost'))
1411
- def handle_ghost_command(message):
1412
- if not should_respond(message):
1413
- return silent_ignore(message)
1414
-
1415
- user_id = message.from_user.id
1416
- temp_message_id = None
1417
-
1418
- try:
1419
- parts = message.text.split()
1420
- if len(parts) < 3:
1421
- bot.send_message(message.chat.id,
1422
- "⚠️ <b>يرجى إدخال teamcode و name</b>\n"
1423
- "📝 <b>مثال:</b> <code>/ghost 12345678 mero</code>",
1424
- reply_to_message_id=message.message_id)
1425
- return
1426
-
1427
- teamcode = parts[1]
1428
- name = ' '.join(parts[2:])
1429
-
1430
- if not ChEck_Commande(teamcode):
1431
- bot.send_message(message.chat.id, "❌ <b>teamcode غير صالح</b>", reply_to_message_id=message.message_id)
1432
- return
1433
-
1434
-
1435
- temp_message_id = send_temp_message(message.chat.id,
1436
- f"⏳ <b>جاري تنفيذ أمر الشبح...</b>\n"
1437
- f"🏷️ الفريق: <code>{teamcode}</code>\n"
1438
- f"👻 الاسم: {name}",
1439
- reply_to_message_id=message.message_id)
1440
-
1441
- clients_list = get_random_accounts(4)
1442
-
1443
- if not clients_list:
1444
- if temp_message_id:
1445
- delete_message(message.chat.id, temp_message_id)
1446
- bot.send_message(message.chat.id, "❌ <b>لا توجد حسابات متصلة حالياً</b>", reply_to_message_id=message.message_id)
1447
- return
1448
-
1449
- success_count = 0
1450
- threads = []
1451
- results = []
1452
-
1453
- for i, client in enumerate(clients_list, 1):
1454
- thread = threading.Thread(target=lambda c=client, r=results: r.append(execute_ghost_command(c, teamcode, name, user_id, i, clients_list)))
1455
- threads.append(thread)
1456
- thread.start()
1457
-
1458
- for thread in threads:
1459
- thread.join(timeout=10)
1460
-
1461
- success_count = sum(results)
1462
-
1463
- if temp_message_id:
1464
- delete_message(message.chat.id, temp_message_id)
1465
-
1466
- bot.send_message(message.chat.id,
1467
- f"✅ <b>تم الانتهاء من عملية الشبح</b>\n"
1468
- f"🏷️ الفريق: <code>{teamcode}</code>\n"
1469
- f"👻 الاسم: {name}\n",
1470
- reply_to_message_id=message.message_id)
1471
-
1472
- update_user_activity(user_id)
1473
-
1474
- except Exception as e:
1475
- if temp_message_id:
1476
- delete_message(message.chat.id, temp_message_id)
1477
- bot.send_message(message.chat.id, f"❌ <b>حدث خطأ:</b> {str(e)}", reply_to_message_id=message.message_id)
1478
- log_action("GHOST_COMMAND_ERROR", user_id, str(e))
1479
- # BlRx MsG SeT
1480
- @bot.message_handler(func=lambda message: is_command(message, 'blrx'))
1481
- def handle_blrx_command(message):
1482
- if not should_respond(message):
1483
- return silent_ignore(message)
1484
-
1485
- user_id = message.from_user.id
1486
- temp_message_id = None
1487
-
1488
- try:
1489
- parts = message.text.split()
1490
- if len(parts) < 3:
1491
- bot.send_message(message.chat.id,
1492
- "⚠️ <b>يرجى إدخال teamcode و name</b>\n"
1493
- "📝 <b>مثال:</b> <code>/blrx 12345678 mero</code>",
1494
- reply_to_message_id=message.message_id)
1495
- return
1496
-
1497
- teamcode = parts[1]
1498
- name = ' '.join(parts[2:])
1499
-
1500
- if not ChEck_Commande(teamcode):
1501
- bot.send_message(message.chat.id, "❌ <b>teamcode غير صالح</b>", reply_to_message_id=message.message_id)
1502
- return
1503
-
1504
- temp_message_id = send_temp_message(message.chat.id,
1505
- f"⏳ <b>جاري تنفيذ أمر Blrx...</b>\n"
1506
- f"🏷️ الفريق: <code>{teamcode}</code>\n"
1507
- f"👻 الاسم: {name}",
1508
- reply_to_message_id=message.message_id)
1509
-
1510
- clients_list = get_random_accounts(3)
1511
-
1512
- if not clients_list:
1513
- if temp_message_id:
1514
- delete_message(message.chat.id, temp_message_id)
1515
- bot.send_message(message.chat.id, "❌ <b>لا توجد حسابات متصلة حالياً</b>", reply_to_message_id=message.message_id)
1516
- return
1517
-
1518
- success_count = 0
1519
- threads = []
1520
- results = []
1521
-
1522
- for i, client in enumerate(clients_list, 1):
1523
- thread = threading.Thread(target=lambda c=client, r=results: r.append(execute_blrx_command(c, teamcode, name, user_id, i)))
1524
- threads.append(thread)
1525
- thread.start()
1526
-
1527
- for thread in threads:
1528
- thread.join(timeout=60)
1529
-
1530
- success_count = sum(results)
1531
-
1532
- if temp_message_id:
1533
- delete_message(message.chat.id, temp_message_id)
1534
-
1535
- bot.send_message(message.chat.id,
1536
- f"✅ <b>تم الانتهاء من عملية Blrx</b>\n"
1537
- f"🏷️ الفريق: <code>{teamcode}</code>\n"
1538
- f"👻 الاسم: {name}\n",
1539
- reply_to_message_id=message.message_id)
1540
-
1541
- update_user_activity(user_id)
1542
-
1543
- except Exception as e:
1544
- if temp_message_id:
1545
- delete_message(message.chat.id, temp_message_id)
1546
- bot.send_message(message.chat.id, f"❌ <b>حدث خطأ:</b> {str(e)}", reply_to_message_id=message.message_id)
1547
- log_action("BLRX_COMMAND_ERROR", user_id, str(e))
1548
- # LaG MsG SeT
1549
- @bot.message_handler(func=lambda message: is_command(message, 'lag'))
1550
- def handle_lag_command(message):
1551
- if not should_respond(message):
1552
- return silent_ignore(message)
1553
-
1554
- user_id = message.from_user.id
1555
- temp_message_id = None
1556
-
1557
- try:
1558
- parts = message.text.split()
1559
- if len(parts) < 2:
1560
- bot.send_message(message.chat.id,
1561
- "⚠️ <b>يرجى إدخال teamcode</b>\n"
1562
- "📝 <b>مثال:</b> <code>/lag 12345678</code>",
1563
- reply_to_message_id=message.message_id)
1564
- return
1565
-
1566
- teamcode = parts[1]
1567
-
1568
- if not ChEck_Commande(teamcode):
1569
- bot.send_message(message.chat.id, "❌ <b>teamcode غير صالح</b>", reply_to_message_id=message.message_id)
1570
- return
1571
-
1572
- temp_message_id = send_temp_message(message.chat.id,
1573
- f"⏳ <b>جاري تنفيذ أمر Lag...</b>\n"
1574
- f"🏷️ الفريق: <code>{teamcode}</code>",
1575
- reply_to_message_id=message.message_id)
1576
-
1577
- clients_list = get_random_accounts(3)
1578
-
1579
- if not clients_list:
1580
- if temp_message_id:
1581
- delete_message(message.chat.id, temp_message_id)
1582
- bot.send_message(message.chat.id, "❌ <b>لا توجد حسابات متصلة حالياً</b>", reply_to_message_id=message.message_id)
1583
- return
1584
-
1585
- success_count = 0
1586
- threads = []
1587
-
1588
- for i, client in enumerate(clients_list, 1):
1589
- thread = threading.Thread(target=lambda c=client, sc=success_count: execute_lag_command(c, teamcode, user_id, i))
1590
- threads.append(thread)
1591
- thread.start()
1592
-
1593
- for thread in threads:
1594
- thread.join(timeout=30)
1595
-
1596
- if temp_message_id:
1597
- delete_message(message.chat.id, temp_message_id)
1598
-
1599
- bot.send_message(message.chat.id,
1600
- f"✅ <b>تم الانتهاء من عملية Lag</b>\n"
1601
- f"🏷️ الفريق: <code>{teamcode}</code>\n"
1602
- f"🔧 الحسابات المستخدمة: {len(clients_list)}",
1603
- reply_to_message_id=message.message_id)
1604
-
1605
- update_user_activity(user_id)
1606
-
1607
- except Exception as e:
1608
- if temp_message_id:
1609
- delete_message(message.chat.id, temp_message_id)
1610
- bot.send_message(message.chat.id, f"❌ <b>حدث خطأ:</b> {str(e)}", reply_to_message_id=message.message_id)
1611
- log_action("LAG_COMMAND_ERROR", user_id, str(e))
1612
- # 5 & 6 MsG SeT
1613
- @bot.message_handler(func=lambda message: is_command(message, '5') or is_command(message, '6'))
1614
- def handle_team_commands(message):
1615
- if not should_respond(message):
1616
- return silent_ignore(message)
1617
-
1618
- user_id = message.from_user.id
1619
- temp_message_id = None
1620
-
1621
- try:
1622
- parts = message.text.split()
1623
- if len(parts) < 2:
1624
- bot.send_message(message.chat.id,
1625
- "⚠️ <b>يرجى إدخال الـ player_id</b>\n"
1626
- "📝 <b>مثال:</b> <code>/5 123456789</code>",
1627
- reply_to_message_id=message.message_id)
1628
- return
1629
-
1630
- target_id = parts[1]
1631
-
1632
- if not ChEck_Commande(target_id):
1633
- bot.send_message(message.chat.id, "❌ <b>user_id غير صالح</b>", reply_to_message_id=message.message_id)
1634
- return
1635
-
1636
- command = message.text.split()[0]
1637
- team_type = "5" if "/5" in command else "6"
1638
-
1639
- temp_message_id = send_temp_message(message.chat.id,
1640
- f"⏳ <b>جاري إرسال فريق {team_type}...</b>\n"
1641
- f"🎯 الهدف: <code>{target_id}</code>",
1642
- reply_to_message_id=message.message_id)
1643
-
1644
- clients_list = get_random_accounts(1)
1645
-
1646
- if not clients_list:
1647
- if temp_message_id:
1648
- delete_message(message.chat.id, temp_message_id)
1649
- bot.send_message(message.chat.id, "❌ <b>لا توجد حسابات متصلة حالياً</b>", reply_to_message_id=message.message_id)
1650
- return
1651
-
1652
- client = clients_list[0]
1653
-
1654
- if "/5" in command:
1655
- success = execute_5x_command(client, target_id, user_id, 1)
1656
- else:
1657
- success = execute_6x_command(client, target_id, user_id, 1)
1658
-
1659
- if temp_message_id:
1660
- delete_message(message.chat.id, temp_message_id)
1661
-
1662
- if success:
1663
- bot.send_message(message.chat.id,
1664
- f"✅ <b>تم إرسال فريق {team_type} بنجاح</b>\n"
1665
- f"🎯 الهدف: <code>{target_id}</code>",
1666
- reply_to_message_id=message.message_id)
1667
- else:
1668
- bot.send_message(message.chat.id,
1669
- f"❌ <b>فشل في إرسال فريق {team_type}</b>\n"
1670
- f"🎯 الهدف: <code>{target_id}</code>",
1671
- reply_to_message_id=message.message_id)
1672
-
1673
- update_user_activity(user_id)
1674
-
1675
- except Exception as e:
1676
- if temp_message_id:
1677
- delete_message(message.chat.id, temp_message_id)
1678
- bot.send_message(message.chat.id, f"❌ <b>حدث خطأ:</b> {str(e)}", reply_to_message_id=message.message_id)
1679
- log_action("TEAM_COMMAND_ERROR", user_id, str(e))
1680
- # HeX MsG SeT
1681
- @bot.message_handler(func=lambda message: is_command(message, 'hex'))
1682
- def handle_hex_command(message):
1683
- if not should_respond(message):
1684
- return silent_ignore(message)
1685
-
1686
- user_id = message.from_user.id
1687
- temp_message_id = None
1688
-
1689
- try:
1690
- parts = message.text.split()
1691
- if len(parts) < 2:
1692
- bot.send_message(message.chat.id,
1693
- "⚠️ <b>يرجى إدخال الـ player_id</b>\n"
1694
- "📝 <b>مثال:</b> <code>/hex 123456789</code>",
1695
- reply_to_message_id=message.message_id)
1696
- return
1697
-
1698
- target_id = parts[1]
1699
-
1700
- if not ChEck_Commande(target_id):
1701
- bot.send_message(message.chat.id, "❌ <b>player_id غير صالح</b>", reply_to_message_id=message.message_id)
1702
- return
1703
-
1704
- attempts_remaining = get_user_attempts(user_id, 'spam')
1705
-
1706
- if attempts_remaining <= 0 and not has_unlimited_attempts(user_id):
1707
- bot.send_message(message.chat.id,
1708
- "❌ <b>لقد استنفذت جميع محاولاتك!</b>\n"
1709
- "⏰ الرجاء الانتظار ساعتين لاستعادة المحاولات\n"
1710
- "💎 أو قم بلحصول على كود تفعيل للحصول على محاولات غير محدودة",
1711
- reply_to_message_id=message.message_id)
1712
- return
1713
-
1714
- if not use_attempt(user_id, 'spam') and not has_unlimited_attempts(user_id):
1715
- bot.send_message(message.chat.id,
1716
- "❌ <b>لا توجد محاولات متاحة!</b>\n"
1717
- "⏰ الرجاء الانتظار ساعتين لاستعادة المحاولات",
1718
- reply_to_message_id=message.message_id)
1719
- return
1720
-
1721
- with active_spam_lock:
1722
- if target_id not in active_spam_targets:
1723
- active_spam_targets[target_id] = True
1724
- threading.Thread(target=infinite_spam_worker, args=(target_id,), daemon=True).start()
1725
-
1726
- if has_unlimited_attempts(user_id):
1727
- message_text = f"✅ <b>تم بدء مقبره 24 ساعه على المستخدم</b>\n👤 الاعب: <code>{target_id}</code>\n♾️ محاولات غير محدودة"
1728
- else:
1729
- remaining_attempts = get_user_attempts(user_id, 'spam')
1730
- message_text = f"✅ <b>تم بدء مقبره 24 ساعه على المستخدم</b>\n👤 الاعب: <code>{target_id}</code>\n🔄 <b>المحاولات المتبقية:</b> {remaining_attempts}/3"
1731
- else:
1732
- message_text = f"⚠️ <b>المقبره تعمل بالفعل على المستخدم</b>"
1733
-
1734
- bot.send_message(message.chat.id, message_text, reply_to_message_id=message.message_id)
1735
- update_user_activity(user_id)
1736
-
1737
- except Exception as e:
1738
- if temp_message_id:
1739
- delete_message(message.chat.id, temp_message_id)
1740
- bot.send_message(message.chat.id, f"❌ <b>حدث خطأ:</b> {str(e)}", reply_to_message_id=message.message_id)
1741
- log_action("HEX_COMMAND_ERROR", user_id, str(e))
1742
- #StOp MsG SeT
1743
- @bot.message_handler(func=lambda message: is_command(message, 'stop'))
1744
- def handle_stop_command(message):
1745
- if not should_respond(message):
1746
- return silent_ignore(message)
1747
-
1748
- user_id = message.from_user.id
1749
-
1750
- try:
1751
- parts = message.text.split()
1752
- if len(parts) < 2:
1753
- bot.send_message(message.chat.id,
1754
- "⚠️ <b>يرجى إدخال الـ player_id</b>\n"
1755
- "📝 <b>مثال:</b> <code>/stop 123456789</code>",
1756
- reply_to_message_id=message.message_id)
1757
- return
1758
-
1759
- target_id = parts[1]
1760
-
1761
- with active_spam_lock:
1762
- if target_id in active_spam_targets:
1763
- del active_spam_targets[target_id]
1764
- message_text = f"🛑 <b>تم إيقاف المقبره على المستخدم:</b> <code>{target_id}</code>"
1765
- else:
1766
- message_text = f"ℹ️ <b>لا توجد مقبره نشطه على المستخدم:</b> <code>{target_id}</code>"
1767
-
1768
- bot.send_message(message.chat.id, message_text, reply_to_message_id=message.message_id)
1769
- update_user_activity(user_id)
1770
-
1771
- except Exception as e:
1772
- bot.send_message(message.chat.id, f"❌ <b>حدث خطأ:</b> {str(e)}", reply_to_message_id=message.message_id)
1773
- log_action("STOP_COMMAND_ERROR", user_id, str(e))
1774
-
1775
- # UeSeRs LoGiN CoDe SeT
1776
- @bot.message_handler(func=lambda message: len(message.text) == 16 and message.text.isalnum() and message.text.isupper())
1777
- def handle_activation_codes(message):
1778
- handle_activation_code(message)
1779
-
1780
- # LoGiN MsG SeT
1781
- @bot.message_handler(func=lambda message: is_command(message, 'login'))
1782
- def handle_login_command(message):
1783
- user_id = message.from_user.id
1784
- if not is_owner(user_id):
1785
- return silent_ignore(message)
1786
-
1787
- try:
1788
- parts = message.text.split()
1789
-
1790
- # التحقق من وجود عدد الأيام
1791
- if len(parts) < 2:
1792
- bot.send_message(message.chat.id,
1793
- "⚠️ <b>يرجى إدخال عدد الأيام</b>\n"
1794
- "📝 <b>مثال:</b> <code>/login 30</code>\n",
1795
- reply_to_message_id=message.message_id)
1796
- return
1797
-
1798
- days = int(parts[1])
1799
-
1800
- if days <= 0:
1801
- bot.send_message(message.chat.id,
1802
- "❌ <b>عدد الأيام يجب أن يكون أكبر من الصفر!</b>\n"
1803
- "📝 <b>مثال صحيح:</b> <code>/login 30</code>",
1804
- reply_to_message_id=message.message_id)
1805
- return
1806
-
1807
- # الحد الأقصى للأيام (اختياري)
1808
- if days > 3650: # 10 سنوات كحد أقصى
1809
- bot.send_message(message.chat.id,
1810
- "❌ <b>عدد الأيام كبير جداً!</b>\n"
1811
- "📝 <b>الحد الأقصى:</b> 3650 يوم (10 سنوات)",
1812
- reply_to_message_id=message.message_id)
1813
- return
1814
-
1815
- code = generate_activation_code(days)
1816
- expire_date = datetime.fromtimestamp(time.time() + (365 * 24 * 60 * 60)).strftime('%Y-%m-%d %H:%M:%S')
1817
-
1818
- response_text = f"""
1819
- ✅ <b>تم إنشاء كود التفعيل بنجاح</b>
1820
-
1821
- 📝 <b>تفاصيل الكود:</b>
1822
- 🔑 الكود: <code>{code}</code>
1823
- ⏰ المدة: {days} يوم
1824
- 📅 ينتهي الكود في: {expire_date}
1825
-
1826
- 💡 <b>طريقة الاستخدام:</b>
1827
- أرسل الكود للمستخدم لتفعيل حسابه:
1828
- <code>{code}</code>
1829
- """
1830
-
1831
- bot.send_message(message.chat.id, response_text, reply_to_message_id=message.message_id)
1832
- log_action("LOGIN_CODE_GENERATED", user_id, f"Code: {code}, Days: {days}")
1833
- update_user_activity(user_id)
1834
-
1835
- except ValueError:
1836
- bot.send_message(message.chat.id,
1837
- "❌ <b>القيمة المدخلة غير صحيحة!</b>\n"
1838
- "📝 <b>تأكد من:</b>\n"
1839
- "• إدخال أرقام صحيحة فقط\n"
1840
- "• <b>مثال صحيح:</b> <code>/login 30</code>\n"
1841
- "• <b>مثال خاطئ:</b> <code>/login ثلاثين</code>",
1842
- reply_to_message_id=message.message_id)
1843
- except Exception as e:
1844
- bot.send_message(message.chat.id,
1845
- f"❌ <b>حدث خطأ غير متوقع:</b> {str(e)}\n"
1846
- f"📝 <b>يرجى المحاولة مرة أخرى</b>",
1847
- reply_to_message_id=message.message_id)
1848
- log_action("LOGIN_COMMAND_ERROR", user_id, str(e))
1849
- # GrOuP MsG SeT
1850
- @bot.message_handler(func=lambda message: is_command(message, 'allow'))
1851
- def handle_allow_command(message):
1852
- user_id = message.from_user.id
1853
- if not is_owner(user_id):
1854
- return silent_ignore(message)
1855
-
1856
- try:
1857
- parts = message.text.split()
1858
- if len(parts) < 2:
1859
- bot.send_message(message.chat.id,
1860
- "⚠️ <b>يرجى إدخال group_id</b>\n"
1861
- "📝 <b>مثال:</b> <code>/allow -100123456789</code>",
1862
- reply_to_message_id=message.message_id)
1863
- return
1864
-
1865
- group_id = parts[1]
1866
-
1867
- if len(parts) < 3:
1868
- days = 365
1869
- else:
1870
- days = int(parts[2])
1871
-
1872
- if days <= 0:
1873
- bot.send_message(message.chat.id, "❌ <b>عدد الأيام يجب أن يكون أكبر من الصفر!</b>", reply_to_message_id=message.message_id)
1874
- return
1875
-
1876
- expire_time = add_allowed_group(group_id, days)
1877
- expire_date = datetime.fromtimestamp(expire_time).strftime('%Y-%m-%d %H:%M:%S')
1878
-
1879
- response_text = f"""
1880
- ✅ <b>تم تفعيل المجموعة بنجاح</b>
1881
-
1882
- 📝 <b>تفاصيل التفعيل:</b>
1883
- 👥 المجموعة: <code>{group_id}</code>
1884
- ⏰ المدة: {days} يوم
1885
- 📅 تاريخ الانتهاء: {expire_date}
1886
- """
1887
-
1888
- bot.send_message(message.chat.id, response_text, reply_to_message_id=message.message_id)
1889
- update_user_activity(user_id)
1890
-
1891
- except ValueError:
1892
- bot.send_message(message.chat.id,
1893
- "❌ <b>القيمة المدخلة غير صحيحة!</b>\n"
1894
- "📝 تأكد من إدخال أرقام صحيحة",
1895
- reply_to_message_id=message.message_id)
1896
- except Exception as e:
1897
- bot.send_message(message.chat.id, f"❌ <b>حدث خطأ:</b> {str(e)}", reply_to_message_id=message.message_id)
1898
- log_action("ALLOW_COMMAND_ERROR", user_id, str(e))
1899
- # GrOuP MsG SeT
1900
- @bot.message_handler(func=lambda message: is_command(message, 'unallow'))
1901
- def handle_unallow_command(message):
1902
- user_id = message.from_user.id
1903
- if not is_owner(user_id):
1904
- return silent_ignore(message)
1905
-
1906
- try:
1907
- parts = message.text.split()
1908
- if len(parts) < 2:
1909
- bot.send_message(message.chat.id,
1910
- "⚠️ <b>يرجى إدخال group_id</b>\n"
1911
- "📝 <b>مثال:</b> <code>/unallow -100123456789</code>",
1912
- reply_to_message_id=message.message_id)
1913
- return
1914
-
1915
- group_id = parts[1]
1916
-
1917
- if remove_allowed_group(group_id):
1918
- response_text = f"✅ <b>تم إلغاء تفعيل المجموعة:</b> <code>{group_id}</code>"
1919
- else:
1920
- response_text = f"❌ <b>المجموعة غير موجودة في القائمة:</b> <code>{group_id}</code>"
1921
-
1922
- bot.send_message(message.chat.id, response_text, reply_to_message_id=message.message_id)
1923
- update_user_activity(user_id)
1924
-
1925
- except Exception as e:
1926
- bot.send_message(message.chat.id, f"❌ <b>حدث خطأ:</b> {str(e)}", reply_to_message_id=message.message_id)
1927
- log_action("UNALLOW_COMMAND_ERROR", user_id, str(e))
1928
- # OwNeR MsG SeT
1929
- @bot.message_handler(func=lambda message: is_command(message, 'addowner'))
1930
- def handle_addowner_command(message):
1931
- user_id = message.from_user.id
1932
- if not is_owner(user_id):
1933
- return silent_ignore(message)
1934
-
1935
- try:
1936
- parts = message.text.split()
1937
- if len(parts) < 2:
1938
- bot.send_message(message.chat.id,
1939
- "⚠️ <b>يرجى إدخال user_id</b>\n"
1940
- "📝 <b>مثال:</b> <code>/addowner 123456789</code>",
1941
- reply_to_message_id=message.message_id)
1942
- return
1943
-
1944
- new_owner_id = parts[1]
1945
- if not new_owner_id.isdigit():
1946
- bot.send_message(message.chat.id, "❌ <b>يجب أن يكون user_id رقماً</b>", reply_to_message_id=message.message_id)
1947
- return
1948
-
1949
- new_owner_id = int(new_owner_id)
1950
- if is_owner(new_owner_id):
1951
- bot.send_message(message.chat.id, f"❌ <b>المستخدم <code>{new_owner_id}</code> مالك بالفعل</b>", reply_to_message_id=message.message_id)
1952
- return
1953
-
1954
- add_owner(new_owner_id)
1955
- bot.send_message(message.chat.id, f"✅ <b>تمت إضافة المالك الجديد:</b> <code>{new_owner_id}</code>", reply_to_message_id=message.message_id)
1956
- update_user_activity(user_id)
1957
-
1958
- except Exception as e:
1959
- bot.send_message(message.chat.id, f"❌ <b>حدث خطأ:</b> {str(e)}", reply_to_message_id=message.message_id)
1960
- log_action("ADDOWNER_COMMAND_ERROR", user_id, str(e))
1961
- # OwNeR MsG SeT
1962
- @bot.message_handler(func=lambda message: is_command(message, 'removeowner'))
1963
- def handle_removeowner_command(message):
1964
- user_id = message.from_user.id
1965
- if not is_owner(user_id):
1966
- return silent_ignore(message)
1967
-
1968
- try:
1969
- parts = message.text.split()
1970
- if len(parts) < 2:
1971
- bot.send_message(message.chat.id,
1972
- "⚠️ <b>يرجى إدخال user_id</b>\n"
1973
- "📝 <b>مثال:</b> <code>/removeowner 123456789</code>",
1974
- reply_to_message_id=message.message_id)
1975
- return
1976
-
1977
- owner_id_to_remove = parts[1]
1978
- if not owner_id_to_remove.isdigit():
1979
- bot.send_message(message.chat.id, "❌ <b>يجب أن يكون user_id رقماً</b>", reply_to_message_id=message.message_id)
1980
- return
1981
-
1982
- owner_id_to_remove = int(owner_id_to_remove)
1983
- if not is_owner(owner_id_to_remove):
1984
- bot.send_message(message.chat.id, f"❌ <b>المستخدم <code>{owner_id_to_remove}</code> ليس مالكاً</b>", reply_to_message_id=message.message_id)
1985
- return
1986
-
1987
- if owner_id_to_remove == user_id:
1988
- bot.send_message(message.chat.id, "❌ <b>لا يمكنك إزالة نفسك</b>", reply_to_message_id=message.message_id)
1989
- return
1990
-
1991
- remove_owner(owner_id_to_remove)
1992
- bot.send_message(message.chat.id, f"✅ <b>تمت إزالة المالك:</b> <code>{owner_id_to_remove}</code>", reply_to_message_id=message.message_id)
1993
- update_user_activity(user_id)
1994
-
1995
- except Exception as e:
1996
- bot.send_message(message.chat.id, f"❌ <b>حدث خطأ:</b> {str(e)}", reply_to_message_id=message.message_id)
1997
- log_action("REMOVEOWNER_COMMAND_ERROR", user_id, str(e))
1998
- # StAtUs BoT iNfO MsG SeT
1999
- @bot.message_handler(func=lambda message: is_command(message, 'status'))
2000
- def handle_status_command(message):
2001
- user_id = message.from_user.id
2002
- if not is_owner(user_id):
2003
- return silent_ignore(message)
2004
-
2005
- try:
2006
- with active_spam_lock:
2007
- active_targets = list(active_spam_targets.keys())
2008
-
2009
- with connected_clients_lock:
2010
- accounts_count = len(connected_clients)
2011
- accounts_list = list(connected_clients.keys())
2012
-
2013
- users = load_data(USERS_FILE)
2014
- total_users = len(users)
2015
- active_users = sum(1 for user_data in users.values()
2016
- if datetime.now().timestamp() - datetime.strptime(user_data.get('last_active', '2000-01-01 00:00:00'), '%Y-%m-%d %H:%M:%S').timestamp() < 24 * 60 * 60)
2017
-
2018
- activations = load_data(ACTIVATIONS_FILE)
2019
- active_activations = sum(1 for activation in activations.values()
2020
- if activation.get('expire_at', 0) > time.time())
2021
-
2022
- allowed_groups = load_allowed_groups()
2023
- active_groups = sum(1 for group_data in allowed_groups.values()
2024
- if group_data.get('expire_at', 0) > time.time())
2025
-
2026
- owners = load_owners()
2027
-
2028
- status_text = f"""
2029
- 📊 <b>حالة البوت MERO KInG</b>
2030
-
2031
- <b>👥 إحصائيات المستخدمين:</b>
2032
- 👤 إجمالي المستخدمين: {total_users}
2033
- 🟢 مستخدمين نشطين: {active_users}
2034
- 💎 تفعيلات نشطة: {active_activations}
2035
- 👑 عدد المالكين: {len(owners)}
2036
-
2037
- <b>🎯 الأهداف النشطة:</b> {len(active_targets)}
2038
- 🔸 {', '.join(active_targets) if active_targets else 'لا توجد أهداف نشطة'}
2039
-
2040
- <b>👥 الحسابات المتصلة:</b> {accounts_count}
2041
- 🔸 {', '.join(accounts_list[:10]) if accounts_list else 'لا توجد حسابات متصلة'}
2042
-
2043
- <b>👥 المجموعات المسموحة:</b> {active_groups}
2044
- """
2045
-
2046
- bot.send_message(message.chat.id, status_text, reply_to_message_id=message.message_id)
2047
- update_user_activity(user_id)
2048
-
2049
- except Exception as e:
2050
- bot.send_message(message.chat.id, f"❌ <b>حدث خطأ:</b> {str(e)}", reply_to_message_id=message.message_id)
2051
- log_action("STATUS_COMMAND_ERROR", user_id, str(e))
2052
- #AcCs StAtUs MsG SeT
2053
- @bot.message_handler(func=lambda message: is_command(message, 'accounts'))
2054
- def handle_accounts_command(message):
2055
- user_id = message.from_user.id
2056
- if not is_owner(user_id):
2057
- return silent_ignore(message)
2058
-
2059
- try:
2060
- with connected_clients_lock:
2061
- accounts_count = len(connected_clients)
2062
- accounts_list = list(connected_clients.keys())
2063
-
2064
- accounts_text = f"👥 <b>الحسابات المتصلة:</b> {accounts_count}\n\n"
2065
- accounts_text += "<b>قائمة الحسابات:</b>"
2066
- for i, account in enumerate(accounts_list, 1):
2067
- accounts_text += f"\n🔹 {i}. <code>{account}</code>"
2068
-
2069
- bot.send_message(message.chat.id, accounts_text, reply_to_message_id=message.message_id)
2070
- update_user_activity(user_id)
2071
-
2072
- except Exception as e:
2073
- bot.send_message(message.chat.id, f"❌ <b>حدث خطأ:</b> {str(e)}", reply_to_message_id=message.message_id)
2074
- log_action("ACCOUNTS_COMMAND_ERROR", user_id, str(e))
2075
-
2076
- # OwNeRs StAtuS MsG SeT
2077
- @bot.message_handler(func=lambda message: is_command(message, 'listowners'))
2078
- def handle_listowners_command(message):
2079
- user_id = message.from_user.id
2080
- if not is_owner(user_id):
2081
- return silent_ignore(message)
2082
-
2083
- try:
2084
- owners = load_owners()
2085
- owners_text = "<b>👑 قائمة المالكين:</b>\n\n"
2086
- for i, (owner_id, owner_data) in enumerate(owners.items(), 1):
2087
- try:
2088
- user_info = bot.get_chat(int(owner_id))
2089
- username = f"@{user_info.username}" if user_info.username else user_info.first_name
2090
- added_at = owner_data.get('added_at', 'غير معروف')
2091
- owners_text += f"{i}. {username} - <code>{owner_id}</code>\n ⏰ مضاف في: {added_at}\n"
2092
- except Exception as e:
2093
- owners_text += f"{i}. غير معروف - <code>{owner_id}</code>\n ⏰ مضاف في: {owner_data.get('added_at', 'غير معروف')}\n"
2094
- log_action("FETCH_OWNER_INFO_ERROR", user_id, f"Owner: {owner_id} | Error: {str(e)}")
2095
-
2096
- owners_text += f"\n<b>الإجمالي:</b> {len(owners)} مالك"
2097
-
2098
- bot.send_message(message.chat.id, owners_text, reply_to_message_id=message.message_id)
2099
- update_user_activity(user_id)
2100
-
2101
- except Exception as e:
2102
- bot.send_message(message.chat.id, f"❌ <b>حدث خطأ:</b> {str(e)}", reply_to_message_id=message.message_id)
2103
- log_action("LISTOWNERS_COMMAND_ERROR", user_id, str(e))
2104
-
2105
- #MsG SeT
2106
- @bot.message_handler(func=lambda message: True)
2107
- def handle_all_other_messages(message):
2108
- silent_ignore(message)
2109
- # FiLeS DaTa
2110
- def initialize_data_files():
2111
-
2112
- files_to_initialize = [
2113
- USERS_FILE,
2114
- ACTIVATIONS_FILE,
2115
- ACTIVATION_CODES_FILE,
2116
- ALLOWED_GROUPS_FILE,
2117
- OWNERS_FILE
2118
- ]
2119
-
2120
- for filename in files_to_initialize:
2121
- if not os.path.exists(filename):
2122
- print(f"📁 إنشاء ملف: {filename}")
2123
- save_data({}, filename)
2124
- else:
2125
- data = load_data(filename)
2126
- print(f"✅ تم تحميل {filename}: {len(data)} عنصر")
2127
-
2128
- restored = restore_expired_attempts()
2129
- print(f"🔄 تم استعادة محاولات {restored} مستخدم عند البدء")
2130
-
2131
-
2132
- owners = load_owners()
2133
- if not owners:
2134
- for owner_id in ADMIN_USER_IDS:
2135
- owners[str(owner_id)] = {
2136
- "added_at": datetime.now().strftime('%Y-%m-%d %H:%M:%S'),
2137
- "added_by": "system"
2138
- }
2139
- save_owners(owners)
2140
- print(f"✅ تم إضافة المالكين الافتراضيين: {ADMIN_USER_IDS}")
2141
- # TeLe BoT
2142
- def start_telegram_bot():
2143
- print("🚀 بدء تشغيل بوت التليجرام...")
2144
- try:
2145
- bot_info = bot.get_me()
2146
- print(f"🤖 اسم البوت: {bot_info.username}")
2147
- print(f"🆔 معرف البوت: {bot_info.id}")
2148
- print("✅ بوت التليجرام يعمل بنجاح!")
2149
-
2150
- allowed_groups = load_allowed_groups()
2151
- print(f"👥 عدد المجموعات المسموحة: {len(allowed_groups)}")
2152
- for group_id, group_data in allowed_groups.items():
2153
- expire_date = group_data.get('expire_date', 'غير معروف')
2154
- print(f" - {group_id} (ينتهي: {expire_date})")
2155
-
2156
- return True
2157
- except Exception as e:
2158
- print(f"❌ خطأ في تشغيل بوت التليجرام: {e}")
2159
- return False
2160
- # AcCs
2161
- def start_accounts():
2162
- print("⏳ جاري بدء تشغيل الحسابات...")
2163
-
2164
- if not ACCOUNTS:
2165
- print("❌ لا توجد حسابات لبدء التشغيل!")
2166
- return
2167
-
2168
- accounts_to_start = ACCOUNTS[:99999999999]
2169
- print(f"🔧 سيتم تشغيل {len(accounts_to_start)} حساب من أصل {len(ACCOUNTS)}")
2170
-
2171
- for i, account in enumerate(accounts_to_start, 1):
2172
- try:
2173
- print(f"🚀 بدء الحساب {i}: {account['id']}")
2174
- threading.Thread(target=start_account, args=(account,), daemon=True).start()
2175
- time.sleep(0.1) # تأخير بين تشغيل كل حساب
2176
- except Exception as e:
2177
- print(f"❌ خطأ في بدء الحساب {account['id']}: {e}")
2178
- # xMeRo KiNgx
2179
- def StarT_SerVer():
2180
- initialize_data_files()
2181
-
2182
- if not start_telegram_bot():
2183
- print("❌ فشل في تشغيل بوت التليجرام، إعادة المحاولة...")
2184
- time.sleep(5)
2185
- return StarT_SerVer()
2186
-
2187
- start_accounts()
2188
-
2189
- threading.Thread(target=background_tasks, daemon=True).start()
2190
- threading.Thread(target=AuTo_ResTartinG, daemon=True).start()
2191
-
2192
- print(f"✅ تم بدء تشغيل النظام بالكامل بنجاح")
2193
- print(f"🕒 وقت البدء: {datetime.now().strftime('%Y-%m-%d %H:%M:%S')}")
2194
- print(f"👑 عدد المالكين: {len(load_owners())}")
2195
- print(f"📊 عدد الحسابات المحملة: {len(ACCOUNTS)}")
2196
- print(f"🔧 عدد الحسابات المشغلة: {min(5, len(ACCOUNTS))}")
2197
-
2198
- try:
2199
- bot.polling(none_stop=True, interval=0)
2200
- except Exception as e:
2201
- print(f"❌ خطأ في بوت التليجرام: {e}")
2202
- print("🔄 إعادة تشغيل النظام...")
2203
- time.sleep(5)
2204
- ResTarT_BoT()
2205
-
2206
- if __name__ == "__main__":
2207
- StarT_SerVer()