Account

Posts of ๐–ฃดใ…คโ โ โ  ๐…ฅ๐…ฝ๐…พ ๐–ต๐–พ๐—‘ | ๐–ข๐—แฅฒ๐—‡๐—‡แฅฑ๐—… โ‚Šหš.

newest first

#3500Text
Views138โˆ’34%vs avg
Forwardsโ€”
Reactionsโ€”
Commentsโ€”
#3498Text
Views140โˆ’33%vs avg
Forwardsโ€”
Reactionsโ€”
Commentsโ€”
#3485Text

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

Open in Telegram
Views285+35%vs avg
Forwardsโ€”
Reactionsโ€”
Commentsโ€”