File size: 1,523 Bytes
274c141
 
1c4b5a6
274c141
dc7e7fa
 
 
274c141
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1c4b5a6
274c141
 
 
dc7e7fa
 
274c141
 
 
 
 
 
dc7e7fa
 
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
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!")