File size: 4,511 Bytes
21bc372 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
import os
import time
from pyrogram.types import *
from pyrogram import *
from pyrogram.errors import *
from akn import log_detailed_error
from akn.utils.handler import *
from akn.utils.scripts import progress
from akn.utils.prefixprem import command
from config import *
custom_loading = "<emoji id=5974235702701853774>🗿</emoji>"
@Akeno(
~filters.scheduled
& command(["hpyer", "hyper", "hek"])
& filters.me
& ~filters.forwarded
)
async def hyperok(client: Client, message: Message):
link = message.text.split(" ", 1)[1] if len(message.command) > 1 else None
if not link:
return
then_do = link.split("/")
developed_by_me = int(then_do[-1])
text = f">> [{developed_by_me}]({link})"
await message.edit_text(text, disable_web_page_preview=True)
@Akeno(
~filters.scheduled
& command(["copy"])
& filters.me
& ~filters.forwarded
)
async def get_story_dl(client: Client, message: Message):
command, *options = message.text.split(" ", 2) if message.command else [None, []]
if client.me.is_premium:
pro = await message.reply_text(f"{custom_loading}Processing...")
else:
pro = await message.reply_text("Processing...")
if not command:
await pro.edit_text("Invalid command")
return
copy_chat = False
copy_story = False
for option in options:
if option == "-c":
copy_chat = True
elif option == "-s":
copy_story = True
text_link = options[-1] if options else None
if not text_link or not text_link.startswith("https://t.me/"):
await pro.edit_text("Invalid story or copy(chats) link")
return
try:
target_link = text_link.split("/c/") if "/c/" in text_link else text_link.split("/")
random_id = int(target_link[-1].split("/")[-1]) if len(target_link) > 1 else None
desired_username = target_link[3] if len(target_link) > 3 else None
username = "@" + desired_username if desired_username else "-100" + target_link[1].split("/")[0] if len(target_link) > 1 else None
if copy_chat and copy_story:
await pro.edit_text("Invalid options. Choose either -c or -s.")
return
elif copy_chat:
await client.copy_message(message.chat.id, from_chat_id=username, message_id=random_id, protect_content=True)
await pro.delete()
elif copy_story:
stories = await client.get_stories(username, story_ids=[random_id])
if stories:
for story in stories:
file_id = (
story.photo.file_id if story and story.photo else None
or story.video.file_id if story and story.video else None
)
caption = story.caption or f"By {client.me.mention}"
if file_id:
documents = await client.download_media(file_id)
if documents.endswith((".mp4", ".gif")):
send_function = client.send_video
else:
send_function = client.send_photo
seconds_time = time.time()
await send_function(
message.chat.id,
documents,
caption=caption,
progress=progress,
progress_args=(pro, seconds_time, "Processing...")
)
await pro.delete()
os.remove(documents)
else:
await pro.edit_text(f"Error: No stories found for {username}")
else:
await pro.edit_text("Invalid options. Choose either -c or -s.")
except ValueError as e:
await pro.edit_text(f"Error parsing for {username}: {e}")
except ChatWriteForbidden as e:
await pro.edit_text(f"Error: Bot doesn't have permission to write in the channel {username}")
except UserIsBlocked as e:
await pro.edit_text(f"Error: Bot is blocked by the user {username}")
except Exception as e:
await log_detailed_error(e, where=client.me.id, who=message.chat.title)
await pro.edit_text(f"Error retrieving or sending for {username}: {e}")
module = modules_help.add_module("storydl", __file__)
module.add_command("copy -c", "to copy chat group link")
module.add_command("copy -s", "to copy story link")
|