import requests from datetime import datetime, timedelta from App.Config.GeneralConfig import ConfigNotifications def send_whatsapp(message): url = ConfigNotifications.webhookURL_wps_notifcation # URL del webhook de WhatsApp en WPS payload = { "message": message } requests.post(url, json=payload) def build_message(project_name, summary, duration): status = "FINALIZADO" if not summary["failed"] else "FINALIZADO CON ERRORES ❌" msg = f"""PROYECTO: {project_name} Fecha: {datetime.now().strftime('%Y-%m-%d')} Estado: {status} Resumen: - Reportes procesados: {summary['total']} - Exitosos: {summary['success']} - Con errores: {len(summary['failed'])} """ if summary["failed"]: msg += "❌ Errores críticos:\n" for e in summary["failed"]: msg += f"- {e}\n" if summary["errors"]: msg += "\n🟠 Errores no bloqueantes:\n" for e in summary["errors"]: msg += f"- {e}\n" if summary["warnings"]: msg += "\n⚠️ Advertencias:\n" for w in summary["warnings"]: msg += f"- {w}\n" msg += f"\n🕐 Duración: {str(duration).split('.')[0]}" return msg