almeira-web/scripts/send_official_whatsapp.py

70 lines
3.3 KiB
Python

import urllib.request
import json
import ssl
import sys
if sys.platform == 'win32':
sys.stdout.reconfigure(encoding='utf-8', errors='replace')
sys.stderr.reconfigure(encoding='utf-8', errors='replace')
EVOLUTION_API_URL = "https://evolution.almeira.com.co"
EVOLUTION_API_KEY = "83B5BD230796-4324-AE73-3508F69E279D"
INSTANCE_NAME = "DripZone"
TARGET_PHONE = "573167455877"
APK_URL = "https://drip-zone.online/DripZone.apk"
ctx = ssl.create_default_context()
ctx.check_hostname = False
ctx.verify_mode = ssl.CERT_NONE
message_text = (
"🚀 *DripZone v1.6 - Dominio drip-zone.online & Correo Oficial info@drip-zone.online Configurados*\n\n"
"Hola Carlos, se ha completado el despliegue de las nuevas configuraciones en producción:\n\n"
"🌐 *1. Dominio Oficial & Correo Electrónico:*\n"
"• URL Principal: *https://drip-zone.online*\n"
"• Correo Oficial: *info@drip-zone.online*\n"
"• Servidor Traefik y Coolify enlazados con SSL Let's Encrypt activo.\n\n"
"📱 *2. Línea Celular Exclusiva DripZone (+57 310 639 0296):*\n"
"• Instancia Evolution API *DripZone* activa (`83B5BD230796-4324-AE73-3508F69E279D`).\n"
"• Códigos OTP, confirmaciones de compras, soporte y pasarela Bold se emiten desde esta línea oficial.\n\n"
"📥 *3. Publicaciones y Catálogo (Tu WhatsApp Personal):*\n"
"• La instancia *AutomataAlmeira* continúa recibiendo los mensajes de los grupos de proveedores mayoristas para sincronización inteligente de calzado.\n\n"
"💳 *4. Pasarela Bold & QR Bre-B en Producción:*\n"
"• Cobro de anticipo de $10.000 COP con generación automática de QR Bre-B y acreditación en vivo.\n\n"
"📲 *5. App Nativa Android v1.6 Sincronizada:*\n"
"• Compilada con el nuevo dominio y la línea oficial de atención.\n\n"
f"🔗 *Descarga Directa del APK:* {APK_URL}\n\n"
"Te adjunto el APK compilado para que puedas actualizar la aplicación en tu celular."
)
print("[1/2] Enviando mensaje de texto oficial a Carlos...")
req_text = urllib.request.Request(
f"{EVOLUTION_API_URL}/message/sendText/{INSTANCE_NAME}",
data=json.dumps({"number": TARGET_PHONE, "text": message_text, "delay": 500}).encode("utf-8"),
headers={"apikey": EVOLUTION_API_KEY, "Content-Type": "application/json"}
)
try:
with urllib.request.urlopen(req_text, context=ctx, timeout=30) as resp:
print(" [OK] Mensaje de texto enviado a WhatsApp (Status:", resp.status, ")")
except Exception as e:
print(" [Error texto WhatsApp]:", e)
print("[2/2] Enviando archivo APK compilado a WhatsApp...")
req_media = urllib.request.Request(
f"{EVOLUTION_API_URL}/message/sendMedia/{INSTANCE_NAME}",
data=json.dumps({
"number": TARGET_PHONE,
"mediatype": "document",
"mimetype": "application/vnd.android.package-archive",
"fileName": "DripZone-v1.6-Official.apk",
"caption": "📲 *DripZone Native v1.6 - Dominio drip-zone.online & Correo info@drip-zone.online*",
"media": APK_URL
}).encode("utf-8"),
headers={"apikey": EVOLUTION_API_KEY, "Content-Type": "application/json"}
)
try:
with urllib.request.urlopen(req_media, context=ctx, timeout=180) as resp:
print(" [OK] Documento APK enviado a WhatsApp (Status:", resp.status, ")")
except Exception as e:
print(" [Error envío documento APK]:", e)