feat: Add asynchronous support and improved logging/error handling for calendar functions, introduce a calendar debug script, and refactor role-based menu logic.

This commit is contained in:
Marco Gallegos
2025-12-18 09:24:54 -06:00
parent 54f4e9ee41
commit 9a83fb93bb
6 changed files with 87 additions and 28 deletions

View File

@@ -2,6 +2,7 @@
# Este es el archivo principal del bot. Aquí se inicia todo y se configuran los comandos.
import logging
import asyncio
from telegram import Update
from telegram.ext import (
Application,
@@ -87,12 +88,25 @@ async def button_dispatcher(update: Update, context: ContextTypes.DEFAULT_TYPE)
}
if query.data in simple_handlers:
response_text = simple_handlers[query.data]()
handler = simple_handlers[query.data]
logger.info(f"Ejecutando simple_handler para: {query.data}")
if asyncio.iscoroutinefunction(handler):
response_text = await handler()
else:
response_text = handler()
logger.info(f"Respuesta obtenida para {query.data}")
await query.edit_message_text(text=response_text, parse_mode='Markdown')
elif query.data in complex_handlers:
response_text, reply_markup = complex_handlers[query.data]()
handler = complex_handlers[query.data]
logger.info(f"Ejecutando complex_handler para: {query.data}")
if asyncio.iscoroutinefunction(handler):
response_text, reply_markup = await handler()
else:
response_text, reply_markup = handler()
logger.info(f"Respuesta obtenida para {query.data}")
await query.edit_message_text(text=response_text, reply_markup=reply_markup, parse_mode='Markdown')
elif query.data.startswith(('approve:', 'reject:')):
logger.info(f"Ejecutando acción de aprobación: {query.data}")
response_text = handle_approval_action(query.data)
await query.edit_message_text(text=response_text, parse_mode='Markdown')
elif query.data == 'start_create_tag':