fix: resolve unresponsive bot by migrating to FlowEngine

The Telegram bot was becoming unresponsive due to a conflict between a legacy `ConversationHandler` for the `propose_activity` flow and the main `FlowEngine`. This was likely caused by breaking changes in the `python-telegram-bot` library.

This commit resolves the issue by:
1.  Removing the problematic `ConversationHandler` from `main.py` and its related functions from `modules/equipo.py`.
2.  Migrating the "propose activity" feature to a data-driven JSON flow (`crew_propose_activity.json`), making it compatible with the existing `FlowEngine`.
3.  Pinning the `python-telegram-bot` dependency to `<22` in `requirements.txt` to prevent future breakage from upstream updates.

This change ensures all conversational flows are handled consistently by the `FlowEngine`, restoring bot responsiveness and improving maintainability.
This commit is contained in:
google-labs-jules[bot]
2025-12-21 18:07:45 +00:00
parent 0c2c9fc524
commit 384e23cf58
4 changed files with 30 additions and 98 deletions

View File

@@ -23,13 +23,7 @@ from talia_bot.modules.onboarding import get_admin_secondary_menu
from talia_bot.modules.agenda import get_agenda
from talia_bot.modules.citas import request_appointment
from talia_bot.modules.equipo import (
propose_activity_start,
get_description,
get_duration,
cancel_proposal,
view_requests_status,
DESCRIPTION,
DURATION,
)
from talia_bot.modules.aprobaciones import view_pending, handle_approval_action
from talia_bot.modules.servicios import get_service_info
@@ -50,11 +44,6 @@ logging.basicConfig(
logger = logging.getLogger(__name__)
async def catch_all_handler(update: object, context: ContextTypes.DEFAULT_TYPE):
print("--- CATCH ALL HANDLER ---")
print(update)
async def send_step_message(update: Update, step: dict):
"""Helper to send a message for a flow step, including options if available."""
text = step["question"]
@@ -181,7 +170,6 @@ async def reset_conversation(update: Update, context: ContextTypes.DEFAULT_TYPE)
async def button_dispatcher(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
print("--- BUTTON DISPATCHER CALLED ---")
"""
Esta función maneja los clics en los botones del menú.
Dependiendo de qué botón se presione, ejecuta una acción diferente.
@@ -289,21 +277,6 @@ def main() -> None:
schedule_daily_summary(application)
# Conversation handler for proposing activities
conv_handler = ConversationHandler(
entry_points=[CallbackQueryHandler(propose_activity_start, pattern='^propose_activity$')],
states={
DESCRIPTION: [MessageHandler(filters.TEXT & ~filters.COMMAND, get_description)],
DURATION: [MessageHandler(filters.TEXT & ~filters.COMMAND, get_duration)],
},
fallbacks=[CommandHandler('cancel', cancel_proposal)],
per_message=False
)
application.add_handler(conv_handler)
# El orden de los handlers es crucial para que las conversaciones funcionen.
# application.add_handler(vikunja_conv_handler())
application.add_handler(CommandHandler("start", start))
application.add_handler(CommandHandler("reset", reset_conversation)) # Added reset command
application.add_handler(CommandHandler("print", print_handler))
@@ -315,8 +288,6 @@ def main() -> None:
application.add_handler(CallbackQueryHandler(button_dispatcher))
application.add_handler(TypeHandler(object, catch_all_handler))
logger.info("Iniciando Talía Bot...")
application.run_polling()