feat: Implement NFC tag creation wizard via FlowEngine

This commit implements the NFC tag creation wizard as a data-driven JSON flow, completing a key item from the roadmap.

-   **Refactor to FlowEngine:** The previous implementation, which used a `ConversationHandler`, has been completely replaced. The wizard is now defined in `talia_bot/data/flows/admin_create_nfc_tag.json` and is managed by the central `FlowEngine`.
-   **New Module:** The logic for generating the Base64 tag is encapsulated in a new, dedicated module: `talia_bot/modules/nfc_tag.py`.
-   **Improved UX:** The "Sucursal" (branch) selection step now uses buttons, as originally specified in the documentation, improving the user experience.
-   **Code Cleanup:** The obsolete `talia_bot/modules/create_tag.py` module and its corresponding `ConversationHandler` have been removed from `main.py`, making the codebase more consistent and maintainable.
-   **Documentation:** The `README.md` has been updated to mark the feature as complete and to include a description of the new wizard.
This commit is contained in:
google-labs-jules[bot]
2025-12-21 10:13:28 +00:00
parent 5274ac3b0c
commit 7b633ef2e8
6 changed files with 54 additions and 136 deletions

View File

@@ -35,7 +35,6 @@ from talia_bot.modules.servicios import get_service_info
from talia_bot.modules.admin import get_system_status
import os
from talia_bot.modules.debug import print_handler
from talia_bot.modules.create_tag import create_tag_conv_handler
from talia_bot.modules.vikunja import vikunja_conv_handler
from talia_bot.modules.printer import send_file_to_printer, check_print_status
from talia_bot.db import setup_database
@@ -90,6 +89,8 @@ async def text_and_voice_handler(update: Update, context: ContextTypes.DEFAULT_T
elif result["status"] == "complete":
if "sales_pitch" in result:
await update.message.reply_text(result["sales_pitch"])
elif "nfc_tag" in result:
await update.message.reply_text(result["nfc_tag"], parse_mode='Markdown')
else:
await update.message.reply_text("Gracias por completar el flujo.")
elif result["status"] == "error":
@@ -167,8 +168,6 @@ async def button_dispatcher(update: Update, context: ContextTypes.DEFAULT_TYPE)
elif query.data.startswith(('approve:', 'reject:')):
logger.info(f"Ejecutando acción de aprobación: {query.data}")
response_text = handle_approval_action(query.data)
elif query.data == 'start_create_tag':
response_text = "Para crear un tag, por favor usa el comando /create_tag."
else:
logger.warning(f"Consulta no manejada por el despachador: {query.data}")
await query.edit_message_text(text=response_text)
@@ -207,7 +206,6 @@ def main() -> None:
schedule_daily_summary(application)
# El orden de los handlers es crucial para que las conversaciones funcionen.
application.add_handler(create_tag_conv_handler())
application.add_handler(vikunja_conv_handler())
conv_handler = ConversationHandler(