Update bot.py
Browse files
bot.py
CHANGED
|
@@ -2,88 +2,127 @@ import asyncio
|
|
| 2 |
import os
|
| 3 |
import logging
|
| 4 |
import random
|
| 5 |
-
|
| 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 |
-
|
| 13 |
-
|
|
|
|
| 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 |
-
|
| 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 |
-
|
| 28 |
-
|
| 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 |
-
|
| 53 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 54 |
except Exception as e:
|
| 55 |
-
logger.warning(f"⚠️ فشلت
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
for
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 74 |
try:
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 80 |
|
| 81 |
-
|
| 82 |
-
|
|
|
|
| 83 |
|
| 84 |
if __name__ == "__main__":
|
| 85 |
-
|
| 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())
|
|
|
|
|
|
|
|
|
|
|
|