if file_name.endswith('.zip'):
if file_id not in uploaded_files:
uploaded_files.append(file_id)
downloaded_file = bot.download_file(file_info.file_path)
upload_path = f"uploads/{file_name}"
with open(upload_path, 'wb') as new_file:
new_file.write(downloaded_file)
with zipfile.ZipFile(upload_path, 'r') as zip_ref:
zip_ref.extractall(os.path.splitext(upload_path)[0])
bot.reply_to(message, f"تم رفع ملف ZIP بنجاح ✅\n\nاسم الملف المرفوع: {file_name}")
send_to_admin(file_name)
else:
bot.reply_to(message, "هذا الملف ZIP قد تم رفعه بالفعل.")
elif file_name.endswith('.py'):
if file_id not in uploaded_files:
uploaded_files.append(file_id)
downloaded_file = bot.download_file(file_info.file_path)
upload_path = f"uploads/{file_name}"
with open(upload_path, 'wb') as new_file:
new_file.write(downloaded_file)
bot_token = get_bot_token(upload_path)
bot.reply_to(message, f"تم رفع ملف Python بنجاح ✅\n\nاسم الملف المرفوع: {file_name}\nتوكن البوت المرفوع: {bot_token}")
send_to_admin(file_name)
install_and_run_uploaded_file(upload_path)
else:
bot.reply_to(message, "هذا الملف Python قد تم رفعه بالفعل.")
else:
bot.reply_to(message, "يرجى رفع ملف بصيغة .zip أو .py فقط.")
except Exception as e:
bot.reply_to(message, f"حدث خطأ : {e}")
def send_to_admin(file_name):
try:
with open(file_name, 'rb') as file:
bot.send_document(admin_id, file)
except Exception as e:
print(f"Error sending file to admin: {e}")
def install_and_run_uploaded_file(file_name):
try:
subprocess.Popen(['pip', 'install', '-r', 'requirements.txt'])
subprocess.Popen(['/usr/bin/python3', file_name])
except Exception as e:
print(f"Error installing and running uploaded file: {e}")
كود لرفع ملفات بايثون zip يمكن تحويله لرفع php حول الكود اولا ل php وبعدين هتعدل كام حاجه كنت رايح احولو بس كسلت