Async to Synck changes in voice handler
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Ekaropolus 2025-07-07 03:13:30 -06:00
parent 30c6af7f8e
commit 96cb030e19

View File

@ -96,9 +96,10 @@ async def dispatch_private_commands(update, text):
async def transcribe_with_whisper(update, bot):
# 1. Descarga el archivo de voz desde Telegram
tg_file = await sync_to_async(bot.get_file)(update.message.voice.file_id)
tg_file = await bot.get_file(update.message.voice.file_id)
download_path = f"/tmp/{update.message.voice.file_id}.ogg"
await sync_to_async(tg_file.download)(download_path)
# En python-telegram-bot v21: download_to_drive es coroutine
await tg_file.download_to_drive(download_path)
# 2. Envía el audio a la API Whisper de OpenAI
with open(download_path, "rb") as audio:
@ -120,7 +121,7 @@ async def telegram_webhook(request, bot_name):
try:
logger.info(f"Webhook called for bot: {bot_name}")
# Carga la configuración del bot
# Carga la configuración del bot (sync ORM)
try:
bot_instance = await sync_to_async(TelegramBot.objects.get)(
name=bot_name, is_active=True