refactor: Migrate bot core and modules from talia_bot to bot directory, update start_bot.sh and Dockerfile, and modify README.md.

This commit is contained in:
Marco Gallegos
2025-12-21 18:00:31 -06:00
parent 6e1a2f0102
commit 13141d6ed3
38 changed files with 112 additions and 86 deletions

33
bot/webhook_client.py Normal file
View File

@@ -0,0 +1,33 @@
# app/webhook_client.py
# Este script se encarga de enviar datos a servicios externos usando "webhooks".
# En este caso, se comunica con n8n.
import requests
from bot.config import N8N_WEBHOOK_URL, N8N_TEST_WEBHOOK_URL
def send_webhook(event_data):
"""
Envía datos de un evento al servicio n8n.
Usa el webhook normal y, si falla o no existe, usa el de test como fallback.
"""
# Intentar con el webhook principal
if N8N_WEBHOOK_URL:
try:
print(f"Intentando enviar a webhook principal: {N8N_WEBHOOK_URL}")
response = requests.post(N8N_WEBHOOK_URL, json=event_data)
response.raise_for_status()
return response.json()
except Exception as e:
print(f"Fallo en webhook principal: {e}")
# Fallback al webhook de test
if N8N_TEST_WEBHOOK_URL:
try:
print(f"Intentando enviar a webhook de fallback (test): {N8N_TEST_WEBHOOK_URL}")
response = requests.post(N8N_TEST_WEBHOOK_URL, json=event_data)
response.raise_for_status()
return response.json()
except Exception as e:
print(f"Fallo en webhook de fallback: {e}")
return None