auto-renamer / plugins /user /caption.py
dragxd's picture
Feature: Add /myusage, blockquote /help, and user stats tracking. Remove /myplan
1c4b5a6
from pyrogram import Client, filters
from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup, ForceReply
from helper.database import user_stats_update
CMD = ["/"]
@Client.on_message(filters.command("caption", CMD) & filters.private)
async def caption_cmd(client, message):
if not message.reply_to_message:
return await message.reply_text("<b>Reply to a file, video, or audio with /caption <new caption text> to instantly change its caption!</b>")
if len(message.command) < 2:
return await message.reply_text("<b>Please provide the new caption text.</b>\n\nExample: <code>/caption My New Cool Caption</code>")
new_caption = message.text.split(None, 1)[1]
msg = await message.reply_text("πŸš€ <b>Processing...</b>")
try:
await client.copy_message(
chat_id=message.chat.id,
from_chat_id=message.chat.id,
message_id=message.reply_to_message.id,
caption=new_caption
)
await msg.delete()
user_stats_update(message.from_user.id, 0)
except Exception as e:
await msg.edit(f"❌ <b>Error:</b> {e}")
@Client.on_callback_query(filters.regex('^instant_caption$'))
async def instant_caption_cb(client, query):
await query.message.delete()
await query.message.reply_text(
"<b>Please Enter The New Caption...</b>",
reply_to_message_id=query.message.reply_to_message.id,
reply_markup=ForceReply(True)
)
print("Instant Caption Plugin Loaded!")