Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 78 additions & 0 deletions misc/tdel.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
import asyncio
from pyrogram import Client, filters, enums
from pyrogram.types import Message
from utils.misc import modules_help, prefix

@Client.on_message(filters.command("tdel", prefix) & filters.me)
async def tdel_message(_, message: Message):
if len(message.command) <= 2:
await message.edit(
"<b>Error:</b> <i>You must specify time (seconds) and message text</i>\n"
"<b>Example:</b> <code>.tdel 10 Hello everyone!</code>",
parse_mode=enums.ParseMode.HTML,
)
await asyncio.sleep(5)
await message.delete()
return

try:
delete_time = int(message.command[1])
text = " ".join(message.command[2:])

if delete_time <= 0:
await message.edit(
"<b>Error:</b> <i>Time must be a positive number!</i>",
parse_mode=enums.ParseMode.HTML,
)
await asyncio.sleep(3)
await message.delete()
return

if delete_time > 86400:
await message.edit(
"<b>Error:</b> <i>Maximum time is 24 hours (86400 seconds)!</i>",
parse_mode=enums.ParseMode.HTML,
)
await asyncio.sleep(5)
await message.delete()
return

if not text.strip():
await message.edit(
"<b>Error:</b> <i>Message text cannot be empty!</i>",
parse_mode=enums.ParseMode.HTML,
)
await asyncio.sleep(3)
await message.delete()
return

await message.edit(
text,
parse_mode=enums.ParseMode.HTML,
)

await asyncio.sleep(delete_time)
await message.delete()

except ValueError:
await message.edit(
"<b>Error:</b> <i>Time must be an integer!</i>\n"
"<b>Example:</b> <code>.tdel 30 This message will be deleted in 30 seconds</code>",
parse_mode=enums.ParseMode.HTML,
)
await asyncio.sleep(5)
await message.delete()
except Exception as e:
await message.edit(
f"<b>Unexpected error:</b> <code>{str(e)}</code>",
parse_mode=enums.ParseMode.HTML,
)
await asyncio.sleep(5)
await message.delete()

modules_help["timed_delete"] = {
"tdel [time] [text]*": "send self-deleting message\n"
"time: seconds until deletion\n"
"text: message content\n"
"example: .tdel 60 this message will delete in one minute"
}
73 changes: 73 additions & 0 deletions utils/anon.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
from pyrogram import Client, filters, enums
from pyrogram.types import Message
from pyrogram.errors import FloodWait, ChannelInvalid, PeerIdInvalid
from utils.misc import modules_help, prefix

@Client.on_message(filters.command("anon", prefix) & filters.me)
async def anon(client: Client, message: Message):
if len(message.command) < 2:
await message.edit(
"<b>Usage:</b> <code>anon [channel_id] [message]</code> or reply to a message to forward it.",
parse_mode=enums.ParseMode.HTML,
)
return

try:
source_chat_id = message.chat.id
anon_channel_id = int(message.command[1])
text_content = " ".join(message.command[2:]) if len(message.command) > 2 else None
except (ValueError, IndexError):
await message.edit(
"<b>Error:</b> Invalid command format. Use <code>anon [channel_id] [text]</code>",
parse_mode=enums.ParseMode.HTML,
)
return

replied_to_message = message.reply_to_message

if not replied_to_message and not text_content:
await message.edit(
"<b>Error:</b> You must provide text or reply to a message/media.",
parse_mode=enums.ParseMode.HTML,
)
return

original_message_id = message.id

try:
await message.delete()

if replied_to_message:
sent_message = await replied_to_message.copy(anon_channel_id)
else:
sent_message = await client.send_message(
chat_id=anon_channel_id,
text=text_content,
parse_mode=enums.ParseMode.MARKDOWN,
)

await sent_message.forward(source_chat_id)

except (ChannelInvalid, PeerIdInvalid):
await client.send_message(
chat_id=source_chat_id,
text=f"<b>Error:</b> The ID <code>{anon_channel_id}</code> is invalid or I am not an admin in that channel.",
parse_mode=enums.ParseMode.HTML,
)
except FloodWait as e:
await client.send_message(
chat_id=source_chat_id,
text=f"<b>FloodWait:</b> Please wait for {e.value} seconds.",
parse_mode=enums.ParseMode.HTML,
)
except Exception as e:
await client.send_message(
chat_id=source_chat_id,
text=f"<b>An unexpected error occurred:</b>\n<code>{e}</code>",
parse_mode=enums.ParseMode.HTML,
)

modules_help["anonymizer"] = {
"anon [id] [message]": "Sends a text message to the specified channel/group ID and then forwards it to the current chat, hiding the original sender. The original command is deleted.",
"anon [id] (as reply)": "Copies the replied-to message/media to the specified channel/group ID and then forwards it to the current chat, hiding the original sender. The original command is deleted.",
}
46 changes: 46 additions & 0 deletions utils/fidsend.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import asyncio
from pyrogram import Client, filters, enums
from pyrogram.types import Message
from utils.misc import modules_help, prefix

@Client.on_message(filters.command("fidsend", prefix) & filters.me)
async def fidsend(_, message: Message):
if len(message.command) <= 1:
return

file_id = " ".join(message.command[1:])

try:
try:
await message.reply_photo(file_id)
except:
try:
await message.reply_video(file_id)
except:
try:
await message.reply_sticker(file_id)
except:
try:
await message.reply_voice(file_id)
except:
try:
await message.reply_video_note(file_id)
except:
try:
await message.reply_audio(file_id)
except:
try:
await message.reply_animation(file_id)
except:
await message.reply_document(file_id)

await message.delete()
except Exception as e:
await message.edit(
f"<b>Error:</b> <code>{e}</code>",
parse_mode=enums.ParseMode.HTML,
)

modules_help["file_sender"] = {
"fidsend [file_id]*": "send any media file using its file ID\nSupports: photo, video, sticker, voice, video note, audio, animation, document"
}
42 changes: 42 additions & 0 deletions utils/numsend.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import asyncio
from pyrogram import Client, filters, enums
from pyrogram.types import Message
from utils.misc import modules_help, prefix

@Client.on_message(filters.command("numsend", prefix) & filters.me)
async def numsend(client: Client, message: Message):
if len(message.command) <= 2:
return

try:
user_id = int(message.command[1])
text = " ".join(message.command[2:])

if message.reply_to_message:
if message.reply_to_message.media:
await client.copy_message(
chat_id=user_id,
from_chat_id=message.chat.id,
message_id=message.reply_to_message.id,
caption=text if text else None
)
else:
await client.send_message(
chat_id=user_id,
text=text if text else message.reply_to_message.text
)
else:
await client.send_message(chat_id=user_id, text=text)

await message.delete()

except ValueError:
await message.edit("Invalid user ID format", parse_mode=enums.ParseMode.HTML)
except Exception as e:
await message.edit(f"Error: <code>{e}</code>", parse_mode=enums.ParseMode.HTML)

modules_help["numsend"] = {
"numsend [user_id] [message]*": "send message to user by numeric ID\n"
"Reply to media to forward it with optional caption\n"
"Original message will be deleted after sending"
}
Loading