Кабинет

Посты канала 𖣴ㅤ⁠⁠⁠ 𝅥𝅽𝅾 𝖵𝖾𝗑 | 𝖢𝗁ᥲ𝗇𝗇ᥱ𝗅 ₊˚.

сначала новые

#3498Текст
Просмотры140−33%к среднему
Пересылки—
Реакции—
Комментарии—
#3491Текст
Просмотры287+36%к среднему
Пересылки—
Реакции—
Комментарии—
#3485Текст

import requests import os import tempfile from telegram import Update from telegram.ext import Application, MessageHandler, filters, ContextTypes, CommandHandler # ضع التوكن الخاص بك هنا BOT_TOKEN = "YOUR_BOT_TOKEN_HERE" CATBOX_URL = "https://catbox.moe/user/api.php" async def start(update: Update, context: ContextTypes.DEFAULT_TYPE): await update.message.reply_text( "👋 أهلاً بك!\n" "أرسل لي أي ملف (صورة، فيديو، مستند، صوت) وسأرفعه لك على Catbox وأعيد لك الرابط." ) async def upload_file(update: Update, context: ContextTypes.DEFAULT_TYPE): message = update.message # تحديد الملف المرسل if message.document: tg_file = await message.document.get_file() filename = message.document.file_name or "file" elif message.photo: tg_file = await message.photo[-1].get_file() filename = f"photo_{message.photo[-1].file_id[:8]}.jpg" elif message.video: tg_file = await message.video.get_file() filename = message.video.file_name or "video.mp4" elif message.audio: tg_file = await message.audio.get_file() filename = message.audio.file_name or "audio.mp3" elif message.voice: tg_file = await message.voice.get_file() filename = "voice.ogg" else: await message.reply_text("❌ نوع الملف غير مدعوم.") return status_msg = await message.reply_text("⏳ جاري تحميل الملف من تليجرام...") # تحميل الملف مؤقتاً tmp_path = os.path.join(tempfile.gettempdir(), filename) await tg_file.download_to_drive(tmp_path) await status_msg.edit_text("📤 جاري الرفع إلى Catbox...") try: files = [ ('reqtype', (None, 'fileupload')), ('fileToUpload', (filename, open(tmp_path, 'rb'), 'application/octet-stream')) ] headers = { 'User-Agent': "Mozilla/5.0 (Linux; Android 13; Mobile) AppleWebKit/537.36 " "(KHTML, like Gecko) Chrome/120.0 Mobile Safari/537.36", } response = requests.post(CATBOX_URL, files=files, headers=headers, timeout=300) response.raise_for_status() file_url = response.text.strip() if file_url.startswith("https://"): await status_msg.edit_text( f"✅ تم الرفع بنجاح!\n\n" f"🔗 الرابط:\n{file_url}\n\n" f"📦 الحجم: {os.path.getsize(tmp_path) / (1024*1024):.2f} MB" ) else: await status_msg.edit_text(f"❌ فشل الرفع:\n{file_url}") except Exception as e: await status_msg.edit_text(f"⚠️ خطأ: {e}") finally: if os.path.exists(tmp_path): os.remove(tmp_path) def main(): app = Application.builder().token(BOT_TOKEN).build() app.add_handler(CommandHandler("start", start)) app.add_handler(MessageHandler( filters.Document.ALL | filters.PHOTO | filters.VIDEO | filters.AUDIO | filters.VOICE, upload_file )) print("✅ البوت يعمل...") app.run_polling(allowed_updates=Update.ALL_TYPES) if name == "main": main()

Открыть в Telegram
Просмотры285+35%к среднему
Пересылки—
Реакции—
Комментарии—