Skip to main content

maxenger

Librería de Python para hacer bots de Maxenger.

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:
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

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

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

@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.

Metadata

Release files for maxenger 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for maxenger 0.2.0
File Size Uploaded Provenance Actions
maxenger-0.2.0.tar.gz 20.6 kB Without provenance Details for maxenger-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for maxenger 0.2.0
File Interpreter ABI Platform Actions
maxenger-0.2.0-py3-none-any.whl Python 3 none any Details for maxenger-0.2.0-py3-none-any.whl

Total release size: 40.8 kB

Release files / maxenger-0.2.0.tar.gz

Download URL maxenger-0.2.0.tar.gz
Size 20.6 kB
Tags Source
SHA-256 checksum
How to use checksums
24a5c4d478b3524a4defc6b3a3ee19fe0ace9756e758e1c937588a47ece468c7
BLAKE2b-256 checksum
How to use checksums
ad478c054db86f9e026e1e13f09ca2d5ffa7a541ffb74f7a5e5a4199c5f31888
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.10

Release files / maxenger-0.2.0-py3-none-any.whl

Download URL maxenger-0.2.0-py3-none-any.whl
Size 20.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0750143341e3a2324730774979c50cd0c738e3b02c4217d4f0c48775a844ecd7
BLAKE2b-256 checksum
How to use checksums
3960be5d6098906f92e74f34ff5910d989ecd8e6655408959ef114ede81ee85d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.10

Security for maxenger 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page