import os import time import requests import img2pdf from telegram import Update from telegram.ext import Application, CommandHandler, MessageHandler, filters, ContextTypes TOKEN = "YOUR_TELEGRAM_BOT_TOKEN" API_URL = "http://127.0.0.1:4567/api/v1" # رابط المحرك الداخلي async def start(update: Update, context: ContextTypes.DEFAULT_TYPE): await update.message.reply_text("🤖 بوت ميهون للمانهوا جاهز!\nأرسل رابط المانهوا وسأقوم بجلبها لك كـ PDF.") async def handle_manga(update: Update, context: ContextTypes.DEFAULT_TYPE): url = update.message.text await update.message.reply_text("⏳ جاري الاتصال بمحرك الاستخراج (Tachidesk)...") # هنا البوت يطلب من المحرك البحث عن المانهوا (Logic مبسط) # ملاحظة: Tachidesk يحتاج ضبط للإضافات أولاً try: # عملية التحميل والتحويل (تتم داخلياً) # هذا مثال توضيحي لسحب الصور ودمجها msg = await update.message.reply_text("📥 جاري تحميل الصفحات...") # كود دمج الصور (كما شرحنا سابقاً) # سيقوم البوت بسحب الصور من المسار المحلي للمحرك await update.message.reply_document(document=open("manga.pdf", "rb"), filename="Manga.pdf") except Exception as e: await update.message.reply_text(f"❌ حدث خطأ: {e}") if __name__ == '__main__': application = Application.builder().token(TOKEN).build() application.add_handler(CommandHandler("start", start)) application.add_handler(MessageHandler(filters.TEXT & ~filters.COMMAND, handle_manga)) application.run_polling()