Spaces:
Configuration error
Configuration error
Update app.py
Browse files
app.py
CHANGED
|
@@ -43,13 +43,18 @@ STREAMER_TOKEN = random.choice([
|
|
| 43 |
"MTQ4NjA5Nzg0NDM4ODQ5NTQ1Mw.G6gyXL.nxOQaSyLNNQzntpVsbHJcaH3THdnu-H3qHQqBs"
|
| 44 |
])
|
| 45 |
|
| 46 |
-
async def start_bot(token, channel_id):
|
| 47 |
clean_token = token.strip()
|
| 48 |
intents = discord.Intents.default()
|
| 49 |
intents.message_content = True
|
| 50 |
intents.voice_states = True
|
| 51 |
|
| 52 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 53 |
bot.is_reconnecting = False
|
| 54 |
|
| 55 |
async def handle_streaming():
|
|
@@ -117,16 +122,15 @@ async def start_bot(token, channel_id):
|
|
| 117 |
except:
|
| 118 |
pass
|
| 119 |
|
| 120 |
-
# محاولة الاتصال الذكي وتخطي التعليق والحجب
|
| 121 |
try:
|
| 122 |
await bot.login(clean_token)
|
| 123 |
await bot.connect()
|
| 124 |
except Exception as e:
|
| 125 |
-
|
| 126 |
-
print(f'🔄
|
| 127 |
-
await
|
| 128 |
-
|
| 129 |
-
print(f'❌ خطأ نهائي في اتصال توكن [{clean_token[:15]}...]: {
|
| 130 |
|
| 131 |
# 🌐 تشغيل سيرفر ويب وهمي لمنع Hugging Face من إغلاق الـ Space
|
| 132 |
async def keep_alive():
|
|
|
|
| 43 |
"MTQ4NjA5Nzg0NDM4ODQ5NTQ1Mw.G6gyXL.nxOQaSyLNNQzntpVsbHJcaH3THdnu-H3qHQqBs"
|
| 44 |
])
|
| 45 |
|
| 46 |
+
async def start_bot(token, channel_id, use_proxy=False):
|
| 47 |
clean_token = token.strip()
|
| 48 |
intents = discord.Intents.default()
|
| 49 |
intents.message_content = True
|
| 50 |
intents.voice_states = True
|
| 51 |
|
| 52 |
+
# تحديد البروكسي عند بناء البوت إذا تطلب الأمر لتفادي الخطأ
|
| 53 |
+
bot_kwargs = {"command_prefix": "!", "self_bot": True, "intents": intents}
|
| 54 |
+
if use_proxy:
|
| 55 |
+
bot_kwargs["proxy"] = "http://45.72.63.14:80"
|
| 56 |
+
|
| 57 |
+
bot = commands.Bot(**bot_kwargs)
|
| 58 |
bot.is_reconnecting = False
|
| 59 |
|
| 60 |
async def handle_streaming():
|
|
|
|
| 122 |
except:
|
| 123 |
pass
|
| 124 |
|
|
|
|
| 125 |
try:
|
| 126 |
await bot.login(clean_token)
|
| 127 |
await bot.connect()
|
| 128 |
except Exception as e:
|
| 129 |
+
if not use_proxy:
|
| 130 |
+
print(f'🔄 خطأ في الاتصال العادي للتوكن [{clean_token[:15]}...]. جاري التحويل للبروكسي البديل...')
|
| 131 |
+
await start_bot(token, channel_id, use_proxy=True)
|
| 132 |
+
else:
|
| 133 |
+
print(f'❌ خطأ نهائي في اتصال توكن [{clean_token[:15]}...]: {e}')
|
| 134 |
|
| 135 |
# 🌐 تشغيل سيرفر ويب وهمي لمنع Hugging Face من إغلاق الـ Space
|
| 136 |
async def keep_alive():
|