Reooiq commited on
Commit
f241053
·
verified ·
1 Parent(s): bc9489c

Update bot.py

Browse files
Files changed (1) hide show
  1. bot.py +106 -67
bot.py CHANGED
@@ -2,88 +2,127 @@ import asyncio
2
  import os
3
  import logging
4
  import random
5
- from pyrogram import Client, errors, types
6
  from threading import Thread
7
  from http.server import HTTPServer, SimpleHTTPRequestHandler
 
 
 
 
 
 
8
 
 
9
  logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(message)s')
10
  logger = logging.getLogger(__name__)
11
 
12
- API_ID = int(os.getenv("API_ID", "0"))
13
- API_HASH = os.getenv("API_HASH", "")
 
14
  SESSION_STRING = os.getenv("SESSION_STRING") or os.getenv("STRING_SESSION") or ""
15
  TARGET_CHANNEL = os.getenv("TARGET_CHANNEL", "")
 
16
 
17
- # جسر الويب
 
 
 
18
  Thread(target=lambda: HTTPServer(("0.0.0.0", 7860), SimpleHTTPRequestHandler).serve_forever(), daemon=True).start()
19
 
20
- async def sync_and_attack():
21
- app = Client(
22
- "sync_beast", api_id=API_ID, api_hash=API_HASH,
23
- session_string=SESSION_STRING.strip(), in_memory=True,
24
- device_model="Samsung Galaxy S24 Ultra"
25
- )
26
 
27
- try:
28
- await app.start()
29
-
30
- # 1. قراءة الأرقام من الملف
31
- if not os.path.exists("contacts.txt"):
32
- logger.error("❌ ملف contacts.txt غير موجود!")
33
- return
34
-
35
- with open("contacts.txt", "r") as f:
36
- all_phones = [line.strip() for line in f if line.strip()]
37
-
38
- logger.info(f"📂 الملف يحتوي على {len(all_phones)} رقم.")
39
-
40
- # 2. المزامنة التدريجية (أهم خطوة)
41
- # سنأخذ 10 أرقام عشوائية في كل دورة لرفعهم
42
- sample_phones = random.sample(all_phones, min(10, len(all_phones)))
43
- logger.info(f"📡 جاري محاولة مزامنة {len(sample_phones)} أرقام جديدة...")
44
-
45
- contacts_to_import = [
46
- types.InputPhoneContact(phone=p, first_name=f"User_{random.randint(1000,9999)}")
47
- for p in sample_phones
48
- ]
49
-
50
  try:
51
- # تنفيذ المزامنة
52
- result = await app.import_contacts(contacts_to_import)
53
- logger.info(f"✅ تم العثور على {len(result.users)} مستخدم جديد لديهم تيليجرام من هذه الدفعة.")
 
 
 
 
 
54
  except Exception as e:
55
- logger.warning(f"⚠️ فشلت المزامنة لهذه الدفعة: {e}")
56
-
57
- # 3. جلب كل جهات الاتصال المسجلة الآن في الحساب
58
- my_contacts = await app.get_contacts()
59
- random.shuffle(my_contacts)
60
-
61
- logger.info(f"👥 إجمالي جهات الاتصال الجاهزة حالياً: {len(my_contacts)}")
62
-
63
- for contact in my_contacts:
64
- try:
65
- # محاولة الإضافة
66
- logger.info(f"🎯 محاولة حشر: {contact.first_name}")
67
- await app.add_chat_members(TARGET_CHANNEL, contact.id)
68
- logger.info(f"✅ نجحت إضافة {contact.first_name}")
69
- await asyncio.sleep(random.randint(60, 120))
70
-
71
- except errors.FloodWait as e:
72
- # إذا في فلود، نراسل بدلاً من الانتظار
73
- if e.value > 60:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
74
  try:
75
- await app.send_message(contact.id, f"أهلاً بك! انضم لجروبنا: https://t.me/{TARGET_CHANNEL}")
76
- logger.info(f"📨 تمت المراسلة بسبب الفلود.")
77
- except: pass
78
- continue
79
- except Exception: continue
 
 
 
 
 
 
 
 
80
 
81
- finally:
82
- await app.stop()
 
83
 
84
  if __name__ == "__main__":
85
- while True:
86
- asyncio.run(sync_and_attack())
87
- logger.info("💤 استراحة 1 دقائق قبل الدفعة القادمة من المزامنة...")
88
- import time
89
- time.sleep(100)
 
2
  import os
3
  import logging
4
  import random
5
+ import sys
6
  from threading import Thread
7
  from http.server import HTTPServer, SimpleHTTPRequestHandler
8
+ from telethon import TelegramClient, functions, types
9
+ from telethon.sessions import StringSession
10
+ from telethon.tl.functions.channels import InviteToChannelRequest, JoinChannelRequest, LeaveChannelRequest
11
+ from telethon.tl.functions.contacts import SearchRequest, ImportContactsRequest
12
+ from telethon.tl.types import InputPeerUser, Channel, InputPhoneContact
13
+ from telethon.errors import *
14
 
15
+ # إعداد اللوق
16
  logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(message)s')
17
  logger = logging.getLogger(__name__)
18
 
19
+ # المتغيرات
20
+ API_ID = int(os.getenv("API_ID", "6"))
21
+ API_HASH = os.getenv("API_HASH", "eb06d4abfb49dc3eeb1aeb98ae0f581e")
22
  SESSION_STRING = os.getenv("SESSION_STRING") or os.getenv("STRING_SESSION") or ""
23
  TARGET_CHANNEL = os.getenv("TARGET_CHANNEL", "")
24
+ KEYWORDS = ["نقاش", "شات", "قروب", "سوالف", "تعارف", "شباب", "بنات", "العاب", "تداول", "عملات", "بينانس", "افلام", "ضحك"]
25
 
26
+ BLACKLIST_USERS = set()
27
+ VISITED_GROUPS = set()
28
+
29
+ # الجسر لمنع الإغلاق
30
  Thread(target=lambda: HTTPServer(("0.0.0.0", 7860), SimpleHTTPRequestHandler).serve_forever(), daemon=True).start()
31
 
32
+ client = TelegramClient(StringSession(SESSION_STRING.strip()), API_ID, API_HASH)
 
 
 
 
 
33
 
34
+ async def sync_file_contacts():
35
+ """مزامنة الأرقام من ملف contacts.txt"""
36
+ if os.path.exists("contacts.txt"):
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
37
  try:
38
+ with open("contacts.txt", "r") as f:
39
+ phones = [line.strip() for line in f if line.strip()]
40
+
41
+ if phones:
42
+ sample = random.sample(phones, min(10, len(phones)))
43
+ logger.info(f"📡 مزامنة {len(sample)} رقم من الملف...")
44
+ contacts = [InputPhoneContact(client_id=random.randrange(0, 2**63), phone=p, first_name=f"User_{random.randint(1,999)}", last_name="") for p in sample]
45
+ await client(ImportContactsRequest(contacts))
46
  except Exception as e:
47
+ logger.warning(f"⚠️ فشلت مزامنة الملف: {e}")
48
+
49
+ async def find_new_group():
50
+ """البحث عن جروب جديد للانضمام إليه"""
51
+ word = random.choice(KEYWORDS)
52
+ try:
53
+ result = await client(SearchRequest(q=word, limit=20))
54
+ groups = [c for c in result.chats if isinstance(c, Channel) and not c.broadcast]
55
+ for group in groups:
56
+ if group.id not in VISITED_GROUPS:
57
+ await client(JoinChannelRequest(group))
58
+ VISITED_GROUPS.add(group.id)
59
+ logger.info(f"✅ تم اقتحام: {group.title}")
60
+ return group
61
+ except: pass
62
+ return None
63
+
64
+ async def main_attack():
65
+ await client.connect()
66
+ if not await client.is_user_authorized():
67
+ logger.error("❌ الجلسة منتهية")
68
+ return
69
+
70
+ logger.info("💀 تفعيل وضع الإعصار المدمر 2026 - بدء الهجوم الشامل")
71
+
72
+ while True:
73
+ try:
74
+ # 1. مزامنة الأرقام من الملف (جزء من الهجوم)
75
+ await sync_file_contacts()
76
+
77
+ # 2. جلب الأهداف (جهات الاتصال + اقتحام جروب)
78
+ targets = []
79
+
80
+ # أضف جهات الاتصال المسجلة
81
+ contacts = await client.get_contacts()
82
+ targets.extend([c for c in contacts if c.id not in BLACKLIST_USERS])
83
+
84
+ # اقتحم جروب وصيد المتفاعلين
85
+ group = await find_new_group()
86
+ if group:
87
+ async for msg in client.iter_messages(group, limit=100):
88
+ if msg.sender_id and msg.sender_id not in BLACKLIST_USERS:
89
+ if hasattr(msg.sender, 'bot') and not msg.sender.bot:
90
+ targets.append(msg.sender)
91
+
92
+ random.shuffle(targets)
93
+ logger.info(f"🎯 تم حشد {len(targets)} ضحية للهجوم...")
94
+
95
+ for user in targets:
96
+ if user.id in BLACKLIST_USERS: continue
97
+ BLACKLIST_USERS.add(user.id)
98
+ name = getattr(user, 'first_name', 'صديقي') or "مستخدم"
99
+
100
+ try:
101
+ # محاولة الإضافة المباشرة (سريعة جداً)
102
+ await client(InviteToChannelRequest(TARGET_CHANNEL, [user]))
103
+ logger.info(f"✅ حشر مباشر: {name}")
104
+ await asyncio.sleep(random.randint(5, 10)) # سرعة جنونية
105
+
106
+ except (PeerFloodError, UserPrivacyRestrictedError, FloodWaitError) as e:
107
+ # إذا طلب تيليجرام انتظاراً طويلاً، "طنش" واقصف الخاص فوراً
108
  try:
109
+ logger.info(f"📩 الإضافة مقيدة.. قصف الخاص لـ {name}...")
110
+ msg = f"أهلاً {name}! 👋\nانضم لجروبنا المتفاعل الآن:\nhttps://t.me/{TARGET_CHANNEL}"
111
+ await client.send_message(user.id, msg)
112
+ logger.info(f"✅ تم القصف.")
113
+ await asyncio.sleep(random.randint(5, 10))
114
+ except: continue
115
+ except Exception: continue
116
+
117
+ if group:
118
+ await client(LeaveChannelRequest(group))
119
+
120
+ logger.info("🔄 تبريد المحرك 2 دقيقة قبل الهجمة القادمة...")
121
+ await asyncio.sleep(120)
122
 
123
+ except Exception as e:
124
+ logger.error(f"💥 خطأ: {e}")
125
+ await asyncio.sleep(30)
126
 
127
  if __name__ == "__main__":
128
+ client.loop.run_until_complete(main_attack())