Spaces:
Paused
Paused
File size: 3,709 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 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 | import html
async def resolve_target(ctx):
if ctx.reply and ctx.reply.from_user:
return ctx.reply.from_user
if ctx.args:
try:
return await ctx.client.get_users(ctx.args.strip())
except Exception:
return None
return ctx.message.from_user
def chat_type_label(chat_type) -> str:
mapping = {
"private": "Privado",
"group": "Grupo",
"supergroup": "Supergrupo",
"channel": "Canal",
"bot": "Bot",
}
return mapping.get(str(chat_type), str(chat_type))
def setup(registry):
async def id_cmd(ctx):
chat_id = ctx.message.chat.id
message_id = ctx.message.id
lines = [
"🪪 <b>IDs</b>",
"",
f"💬 <b>Chat:</b> <code>{chat_id}</code>",
f"✉️ <b>Mensaje:</b> <code>{message_id}</code>",
]
if ctx.message.from_user:
lines.append(f"👤 <b>Tu usuario:</b> <code>{ctx.message.from_user.id}</code>")
if ctx.reply and ctx.reply.from_user:
lines.append(f"↩️ <b>Respondido a:</b> <code>{ctx.reply.from_user.id}</code>")
await ctx.respond("\n".join(lines))
async def info_cmd(ctx):
user = await resolve_target(ctx)
if not user:
await ctx.respond("⚠️ No pude encontrar ese usuario.")
return
username = f"@{user.username}" if user.username else "Sin username"
name = " ".join(filter(None, [user.first_name, user.last_name]))
await ctx.respond(
"👤 <b>Información de usuario</b>\n\n"
f"🧾 <b>Nombre:</b> {html.escape(name or 'Sin nombre')}\n"
f"🔗 <b>Username:</b> {html.escape(username)}\n"
f"🆔 <b>ID:</b> <code>{user.id}</code>\n"
f"🤖 <b>Es bot:</b> {'Sí' if user.is_bot else 'No'}\n"
f"✅ <b>Verificado:</b> {'Sí' if getattr(user, 'is_verified', False) else 'No'}\n"
f"⭐ <b>Premium:</b> {'Sí' if getattr(user, 'is_premium', False) else 'No'}"
)
async def me_cmd(ctx):
me = ctx.app.owner_user or await ctx.client.get_me()
username = f"@{me.username}" if me.username else "Sin username"
await ctx.respond(
"🙋 <b>Tu perfil</b>\n\n"
f"🧾 <b>Nombre:</b> {html.escape(me.first_name or '')} {html.escape(me.last_name or '')}\n"
f"🔗 <b>Username:</b> {html.escape(username)}\n"
f"🆔 <b>ID:</b> <code>{me.id}</code>\n"
f"📱 <b>Mención:</b> <a href='tg://user?id={me.id}'>abrir perfil</a>"
)
async def chatinfo_cmd(ctx):
chat = ctx.message.chat
title = chat.title or chat.first_name or "Chat"
username = f"@{chat.username}" if getattr(chat, "username", None) else "Sin username"
await ctx.respond(
"💬 <b>Información del chat</b>\n\n"
f"🏷️ <b>Nombre:</b> {html.escape(title)}\n"
f"🆔 <b>ID:</b> <code>{chat.id}</code>\n"
f"📦 <b>Tipo:</b> {chat_type_label(chat.type)}\n"
f"🔗 <b>Username:</b> {html.escape(username)}\n"
f"📝 <b>Descripción:</b> {html.escape((chat.description or 'Sin descripción')[:600])}"
)
registry.add("id", id_cmd, "Muestra IDs del chat, mensaje y reply.", usage=".id", category="Info")
registry.add("info", info_cmd, "Muestra datos de un usuario o del reply.", usage=".info @usuario", category="Info")
registry.add("me", me_cmd, "Muestra datos de tu cuenta.", usage=".me", category="Info")
registry.add("chatinfo", chatinfo_cmd, "Muestra datos del chat actual.", usage=".chatinfo", aliases=["chat"], category="Info")
|