Spaces:
Paused
Paused
Download modules/info.py from saske560/userbotsaske: direct link, hf CLI and curl.
- Browser
- Download file 3.71 kB
-
https://huggingface.co/spaces/saske560/userbotsaske/resolve/main/modules/info.py
- Command line
-
hf download hf://spaces/saske560/userbotsaske/modules/info.py
-
curl -L -o info.py https://huggingface.co/spaces/saske560/userbotsaske/resolve/main/modules/info.py
3.71 kB
| 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") | |