mirror of
https://github.com/marcogll/talia_bot.git
synced 2026-01-13 21:35:19 +00:00
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:
18
app/main.py
18
app/main.py
@@ -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':
|
||||
|
||||
Reference in New Issue
Block a user