Skip to content

Commit

Permalink
❖ | sᴧᴄʜɪɴ ꭙ sᴧɴᴧᴛᴧɴɪ | ❖
Browse files Browse the repository at this point in the history
  • Loading branch information
SEX-SUX authored Sep 15, 2024
1 parent bd9b339 commit d54d2c3
Showing 1 changed file with 40 additions and 17 deletions.
57 changes: 40 additions & 17 deletions SACHIN_MUSIC/plugins/tools/telegraph.py
Original file line number Diff line number Diff line change
@@ -1,46 +1,69 @@
import os
from pyrogram import filters
from pyrogram.types import InlineKeyboardMarkup, InlineKeyboardButton
from telegraph import upload_file
from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup
from SACHIN_MUSIC import app
from TheApi import api


@app.on_message(filters.command(["tgm", "tgt", "telegraph", "tl"]))
async def get_link_group(client, message):
if not message.reply_to_message:
return await message.reply_text(
"ᴘʟᴇᴀsᴇ ʀᴇᴘʟʏ ᴛᴏ ᴀ ᴍᴇᴅɪᴀ ᴛᴏ ᴜᴘʟᴏᴀᴅ ᴏɴ ᴛᴇʟᴇɢʀᴀᴘʜ"
"Pʟᴇᴀsᴇ ʀᴇᴘʟʏ ᴛᴏ ᴀ ᴍᴇᴅɪᴀ ᴛᴏ ᴜᴘʟᴏᴀᴅ ᴏɴ Tᴇʟᴇɢʀᴀᴘʜ"
)

media = message.reply_to_message
file_size = 0
if media.photo:
file_size = media.photo.file_size
elif media.video:
file_size = media.video.file_size
elif media.document:
file_size = media.document.file_size

if file_size > 15 * 1024 * 1024:
return await message.reply_text("Pʟᴇᴀsᴇ ᴘʀᴏᴠɪᴅᴇ ᴀ ᴍᴇᴅɪᴀ ғɪʟᴇ ᴜɴᴅᴇʀ 15MB.")

try:
text = await message.reply("❍ ᴘʀᴏᴄᴇssɪɴɢ...")
text = await message.reply("Pʀᴏᴄᴇssɪɴɢ...")

async def progress(current, total):
await text.edit_text(f"❍ ᴅᴏᴡɴʟᴏᴀᴅɪɴɢ... {current * 100 / total:.1f}%")
try:
await text.edit_text(f"📥 Dᴏᴡɴʟᴏᴀᴅɪɴɢ... {current * 100 / total:.1f}%")
except Exception:
pass

try:
location = f"cache"
local_path = await message.reply_to_message.download(
location, progress=progress
)
await text.edit_text("❍ ᴜᴘʟᴏᴀᴅɪɴɢ ᴛᴏ ᴛᴇʟᴇɢʀᴀᴘʜ...")
upload_path = upload_file(local_path)
local_path = await media.download(progress=progress)
await text.edit_text("📤 Uᴘʟᴏᴀᴅɪɴɢ ᴛᴏ ᴛᴇʟᴇɢʀᴀᴘʜ...")

upload_path = api.upload_image(local_path)

await text.edit_text(
f" | [ᴛᴇʟᴇɢʀᴀᴘʜ ʟɪɴᴋ](https://telegra.ph{upload_path[0]}) ❖",
f"🌐 | [ᴜᴘʟᴏᴀᴅᴇᴅ ʟɪɴᴋ]({upload_path})",
reply_markup=InlineKeyboardMarkup(
[
[
InlineKeyboardButton(
"• ᴛᴇʟᴇɢʀᴀᴘʜ ʟɪɴᴋ •",
url=f"https://telegra.ph{upload_path[0]}",
"ᴜᴘʟᴏᴀᴅᴇᴅ ғɪʟᴇ",
url=upload_path,
)
]
]
),
)
os.remove(local_path)

try:
os.remove(local_path)
except Exception:
pass

except Exception as e:
await text.edit_text(f"❍ |ғɪʟᴇ ᴜᴘʟᴏᴀᴅ ғᴀɪʟᴇᴅ \n\n<i>ʀᴇᴀsᴏɴ: {e}</i>")
os.remove(local_path)
await text.edit_text(f"❌ Fɪʟᴇ ᴜᴘʟᴏᴀᴅ ғᴀɪʟᴇᴅ\n\n<i>Rᴇᴀsᴏɴ: {e}</i>")
try:
os.remove(local_path)
except Exception:
pass
return
except Exception:
pass

0 comments on commit d54d2c3

Please sign in to comment.