File size: 11,665 Bytes
ccd2a2f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
08b0f04
 
ccd2a2f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
# ============================================================
#  تثبيت المتطلبات لو مش موجودة
# ============================================================
import sys, os, subprocess

try:
    import discord
except ImportError:
    print("[*] جاري تثبيت المتطلبات...")
    subprocess.check_call([sys.executable, "-m", "pip", "install", "-U",
        "discord.py-self==2.1.0",
        "aiohttp>=3.9.0",
        "colorama>=0.4.6",
        "audioop-lts"])

import discord
import asyncio# ============================================================
#  تثبيت المتطلبات لو مش موجودة
# ============================================================
import sys, os, subprocess

try:
    import discord
except ImportError:
    print("[*] جاري تثبيت المتطلبات...")
    subprocess.check_call([sys.executable, "-m", "pip", "install", "-U",
        "discord.py-self==2.1.0",
        "aiohttp>=3.9.0",
        "colorama>=0.4.6",
        "audioop-lts"])

import discord
import asyncio
import re
import traceback
import time

# ============================================================
#  حط التوكين هنا فقط
# ============================================================
TOKEN = "MTQxODM2MTIwNTE1NTY5MjY2Nw.GDbNu4.zmdHwdbkD0M85uk-YDDwOCuZcrr4pkg7fOMVMU"


GUILD_ID   = 1439271484127318221     # ID السيرفر
CHANNEL_ID = 1527544123890864319     # الروم الصوتي الهدف

# ============================================================
#  تعديل bug مكتبة discord.py-self
# ============================================================
try:
    state_path = os.path.join(os.path.dirname(discord.__file__), "state.py")
    if os.path.exists(state_path):
        with open(state_path, "r", encoding="utf-8") as f:
            content = f.read()
        content = re.sub(
            r"for p in data\.get\('pending_payments',\s*\[\]\)",
            "for p in (data.get('pending_payments') or [])",
            content
        )
        with open(state_path, "w", encoding="utf-8") as f:
            f.write(content)
        print("[✓] تم تعديل bug discord.py-self")
except Exception as e:
    print(f"[!] تعديل الـ bug: {e}")

def global_excepthook(exc_type, exc_value, exc_tb):
    print("!!! خطأ غير متوقع:")
    traceback.print_exception(exc_type, exc_value, exc_tb)
sys.excepthook = global_excepthook

print("=" * 40)
print("  🎯 VC — يدخل الفويس بس لو مش موجود")
print("=" * 40)

client = discord.Client(max_messages=None)

# عداد الطرد المتكرر + آخر مرة دخلنا
kick_count = 0
last_join_time = 0

async def is_in_any_voice(guild):
    """يرجع True لو الأكاونت موجود في أي فويس جوه السيرفر"""
    try:
        member = guild.get_member(client.user.id)
        if member is None:
            member = await guild.fetch_member(client.user.id)
        return member is not None and member.voice is not None
    except Exception as e:
        print(f"[✗] فحص الفويس فشل: {e}")
        return False

async def enter_target_voice():
    """يدخل الروم المحدد فقط لو مش موجود في فويس"""
    global kick_count, last_join_time
    try:
        guild = client.get_guild(GUILD_ID)
        if guild is None:
            print("[!] السيرفر مش محمّل")
            return
        if await is_in_any_voice(guild):
            print("[*] موجود في فويس بالفعل — مش هيتحرك")
            return
        channel = client.get_channel(CHANNEL_ID)
        if channel is None:
            print("[!] الروم مش محمّل")
            return
        await guild.change_voice_state(channel=channel, self_mute=False, self_deaf=False)
        last_join_time = time.time()
        kick_count = 0  # نجحنا ندخل → نصفر العداد
        print("[✓] دخلت الروم المحدد")
    except Exception as e:
        print(f"[✗] خطأ في الدخول: {e}")

@client.event
async def on_ready():
    try:
        print(f"[+] {client.user.name} متصل ✅")
        await enter_target_voice()
    except Exception as e:
        print(f"[✗] on_ready error: {e}")

@client.event
async def on_voice_state_update(member, before, after):
    global kick_count
    try:
        if member.id != client.user.id:
            return

        # خرج من فويس خالص
        if before.channel is not None and after.channel is None:
            # نتحقق إنه فعلًا مش في فويس (ممكن يكون اتنقل مش خرج)
            await asyncio.sleep(2)
            guild = client.get_guild(GUILD_ID)
            if guild and await is_in_any_voice(guild):
                print("[*] اتضح إنه لسه في فويس — تجاهل")
                return

            kick_count += 1
            if kick_count >= 3:
                wait = 300  # اتطرد 3 مرات ورا بعض → استنى 5 دقايق
                print(f"[!] اتطردت {kick_count} مرات ورا بعض — هرجع بعد {wait//60} دقايق")
                await asyncio.sleep(wait)
                kick_count = 0
            else:
                print("[!] خرجت من الفويس — هرجع بعد 10 ثواني")
                await asyncio.sleep(10)
            await enter_target_voice()
    except Exception as e:
        print(f"[✗] voice_state error: {e}")

async def run():
    attempt = 0
    while True:
        try:
            attempt = 0
            print("[*] جاري الاتصال بديسكورد...")
            await client.start(TOKEN)
        except discord.LoginFailure:
            print("[!!!] التوكين غلط أو متلغي — صلّحه و Restart")
            while True:
                await asyncio.sleep(60)
                print("[!] التوكين غير صالح")
        except asyncio.CancelledError:
            raise
        except Exception as e:
            attempt += 1
            wait = min(15 * attempt, 120)
            print(f"[!] انقطاع: {e} — هعيد بعد {wait} ثانية")
            await asyncio.sleep(wait)
        print("[!] الاتصال انغلق — هعيد التشغيل فورًا")
        await asyncio.sleep(5)

asyncio.run(run())

import re
import traceback
import time

# ============================================================
#  حط التوكين هنا فقط
# ============================================================
TOKEN = "MTQxODM2MTIwNTE1NTY5MjY2Nw.G2zOHn.S-BGHloJcraUmGAWiDv_LxWY4lV51pT3wxR6Hk"


GUILD_ID   = 512369682636865556     # ID السيرفر
CHANNEL_ID = 1562652593069498383     # الروم الصوتي الهدف

# ============================================================
#  تعديل bug مكتبة discord.py-self
# ============================================================
try:
    state_path = os.path.join(os.path.dirname(discord.__file__), "state.py")
    if os.path.exists(state_path):
        with open(state_path, "r", encoding="utf-8") as f:
            content = f.read()
        content = re.sub(
            r"for p in data\.get\('pending_payments',\s*\[\]\)",
            "for p in (data.get('pending_payments') or [])",
            content
        )
        with open(state_path, "w", encoding="utf-8") as f:
            f.write(content)
        print("[✓] تم تعديل bug discord.py-self")
except Exception as e:
    print(f"[!] تعديل الـ bug: {e}")

def global_excepthook(exc_type, exc_value, exc_tb):
    print("!!! خطأ غير متوقع:")
    traceback.print_exception(exc_type, exc_value, exc_tb)
sys.excepthook = global_excepthook

print("=" * 40)
print("  🎯 VC — يدخل الفويس بس لو مش موجود")
print("=" * 40)

client = discord.Client(max_messages=None)

# عداد الطرد المتكرر + آخر مرة دخلنا
kick_count = 0
last_join_time = 0

async def is_in_any_voice(guild):
    """يرجع True لو الأكاونت موجود في أي فويس جوه السيرفر"""
    try:
        member = guild.get_member(client.user.id)
        if member is None:
            member = await guild.fetch_member(client.user.id)
        return member is not None and member.voice is not None
    except Exception as e:
        print(f"[✗] فحص الفويس فشل: {e}")
        return False

async def enter_target_voice():
    """يدخل الروم المحدد فقط لو مش موجود في فويس"""
    global kick_count, last_join_time
    try:
        guild = client.get_guild(GUILD_ID)
        if guild is None:
            print("[!] السيرفر مش محمّل")
            return
        if await is_in_any_voice(guild):
            print("[*] موجود في فويس بالفعل — مش هيتحرك")
            return
        channel = client.get_channel(CHANNEL_ID)
        if channel is None:
            print("[!] الروم مش محمّل")
            return
        await guild.change_voice_state(channel=channel, self_mute=False, self_deaf=False)
        last_join_time = time.time()
        kick_count = 0  # نجحنا ندخل → نصفر العداد
        print("[✓] دخلت الروم المحدد")
    except Exception as e:
        print(f"[✗] خطأ في الدخول: {e}")

@client.event
async def on_ready():
    try:
        print(f"[+] {client.user.name} متصل ✅")
        await enter_target_voice()
    except Exception as e:
        print(f"[✗] on_ready error: {e}")

@client.event
async def on_voice_state_update(member, before, after):
    global kick_count
    try:
        if member.id != client.user.id:
            return

        # خرج من فويس خالص
        if before.channel is not None and after.channel is None:
            # نتحقق إنه فعلًا مش في فويس (ممكن يكون اتنقل مش خرج)
            await asyncio.sleep(2)
            guild = client.get_guild(GUILD_ID)
            if guild and await is_in_any_voice(guild):
                print("[*] اتضح إنه لسه في فويس — تجاهل")
                return

            kick_count += 1
            if kick_count >= 3:
                wait = 300  # اتطرد 3 مرات ورا بعض → استنى 5 دقايق
                print(f"[!] اتطردت {kick_count} مرات ورا بعض — هرجع بعد {wait//60} دقايق")
                await asyncio.sleep(wait)
                kick_count = 0
            else:
                print("[!] خرجت من الفويس — هرجع بعد 10 ثواني")
                await asyncio.sleep(10)
            await enter_target_voice()
    except Exception as e:
        print(f"[✗] voice_state error: {e}")

async def run():
    attempt = 0
    while True:
        try:
            attempt = 0
            print("[*] جاري الاتصال بديسكورد...")
            await client.start(TOKEN)
        except discord.LoginFailure:
            print("[!!!] التوكين غلط أو متلغي — صلّحه و Restart")
            while True:
                await asyncio.sleep(60)
                print("[!] التوكين غير صالح")
        except asyncio.CancelledError:
            raise
        except Exception as e:
            attempt += 1
            wait = min(15 * attempt, 120)
            print(f"[!] انقطاع: {e} — هعيد بعد {wait} ثانية")
            await asyncio.sleep(wait)
        print("[!] الاتصال انغلق — هعيد التشغيل فورًا")
        await asyncio.sleep(5)

asyncio.run(run())