File size: 2,298 Bytes
1fefee0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import html



def setup(registry):
    async def say_cmd(ctx):
        text = await ctx.require_text("Escribe el texto a enviar con <code>.say mensaje</code>.")
        if not text:
            return
        if ctx.reply:
            await ctx.reply.reply_text(text, disable_web_page_preview=True)
        else:
            await ctx.client.send_message(ctx.message.chat.id, text, disable_web_page_preview=True)
        await ctx.maybe_delete_command()
        try:
            await ctx.message.delete()
        except Exception:
            pass

    async def purge_cmd(ctx):
        amount = 5
        if ctx.args.strip().isdigit():
            amount = max(1, min(100, int(ctx.args.strip())))
        deleted = 0
        ids = []
        async for msg in ctx.client.get_chat_history(ctx.message.chat.id, limit=amount + 25):
            is_self = bool(getattr(msg.from_user, "is_self", False)) or bool(msg.outgoing)
            if is_self:
                ids.append(msg.id)
                deleted += 1
            if deleted >= amount:
                break
        if ctx.message.id not in ids:
            ids.append(ctx.message.id)
        if not ids:
            await ctx.respond("⚠️ No encontré mensajes tuyos para borrar.")
            return
        await ctx.client.delete_messages(ctx.message.chat.id, ids, revoke=True)

    async def pin_cmd(ctx):
        if not ctx.reply:
            await ctx.respond("⚠️ Responde a un mensaje para fijarlo.")
            return
        await ctx.reply.pin(disable_notification=True)
        await ctx.respond("📌 Mensaje fijado correctamente.")

    async def unpin_cmd(ctx):
        if ctx.reply:
            await ctx.reply.unpin()
        else:
            await ctx.client.unpin_all_chat_messages(ctx.message.chat.id)
        await ctx.respond("📍 Hecho.")

    registry.add("say", say_cmd, "Envía un texto limpio y borra el comando.", usage=".say hola", aliases=["echo"], category="Chat")
    registry.add("purge", purge_cmd, "Borra tus últimos mensajes en el chat.", usage=".purge 10", category="Chat")
    registry.add("pin", pin_cmd, "Fija el mensaje respondido.", usage=".pin (reply)", category="Chat")
    registry.add("unpin", unpin_cmd, "Desfija el reply o todos si no respondes.", usage=".unpin", category="Chat")