Metadata-Version: 2.4
Name: maxenger
Version: 0.2.0
Summary: Librería para hacer bots de Maxenger
Author: Maxexiyo
License-Expression: MIT
Project-URL: Homepage, https://maxenger.dpdns.org
Keywords: maxenger,bot,chat,async
Classifier: Programming Language :: Python :: 3
Classifier: Framework :: AsyncIO
Classifier: Operating System :: OS Independent
Classifier: Intended Audience :: Developers
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: python-socketio[asyncio_client]>=5.10
Requires-Dist: aiohttp>=3.9
Dynamic: license-file

# maxenger

Librería de Python para hacer bots de Maxenger.

```bash
pip install -e .          # desde esta carpeta (después: pip install maxenger)
```

## Tu primer bot

1. En Maxenger crea un bot (panel de bots) y copia su token (`mxb_...`). Solo se muestra una vez.
2. Invítalo a tu fiesta con el enlace de invitación del bot.
3. Escribe esto y córrelo:

```python
from maxenger import Embed, commands

bot = commands.Bot("mxb_TU_TOKEN", "https://maxenger.dpdns.org")

@bot.command(description="Suma dos números")
async def suma(ctx, a: int, b: int = 0):
    await ctx.reply(f"{a} + {b} = {a + b}")

@bot.command(description="Repite lo que escribas")
async def eco(ctx, *, texto):
    await ctx.send(embed=Embed(title="Eco", description=texto, color=0x5865F2))

@bot.event
async def on_ready():
    print("Bot conectado. Prefijo:", bot.prefix)

bot.run()
```

En el chat se usa con el prefijo de tu bot: `!tubot suma 2 3`. Los comandos también salen en el autocompletado.

## Piezas

| Pieza | Para qué |
|---|---|
| `commands.Bot(token, url)` | El bot: conexión, comandos y eventos |
| `@bot.command(name=, description=, aliases=)` | Registra un comando; los argumentos se convierten por su tipo (`int`, `float`, `bool`, `str`) |
| `*, texto` | Un argumento "keyword-only" recibe el resto del texto |
| `commands.Cog` | Agrupa comandos y eventos en una clase (`await bot.add_cog(MiCog())`) |
| `@bot.event` / `@Cog.listener()` | Eventos: `on_ready`, `on_message`, `on_disconnect`, `on_command_error`, `on_command_not_found` |
| `ctx.send / ctx.reply / ctx.typing()` | Responder en el canal |
| `Embed` | Tarjetas con título, campos, imagen, pie, color |
| `ui.View`, `@ui.button`, `@ui.select` | Botones y menús (`await ctx.send(view=MiVista())`) |
| `interaction.respond(...)` | Respuesta privada que solo ve quien hizo clic |
| `ui.Modal` + `ui.TextInput` | Formularios (`await interaction.send_modal(modal)`) |
| `message.edit / delete / react / fetch_reactors` | Acciones sobre mensajes |
| `canal.history(limit)` / `canal.fetch_message(id)` | Leer mensajes anteriores |
| `File(ruta_o_bytes, spoiler=)` | Mandar archivos: `ctx.send("mira", file=File("foto.png"))` (hasta 10) |
| `await bot.get_party(id)` | Miembros, roles, canales y permisos de la fiesta |
| `fiesta.kick / ban / unban / set_roles / set_nickname / create_channel` | Moderación (con los permisos del rol del bot) |
| `Permissions`, `miembro.permissions` | Permisos de cada persona |
| `await bot.set_activity("algo")` | «Jugando a …» en el perfil del bot |
| `await bot.wait_for("message", check=..., timeout=)` | Esperar una respuesta |
| `tasks.loop(seconds=)` | Tareas que se repiten |

### Botones

```python
from maxenger import ui

class Confirmar(ui.View):
    @ui.button(label="Sí", style="success")
    async def si(self, interaction, boton):
        await interaction.respond("¡Hecho!")

    @ui.button(label="No", style="danger")
    async def no(self, interaction, boton):
        await interaction.edit_message(content="Cancelado", view=ui.View())

@bot.command()
async def borrar(ctx):
    await ctx.send("¿Seguro?", view=Confirmar())
```

### Cog

```python
class Utiles(commands.Cog):
    @commands.command(description="Responde pong")
    async def ping(self, ctx):
        await ctx.reply("pong")

    @commands.Cog.listener()
    async def on_message(self, mensaje):
        ...

# dentro de una función async, o con asyncio.run:
await bot.add_cog(Utiles())
```

## Verificaciones, cooldowns, grupos y ayuda

```python
@bot.command()
@commands.has_permissions(kick_members=True)      # quien lo use necesita ese permiso
@commands.bot_has_permissions(kick_members=True)  # y el bot también
@commands.cooldown(1, 30)                         # 1 uso cada 30 s por persona (type="channel" o "party" también)
async def echar(ctx, quien: commands.Member, *, motivo="sin motivo"):
    await ctx.party.kick(quien)

@bot.group()
async def config(ctx): ...

@config.command()
async def ver(ctx, clave): ...                    # !tubot config ver clave
```

- Argumentos con tipo `commands.Member`, `commands.User` o `commands.Role` aceptan menciones o ids.
- Otras verificaciones: `@commands.check(funcion)`, `@commands.is_party_owner()` y `@bot.check` (global).
- Hay un comando `ayuda` automático (apágalo con `Bot(..., help_command=False)`).
- Errores: define `on_command_error(ctx, error)` o deja los mensajes por defecto.

## Eventos

`on_ready`, `on_message`, `on_message_edit(mensaje)`, `on_message_delete(canal, id)`, `on_reaction_add(reaccion, usuario)`, `on_reaction_remove`, `on_member_join(fiesta, usuario)`, `on_member_remove(fiesta, usuario, motivo)` (motivo: `leave`, `kick` o `ban`), `on_command`, `on_command_completion`, `on_command_error`, `on_command_not_found`, `on_disconnect`.

## ¿Prefieres no mantener una conexión abierta?

Mira `API.md`: también hay API REST y webhooks.

## Límites

- Los bots solo ven mensajes de los canales de las fiestas donde están (nunca chats directos) y no ven mensajes de otros bots.
- Esta versión no incluye llamadas de voz ni mensajes directos de bots.
