import os
import subprocess
import sys
# --- [ وظيفة التثبيت التلقائي للمكتبات ] ---
def install_requirements():
try:
import telebot
except ImportError:
print("📥 Installing requirements (pyTelegramBotAPI)...")
subprocess.check_call([sys.executable, "-m", "pip", "install", "pyTelegramBotAPI"])
print("✅ Requirements installed. Restarting script...")
os.execl(sys.executable, sys.executable, *sys.argv)
install_requirements()
import telebot
# --- [ إعدادات البوت ] ---
# ضع التوكن الخاص بك بين القوسين بالأسفل
BOT_TOKEN = "ضع_التوكن_هنا"
if BOT_TOKEN == "ضع_التوكن_هنا":
BOT_TOKEN = input("📌 Please enter your Bot Token: ")
bot = telebot.TeleBot(BOT_TOKEN)
# مخزن مؤقت للملفات
user_data = {}
# نصوص الرسائل (دعم العربية والإنجليزية)
STRINGS = {
'start': {
'ar': "**مرحباً بك في بوت تغليف الملفات 📦**\n\nأرسل الآن أي ملف برمجي وسأقوم بتغليفه لك بصورة احترافية.",
'en': "**Welcome to File Packer Bot 📦**\n\nSend any code file and I will pack it for you with a custom cover."
},
'file_received': {
'ar': "✅ تم استلام الملف بنجاح.\n\n**الآن أرسل الصورة التي تريد جعلها غلافاً (Thumbnail) لهذا الملف:**",
'en': "✅ File received successfully.\n\n**Now send the image you want to use as a cover (Thumbnail):**"
},
'processing': {
'ar': "🔄 جاري المعالجة وإضافة الغلاف...",
'en': "🔄 Processing and adding the cover..."
},
'error_file': {
'ar': "⚠️ يرجى إرسال الملف أولاً قبل إرسال الصورة.",
'en': "⚠️ Please send the file first before sending the image."
},
'done': {
'ar': "**📦 تمت المعالجة بنجاح**\n\n📄 الملف: `{}`\n\n**الحقوق: @T44DT**",
'en': "**📦 Processed Successfully**\n\n📄 File: `{}`\n\n**Credits: @T44DT**"
}
}
def get_lang(message):
return 'ar' if message.from_user.language_code == 'ar' else 'en'
@bot.message_handler(commands=['start'])
def send_welcome(message):
lang = get_lang(message)
bot.reply_to(message, STRINGS['start'][lang], parse_mode="Markdown")
@bot.message_handler(content_types=['document'])
def handle_document(message):
lang = get_lang(message)
chat_id = message.chat.id
file_info = bot.get_file(message.document.file_id)
downloaded_file = bot.download_file(file_info.file_path)
file_name = message.document.file_name
file_path = f"temp_{chat_id}_{file_name}"
with open(file_path, 'wb') as new_file:
new_file.write(downloaded_file)
user_data[chat_id] = {'file_path': file_path, 'file_name': file_name}
bot.reply_to(message, STRINGS['file_received'][lang], parse_mode="Markdown")
@bot.message_handler(content_types=['photo'])
def handle_photo(message):
lang = get_lang(message)
chat_id = message.chat.id
if chat_id not in user_data:
bot.reply_to(message, STRINGS['error_file'][lang])
return
file_info = bot.get_file(message.photo[-1].file_id)
downloaded_photo = bot.download_file(file_info.file_path)
photo_path = f"thumb_{chat_id}.jpg"
with open(photo_path, 'wb') as f:
f.write(downloaded_photo)
bot.send_message(chat_id, STRINGS['processing'][lang])
file_path = user_data[chat_id]['file_path']
file_name = user_data[chat_id]['file_name']
with open(file_path, 'rb') as doc, open(photo_path, 'rb') as thumb:
bot.send_document(
chat_id,
doc,
thumbnail=thumb,
caption=STRINGS['done'][lang].format(file_name),
parse_mode="Markdown"
)
if os.path.exists(file_path): os.remove(file_path)
if os.path.exists(photo_path): os.remove(photo_path)
del user_data[chat_id]
if __name__ == '__main__':
print("🚀 Bot is starting...")
bot.infinity_polling()
📦 كود بوت تغليف الملفات الذكي (File Packer)
🛠 وظيفة البوت:
يقوم البوت بتحويل ملفاتك البرمجية العادية إلى ملفات احترافية من خلال إضافة غلاف (Thumbnail) خاص بها يظهر عند مشاركتها على تليجرام، مما يعطي طابعاً رسمياً وفاخر 💎
by : @T44DT & @H_A_C_H
19 abr, 23:53
20 abr, ~00:01

