-
Notifications
You must be signed in to change notification settings - Fork 10
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
1 parent
fae934d
commit df5a969
Showing
1 changed file
with
42 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import os, asyncio | ||
from pyrogram import Client, filters | ||
from pyrogram.types import InlineKeyboardMarkup, InlineKeyboardButton, Message, CallbackQuery | ||
from telegraph import upload_file | ||
from shizuchat.modules.helpers.mongo import get_file_id | ||
from shizuchat import shizuchat | ||
from shizuchat import shizuchat as Client | ||
|
||
|
||
@Client.on_message(filters.command("telegrap") & filters.private) | ||
async def telegraph_upload(bot, update): | ||
replied = update.reply_to_message | ||
if not replied: | ||
return await update.reply_text("Rᴇᴘʟʏ Tᴏ A Pʜᴏᴛᴏ Oʀ Vɪᴅᴇᴏ Uɴᴅᴇʀ 5ᴍʙ") | ||
file_info = get_file_id(replied) | ||
if not file_info: | ||
return await update.reply_text("Not Supported!") | ||
text = await update.reply_text(text="<code>Downloading To My Server ...</code>", disable_web_page_preview=True) | ||
media = await update.reply_to_message.download() | ||
await text.edit_text(text="<code>Downloading Completed. Now I am Uploading to telegra.ph Link ...</code>", disable_web_page_preview=True) | ||
try: | ||
response = upload_file(media) | ||
except Exception as error: | ||
print(error) | ||
await text.edit_text(text=f"Error :- {error}", disable_web_page_preview=True) | ||
return | ||
try: | ||
os.remove(media) | ||
except Exception as error: | ||
print(error) | ||
return | ||
await text.edit_text( | ||
text=f"<b>Link :-</b>\n\n<code>https://graph.org{response[0]}</code>", | ||
disable_web_page_preview=True, | ||
reply_markup=InlineKeyboardMarkup( [[ | ||
InlineKeyboardButton(text="Open Link", url=f"https://graph.org{response[0]}"), | ||
InlineKeyboardButton(text="Share Link", url=f"https://telegram.me/share/url?url=https://graph.org{response[0]}") | ||
],[ | ||
InlineKeyboardButton(text="✗ Close ✗", callback_data="close") | ||
]]) | ||
) | ||
|