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 = [ "🪪 IDs", "", f"💬 Chat: {chat_id}", f"✉️ Mensaje: {message_id}", ] if ctx.message.from_user: lines.append(f"👤 Tu usuario: {ctx.message.from_user.id}") if ctx.reply and ctx.reply.from_user: lines.append(f"↩️ Respondido a: {ctx.reply.from_user.id}") 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( "👤 Información de usuario\n\n" f"🧾 Nombre: {html.escape(name or 'Sin nombre')}\n" f"🔗 Username: {html.escape(username)}\n" f"🆔 ID: {user.id}\n" f"🤖 Es bot: {'Sí' if user.is_bot else 'No'}\n" f"✅ Verificado: {'Sí' if getattr(user, 'is_verified', False) else 'No'}\n" f"⭐ Premium: {'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( "🙋 Tu perfil\n\n" f"🧾 Nombre: {html.escape(me.first_name or '')} {html.escape(me.last_name or '')}\n" f"🔗 Username: {html.escape(username)}\n" f"🆔 ID: {me.id}\n" f"📱 Mención: abrir perfil" ) 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( "💬 Información del chat\n\n" f"🏷️ Nombre: {html.escape(title)}\n" f"🆔 ID: {chat.id}\n" f"📦 Tipo: {chat_type_label(chat.type)}\n" f"🔗 Username: {html.escape(username)}\n" f"📝 Descripción: {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")