Skip to content

Commit

Permalink
Create Telegraph.py
Browse files Browse the repository at this point in the history
  • Loading branch information
Badhacker98 authored Oct 18, 2024
1 parent fae934d commit df5a969
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions shizuchat/modules/Telegraph.py
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")
]])
)

0 comments on commit df5a969

Please sign in to comment.