-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
40 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |