import html def setup(registry): async def save_cmd(ctx): if not ctx.args.strip(): await ctx.respond("⚠️ Usa .save nombre texto o responde a un mensaje: .save nombre") return parts = ctx.args.split(maxsplit=1) name = parts[0].lower() content = parts[1] if len(parts) > 1 else "" if not content and ctx.reply: content = ctx.reply.text or ctx.reply.caption or "" if not content: await ctx.respond("⚠️ No hay contenido para guardar.") return ctx.app.state.data.setdefault("notes", {})[name] = content await ctx.app.state.save() await ctx.respond(f"✅ Nota {html.escape(name)} guardada correctamente.") async def note_cmd(ctx): name = ctx.args.strip().lower() if not name: await ctx.respond("⚠️ Usa .note nombre") return notes = ctx.app.state.data.get("notes", {}) if name not in notes: await ctx.respond(f"❌ No existe la nota {html.escape(name)}.") return content = notes[name] await ctx.respond( f"🗒️ Nota: {html.escape(name)}\n\n" f"{html.escape(content[:3500])}" ) async def notes_cmd(ctx): notes = ctx.app.state.data.get("notes", {}) if not notes: await ctx.respond("🗒️ No tienes notas guardadas todavía.") return joined = "\n".join(f"• {html.escape(name)}" for name in sorted(notes)) await ctx.respond(f"🗂️ Notas guardadas\n\n{joined}") async def delnote_cmd(ctx): name = ctx.args.strip().lower() if not name: await ctx.respond("⚠️ Usa .delnote nombre") return notes = ctx.app.state.data.get("notes", {}) if name not in notes: await ctx.respond("❌ Esa nota no existe.") return del notes[name] await ctx.app.state.save() await ctx.respond(f"🗑️ Nota {html.escape(name)} eliminada.") registry.add("save", save_cmd, "Guarda una nota por nombre.", usage=".save compra leche", category="Notas") registry.add("note", note_cmd, "Muestra una nota guardada.", usage=".note compra", category="Notas") registry.add("notes", notes_cmd, "Lista todas las notas.", usage=".notes", category="Notas") registry.add("delnote", delnote_cmd, "Elimina una nota por nombre.", usage=".delnote compra", aliases=["rmnote"], category="Notas")