| 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)...") |
|
|
| |
| |
| 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() |