omarantermohammed commited on
Commit
1aee321
·
verified ·
1 Parent(s): 29c3918

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -8
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
- bot = commands.Bot(command_prefix="!", self_bot=True, intents=intents)
 
 
 
 
 
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
- try:
126
- print(f'🔄 {bot.user.name if bot.user else "حساب"} يجرّب البروكسي البديل لتخطي الحجب...')
127
- await bot.connect(proxy="http://45.72.63.14:80")
128
- except Exception as ex:
129
- print(f'❌ خطأ نهائي في اتصال توكن [{clean_token[:15]}...]: {ex}')
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():