Spaces:
Configuration error
Configuration error
Delete main.py
Browse files
main.py
DELETED
|
@@ -1,157 +0,0 @@
|
|
| 1 |
-
# ============================================================
|
| 2 |
-
# تثبيت المتطلبات لو مش موجودة
|
| 3 |
-
# ============================================================
|
| 4 |
-
import sys, os, subprocess
|
| 5 |
-
|
| 6 |
-
try:
|
| 7 |
-
import discord
|
| 8 |
-
except ImportError:
|
| 9 |
-
print("[*] جاري تثبيت المتطلبات...")
|
| 10 |
-
subprocess.check_call([sys.executable, "-m", "pip", "install", "-U",
|
| 11 |
-
"discord.py-self==2.1.0",
|
| 12 |
-
"aiohttp>=3.9.0",
|
| 13 |
-
"colorama>=0.4.6",
|
| 14 |
-
"audioop-lts"])
|
| 15 |
-
|
| 16 |
-
import discord
|
| 17 |
-
import asyncio
|
| 18 |
-
import re
|
| 19 |
-
import traceback
|
| 20 |
-
import time
|
| 21 |
-
|
| 22 |
-
# ============================================================
|
| 23 |
-
# حط التوكين هنا فقط
|
| 24 |
-
# ============================================================
|
| 25 |
-
TOKEN = "MTQxODM2MTIwNTE1NTY5MjY2Nw.G2zOHn.S-BGHloJcraUmGAWiDv_LxWY4lV51pT3wxR6Hk"
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
GUILD_ID = 512369682636865556 # ID السيرفر
|
| 29 |
-
CHANNEL_ID = 806092039410286612 # الروم الصوتي الهدف
|
| 30 |
-
|
| 31 |
-
# ============================================================
|
| 32 |
-
# تعديل bug مكتبة discord.py-self
|
| 33 |
-
# ============================================================
|
| 34 |
-
try:
|
| 35 |
-
state_path = os.path.join(os.path.dirname(discord.__file__), "state.py")
|
| 36 |
-
if os.path.exists(state_path):
|
| 37 |
-
with open(state_path, "r", encoding="utf-8") as f:
|
| 38 |
-
content = f.read()
|
| 39 |
-
content = re.sub(
|
| 40 |
-
r"for p in data\.get\('pending_payments',\s*\[\]\)",
|
| 41 |
-
"for p in (data.get('pending_payments') or [])",
|
| 42 |
-
content
|
| 43 |
-
)
|
| 44 |
-
with open(state_path, "w", encoding="utf-8") as f:
|
| 45 |
-
f.write(content)
|
| 46 |
-
print("[✓] تم تعديل bug discord.py-self")
|
| 47 |
-
except Exception as e:
|
| 48 |
-
print(f"[!] تعديل الـ bug: {e}")
|
| 49 |
-
|
| 50 |
-
def global_excepthook(exc_type, exc_value, exc_tb):
|
| 51 |
-
print("!!! خطأ غير متوقع:")
|
| 52 |
-
traceback.print_exception(exc_type, exc_value, exc_tb)
|
| 53 |
-
sys.excepthook = global_excepthook
|
| 54 |
-
|
| 55 |
-
print("=" * 40)
|
| 56 |
-
print(" 🎯 VC — يدخل الفويس بس لو مش موجود")
|
| 57 |
-
print("=" * 40)
|
| 58 |
-
|
| 59 |
-
client = discord.Client(max_messages=None)
|
| 60 |
-
|
| 61 |
-
# عداد الطرد المتكرر + آخر مرة دخلنا
|
| 62 |
-
kick_count = 0
|
| 63 |
-
last_join_time = 0
|
| 64 |
-
|
| 65 |
-
async def is_in_any_voice(guild):
|
| 66 |
-
"""يرجع True لو الأكاونت موجود في أي فويس جوه السيرفر"""
|
| 67 |
-
try:
|
| 68 |
-
member = guild.get_member(client.user.id)
|
| 69 |
-
if member is None:
|
| 70 |
-
member = await guild.fetch_member(client.user.id)
|
| 71 |
-
return member is not None and member.voice is not None
|
| 72 |
-
except Exception as e:
|
| 73 |
-
print(f"[✗] فحص الفويس فشل: {e}")
|
| 74 |
-
return False
|
| 75 |
-
|
| 76 |
-
async def enter_target_voice():
|
| 77 |
-
"""يدخل الروم المحدد فقط لو مش موجود في فويس"""
|
| 78 |
-
global kick_count, last_join_time
|
| 79 |
-
try:
|
| 80 |
-
guild = client.get_guild(GUILD_ID)
|
| 81 |
-
if guild is None:
|
| 82 |
-
print("[!] السيرفر مش محمّل")
|
| 83 |
-
return
|
| 84 |
-
if await is_in_any_voice(guild):
|
| 85 |
-
print("[*] موجود في فويس بالفعل — مش هيتحرك")
|
| 86 |
-
return
|
| 87 |
-
channel = client.get_channel(CHANNEL_ID)
|
| 88 |
-
if channel is None:
|
| 89 |
-
print("[!] الروم مش محمّل")
|
| 90 |
-
return
|
| 91 |
-
await guild.change_voice_state(channel=channel, self_mute=False, self_deaf=False)
|
| 92 |
-
last_join_time = time.time()
|
| 93 |
-
kick_count = 0 # نجحنا ندخل → نصفر العداد
|
| 94 |
-
print("[✓] دخلت الروم المحدد")
|
| 95 |
-
except Exception as e:
|
| 96 |
-
print(f"[✗] خطأ في الدخول: {e}")
|
| 97 |
-
|
| 98 |
-
@client.event
|
| 99 |
-
async def on_ready():
|
| 100 |
-
try:
|
| 101 |
-
print(f"[+] {client.user.name} متصل ✅")
|
| 102 |
-
await enter_target_voice()
|
| 103 |
-
except Exception as e:
|
| 104 |
-
print(f"[✗] on_ready error: {e}")
|
| 105 |
-
|
| 106 |
-
@client.event
|
| 107 |
-
async def on_voice_state_update(member, before, after):
|
| 108 |
-
global kick_count
|
| 109 |
-
try:
|
| 110 |
-
if member.id != client.user.id:
|
| 111 |
-
return
|
| 112 |
-
|
| 113 |
-
# خرج من فويس خالص
|
| 114 |
-
if before.channel is not None and after.channel is None:
|
| 115 |
-
# نتحقق إنه فعلًا مش في فويس (ممكن يكون اتنقل مش خرج)
|
| 116 |
-
await asyncio.sleep(2)
|
| 117 |
-
guild = client.get_guild(GUILD_ID)
|
| 118 |
-
if guild and await is_in_any_voice(guild):
|
| 119 |
-
print("[*] اتضح إنه لسه في فويس — تجاهل")
|
| 120 |
-
return
|
| 121 |
-
|
| 122 |
-
kick_count += 1
|
| 123 |
-
if kick_count >= 3:
|
| 124 |
-
wait = 300 # اتطرد 3 مرات ورا بعض → استنى 5 دقايق
|
| 125 |
-
print(f"[!] اتطردت {kick_count} مرات ورا بعض — هرجع بعد {wait//60} دقايق")
|
| 126 |
-
await asyncio.sleep(wait)
|
| 127 |
-
kick_count = 0
|
| 128 |
-
else:
|
| 129 |
-
print("[!] خرجت من الفويس — هرجع بعد 10 ثواني")
|
| 130 |
-
await asyncio.sleep(10)
|
| 131 |
-
await enter_target_voice()
|
| 132 |
-
except Exception as e:
|
| 133 |
-
print(f"[✗] voice_state error: {e}")
|
| 134 |
-
|
| 135 |
-
async def run():
|
| 136 |
-
attempt = 0
|
| 137 |
-
while True:
|
| 138 |
-
try:
|
| 139 |
-
attempt = 0
|
| 140 |
-
print("[*] جاري الاتصال بديسكورد...")
|
| 141 |
-
await client.start(TOKEN)
|
| 142 |
-
except discord.LoginFailure:
|
| 143 |
-
print("[!!!] التوكين غلط أو متلغي — صلّحه و Restart")
|
| 144 |
-
while True:
|
| 145 |
-
await asyncio.sleep(60)
|
| 146 |
-
print("[!] التوكين غير صالح")
|
| 147 |
-
except asyncio.CancelledError:
|
| 148 |
-
raise
|
| 149 |
-
except Exception as e:
|
| 150 |
-
attempt += 1
|
| 151 |
-
wait = min(15 * attempt, 120)
|
| 152 |
-
print(f"[!] انقطاع: {e} — هعيد بعد {wait} ثانية")
|
| 153 |
-
await asyncio.sleep(wait)
|
| 154 |
-
print("[!] الاتصال انغلق — هعيد التشغيل فورًا")
|
| 155 |
-
await asyncio.sleep(5)
|
| 156 |
-
|
| 157 |
-
asyncio.run(run())
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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