Update bot.py
Browse files
bot.py
CHANGED
|
@@ -1,108 +1,129 @@
|
|
| 1 |
import asyncio
|
| 2 |
import os
|
| 3 |
import logging
|
| 4 |
-
import
|
| 5 |
-
import
|
| 6 |
-
from threading import Thread
|
| 7 |
-
from http.server import HTTPServer, SimpleHTTPRequestHandler
|
| 8 |
-
from telethon import TelegramClient, functions
|
| 9 |
from telethon.sessions import StringSession
|
| 10 |
from telethon.tl.functions.channels import InviteToChannelRequest
|
| 11 |
-
from telethon.tl.types import InputPeerUser
|
| 12 |
from telethon.errors import (
|
| 13 |
-
FloodWaitError,
|
| 14 |
-
|
|
|
|
|
|
|
|
|
|
| 15 |
)
|
| 16 |
|
| 17 |
-
#
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
self.send_response(200)
|
| 21 |
-
self.send_header("Content-type", "text/html; charset=utf-8")
|
| 22 |
-
self.end_headers()
|
| 23 |
-
self.wfile.write("<h1>✅ البوت شغال: نقل + دعوات خاصة</h1>".encode("utf-8"))
|
| 24 |
-
def log_message(self, format, *args): pass
|
| 25 |
|
| 26 |
-
|
| 27 |
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
|
|
|
|
|
|
| 31 |
|
| 32 |
-
#
|
| 33 |
API_ID = int(os.getenv("API_ID", "0"))
|
| 34 |
API_HASH = os.getenv("API_HASH", "")
|
| 35 |
-
SESSION_STRING = os.getenv("SESSION_STRING"
|
| 36 |
SOURCE_CHANNEL = os.getenv("SOURCE_CHANNEL", "")
|
| 37 |
TARGET_CHANNEL = os.getenv("TARGET_CHANNEL", "")
|
| 38 |
-
INVITE_LINK = os.getenv("INVITE_LINK", f"https://t.me/{TARGET_CHANNEL}") # رابط الدعوة
|
| 39 |
-
LIMIT = int(os.getenv("LIMIT", "50"))
|
| 40 |
-
BASE_DELAY = int(os.getenv("DELAY_SECONDS", "300"))
|
| 41 |
|
| 42 |
-
#
|
| 43 |
-
|
|
|
|
| 44 |
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 52 |
|
|
|
|
| 53 |
source = await client.get_entity(SOURCE_CHANNEL)
|
| 54 |
target = await client.get_entity(TARGET_CHANNEL)
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 67 |
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
logger.info(f"✉️ الإضافة مقيدة. إرسال دعوة خاصة لـ {name}...")
|
| 79 |
-
await client.send_message(member.id, MESSAGE_TEXT)
|
| 80 |
-
success_msg += 1
|
| 81 |
-
logger.info(f"✅ تم إرسال الدعوة بنجاح لـ {name}")
|
| 82 |
-
except Exception as e:
|
| 83 |
-
logger.info(f"❌ فشل إرسال الرسالة أيضاً: {type(e).__name__}")
|
| 84 |
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
# انتظ
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 102 |
|
| 103 |
if __name__ == "__main__":
|
| 104 |
-
|
| 105 |
-
asyncio.run(main())
|
| 106 |
-
logger.info("💤 استراحة 15 دقيقة...")
|
| 107 |
-
import time
|
| 108 |
-
time.sleep(900)
|
|
|
|
| 1 |
import asyncio
|
| 2 |
import os
|
| 3 |
import logging
|
| 4 |
+
import gradio as gr
|
| 5 |
+
from telethon import TelegramClient
|
|
|
|
|
|
|
|
|
|
| 6 |
from telethon.sessions import StringSession
|
| 7 |
from telethon.tl.functions.channels import InviteToChannelRequest
|
| 8 |
+
from telethon.tl.types import InputPeerUser
|
| 9 |
from telethon.errors import (
|
| 10 |
+
FloodWaitError,
|
| 11 |
+
UserPrivacyRestrictedError,
|
| 12 |
+
PeerFloodError,
|
| 13 |
+
UserAlreadyParticipantError,
|
| 14 |
+
UserChannelsTooMuchError
|
| 15 |
)
|
| 16 |
|
| 17 |
+
# إعداد اللوق
|
| 18 |
+
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(message)s')
|
| 19 |
+
logger = logging.getLogger(__name__)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
|
| 21 |
+
log_history = []
|
| 22 |
|
| 23 |
+
def ui_print(msg):
|
| 24 |
+
logger.info(msg)
|
| 25 |
+
log_history.append(msg)
|
| 26 |
+
if len(log_history) > 40:
|
| 27 |
+
log_history.pop(0)
|
| 28 |
|
| 29 |
+
# المتغيرات السريّة (Secrets)
|
| 30 |
API_ID = int(os.getenv("API_ID", "0"))
|
| 31 |
API_HASH = os.getenv("API_HASH", "")
|
| 32 |
+
SESSION_STRING = os.getenv("SESSION_STRING", "")
|
| 33 |
SOURCE_CHANNEL = os.getenv("SOURCE_CHANNEL", "")
|
| 34 |
TARGET_CHANNEL = os.getenv("TARGET_CHANNEL", "")
|
|
|
|
|
|
|
|
|
|
| 35 |
|
| 36 |
+
# 🚀 وضع الهجوم: سحب عدد ضخم والانتظار 5 ثواني فقط!
|
| 37 |
+
LIMIT = 200
|
| 38 |
+
AGGRESSIVE_DELAY = 5
|
| 39 |
|
| 40 |
+
client = TelegramClient(StringSession(SESSION_STRING.strip()), API_ID, API_HASH)
|
| 41 |
+
|
| 42 |
+
async def aggressive_transfer():
|
| 43 |
+
log_history.clear()
|
| 44 |
+
ui_print("🔥 بدء وضع الرشق الهجومي (بدون فلترة، سرعة قصوى)...")
|
| 45 |
+
|
| 46 |
+
await client.connect()
|
| 47 |
+
if not await client.is_user_authorized():
|
| 48 |
+
ui_print("❌ الجلسة غير صالحة!")
|
| 49 |
+
await client.disconnect()
|
| 50 |
+
return
|
| 51 |
|
| 52 |
+
try:
|
| 53 |
source = await client.get_entity(SOURCE_CHANNEL)
|
| 54 |
target = await client.get_entity(TARGET_CHANNEL)
|
| 55 |
+
except Exception as e:
|
| 56 |
+
ui_print(f"❌ خطأ في القنوات: {e}")
|
| 57 |
+
await client.disconnect()
|
| 58 |
+
return
|
| 59 |
+
|
| 60 |
+
try:
|
| 61 |
+
ui_print("👥 جاري جلب كمية ضخمة من الأعضاء...")
|
| 62 |
+
# جلب عدد كبير جداً بدون الاهتمام لحالتهم
|
| 63 |
+
participants = await client.get_participants(source, limit=1000)
|
| 64 |
+
except Exception as e:
|
| 65 |
+
ui_print(f"❌ خطأ في جلب الأعضاء: {e}")
|
| 66 |
+
await client.disconnect()
|
| 67 |
+
return
|
| 68 |
+
|
| 69 |
+
success = 0
|
| 70 |
+
processed = 0
|
| 71 |
+
|
| 72 |
+
for member in participants:
|
| 73 |
+
if success >= LIMIT:
|
| 74 |
+
ui_print("🎯 وصلنا للحد المطلوب لهذه الدورة.")
|
| 75 |
+
break
|
| 76 |
|
| 77 |
+
if member.bot or member.deleted:
|
| 78 |
+
continue
|
| 79 |
+
|
| 80 |
+
processed += 1
|
| 81 |
+
name = member.first_name or "مجهول"
|
| 82 |
+
|
| 83 |
+
try:
|
| 84 |
+
# إضافة سريعة مباشرة
|
| 85 |
+
user_to_add = InputPeerUser(user_id=member.id, access_hash=member.access_hash or 0)
|
| 86 |
+
await client(InviteToChannelRequest(channel=target, users=[user_to_add]))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 87 |
|
| 88 |
+
success += 1
|
| 89 |
+
ui_print(f"[{processed}] ✅ رشق ناجح: {name}")
|
| 90 |
+
|
| 91 |
+
# انتظار قصير جداً (5 ثواني) لزيادة العدد بسرعة قبل الحظر
|
| 92 |
+
await asyncio.sleep(AGGRESSIVE_DELAY)
|
| 93 |
+
|
| 94 |
+
except PeerFloodError:
|
| 95 |
+
ui_print(f"🚨 فلود! تيليجرام يحاول إيقافنا. تخطي سريع لـ {name}...")
|
| 96 |
+
await asyncio.sleep(2) # لا ننتظر كثيراً، نهجم على اللي بعده
|
| 97 |
+
continue
|
| 98 |
+
except UserAlreadyParticipantError:
|
| 99 |
+
pass # تخطي صامت
|
| 100 |
+
except UserPrivacyRestrictedError:
|
| 101 |
+
pass # تخطي صامت لتسريع العملية
|
| 102 |
+
except FloodWaitError as e:
|
| 103 |
+
if e.seconds > 60:
|
| 104 |
+
ui_print(f"⚠️ فلود طويل ({e.seconds}ث). سنتخطاه فوراً!")
|
| 105 |
+
continue # تخطي فوري بدون انتظار
|
| 106 |
+
else:
|
| 107 |
+
await asyncio.sleep(e.seconds)
|
| 108 |
+
except Exception as e:
|
| 109 |
+
pass
|
| 110 |
+
|
| 111 |
+
ui_print(f"🏁 انتهى الهجوم! رشّقنا {success} عضو للجروب.")
|
| 112 |
+
await client.disconnect()
|
| 113 |
+
|
| 114 |
+
def get_logs():
|
| 115 |
+
return "\n".join(log_history) if log_history else "في انتظار إطلاق الهجوم..."
|
| 116 |
+
|
| 117 |
+
# =============== واجهة Gradio ===============
|
| 118 |
+
with gr.Blocks(title="بوت الرشق السريع", theme=gr.themes.Monochrome()) as demo:
|
| 119 |
+
gr.Markdown("## 💣 بوت الرشق الهجومي (لزيادة العدد فقط - قد يعرض الحساب للحظر)")
|
| 120 |
+
start_btn = gr.Button("🔥 ابدأ الهجوم الآن")
|
| 121 |
+
log_box = gr.Textbox(label="مراقبة الرشق", lines=20, interactive=False)
|
| 122 |
+
|
| 123 |
+
start_btn.click(fn=aggressive_transfer, outputs=None)
|
| 124 |
+
|
| 125 |
+
timer = gr.Timer(1)
|
| 126 |
+
timer.tick(fn=get_logs, outputs=log_box)
|
| 127 |
|
| 128 |
if __name__ == "__main__":
|
| 129 |
+
demo.launch(server_name="0.0.0.0", server_port=7860)
|
|
|
|
|
|
|
|
|
|
|
|