122 lines
6.3 KiB
Python
122 lines
6.3 KiB
Python
import paramiko
|
|
import os
|
|
import urllib.request
|
|
import json
|
|
import ssl
|
|
import sys
|
|
import io
|
|
import time
|
|
|
|
if sys.platform == 'win32':
|
|
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8', errors='replace')
|
|
sys.stderr = io.TextIOWrapper(sys.stderr.buffer, encoding='utf-8', errors='replace')
|
|
|
|
HOST = "161.97.93.156"
|
|
USER = "carlos"
|
|
PASSWORD = "Innova1978+*?"
|
|
REMOTE_BASE = "/home/carlos/apps/dripzone-app"
|
|
LOCAL_APP = r"c:\Users\Carlos\dev\almeira-web\pacifictrans-app"
|
|
LOCAL_APK = os.path.join(LOCAL_APP, "public", "PacifictransGo.apk")
|
|
REMOTE_APK = f"{REMOTE_BASE}/public/PacifictransGo.apk"
|
|
|
|
EVOLUTION_API_URL = "https://evolution.almeira.com.co"
|
|
EVOLUTION_API_KEY = "EE49029EEB85-4568-8F81-C9FDFC6E2943"
|
|
INSTANCE_NAME = "AutomataAlmeira"
|
|
TARGET_PHONE = "573167455877"
|
|
APK_URL = "https://pacifictrans.almeira.com.co/PacifictransGo.apk"
|
|
|
|
ctx = ssl.create_default_context()
|
|
ctx.check_hostname = False
|
|
ctx.verify_mode = ssl.CERT_NONE
|
|
|
|
def main():
|
|
print("[1/4] Verificando archivo APK de Pacifictrans Go...", flush=True)
|
|
if not os.path.exists(LOCAL_APK):
|
|
print(f" [ERROR] El archivo {LOCAL_APK} no existe.", flush=True)
|
|
sys.exit(1)
|
|
|
|
size_mb = os.path.getsize(LOCAL_APK) / (1024 * 1024)
|
|
print(f" -> APK Verificado: {LOCAL_APK} ({size_mb:.2f} MB)", flush=True)
|
|
|
|
print("[2/4] Conectando por SSH al VPS y subiendo PacifictransGo.apk...", flush=True)
|
|
ssh = paramiko.SSHClient()
|
|
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
|
ssh.connect(hostname=HOST, username=USER, password=PASSWORD, timeout=30)
|
|
|
|
sftp = ssh.open_sftp()
|
|
print(f" -> Subiendo APK a {REMOTE_APK}...", flush=True)
|
|
sftp.put(LOCAL_APK, REMOTE_APK)
|
|
sftp.close()
|
|
|
|
stdin, stdout, stderr = ssh.exec_command("docker ps --format '{{.Names}}'")
|
|
containers = [c.strip() for c in stdout.read().decode('utf-8').splitlines() if c.strip()]
|
|
target_containers = [c for c in containers if any(k in c.lower() for k in ['tayk', 'pacific', 'bfmno', 'drip'])]
|
|
|
|
for c in target_containers:
|
|
ssh.exec_command(f"docker cp {REMOTE_APK} {c}:/app/public/PacifictransGo.apk 2>/dev/null || true")
|
|
print(f" -> Sincronizado en contenedor: {c}", flush=True)
|
|
|
|
ssh.close()
|
|
|
|
print("[3/4] Verificando URL pública de PacifictransGo.apk...", flush=True)
|
|
time.sleep(2)
|
|
try:
|
|
req = urllib.request.Request(APK_URL, method='HEAD')
|
|
with urllib.request.urlopen(req, context=ctx, timeout=15) as res:
|
|
live_size_mb = int(res.headers.get('Content-Length', 0)) / (1024 * 1024)
|
|
print(f" [OK] APK online en {APK_URL} (HTTP {res.status}, {live_size_mb:.2f} MB)", flush=True)
|
|
except Exception as e:
|
|
print(f" [Aviso]: Verificación HEAD: {e}", flush=True)
|
|
|
|
print("[4/4] Enviando notificación de Pacifictrans Go a WhatsApp (+57 316 745 5877)...", flush=True)
|
|
|
|
text_msg = (
|
|
"🚗 *Pacifictrans Go: Seguridad de Rutas, Dashboard Admin Exclusivo & Grupos de WhatsApp Separados*\n\n"
|
|
"¡Hola Carlos! Se ha desplegado una nueva versión con la reestructuración completa de seguridad y canales de WhatsApp:\n\n"
|
|
"📱 *App Oficial:* `Pacifictrans Go`\n"
|
|
"📦 *Archivo APK:* `PacifictransGo.apk` (37.07 MB)\n"
|
|
"🆔 *Package ID:* `co.pacifictrans.go`\n\n"
|
|
"⚡ *Novedades y Mejoras Implementadas:*\n"
|
|
"• 🛡️ *Seguridad de Rutas por Permisos de Rol:* Protección de vistas y endpoints API (`ADMIN`, `CONDUCTOR`, `PASAJERO`). Si un usuario no autorizado o visitante intenta ingresar a la consola de administración (`/#admin`) o conductor (`/#conductor`), el sistema activa un Escudo de Seguridad interactivo con acceso restringido.\n"
|
|
"• 🖥️ *Dashboard Exclusivo para Administradores:* La página principal quedó 100% limpia para clientes (sólo reserva de cupo, calculadora de fletes, muro de reseñas y descarga de app). La administración ahora opera en su propia Central de Mando Ejecutiva con Radar GPS en vivo, Telemetría, Control Bre-B y Tarifas.\n"
|
|
"• 👥 *Separación de Grupos de WhatsApp por App:* Las notificaciones operativas de Pacific Trans GO se envían automáticamente al grupo *'Pacific Trans Notificaciones'* y las de Dripzone al grupo *'Dripzone Notificaciones'*. En caso de que no exista el grupo o el bot no esté agregado, hace fallback inmediato a tu número personal (+57 316 745 5877).\n"
|
|
"• 🔍 *Auto-Detección de Grupos Evolution:* Botón en el panel administrativo que consulta Evolution API en vivo (`/api/admin/whatsapp/groups`) y resuelve los JIDs oficiales `@g.us`.\n"
|
|
"• 💰 *Bandeja de Transferencias Bre-B:* Control de solicitudes de pago con ciclo de compensación inmediata 24/7 y generación de recibos digitales.\n\n"
|
|
f"🔗 *Enlace de Descarga Directa:*\n👉 {APK_URL}"
|
|
)
|
|
|
|
req_text = urllib.request.Request(
|
|
f"{EVOLUTION_API_URL}/message/sendText/{INSTANCE_NAME}",
|
|
data=json.dumps({"number": TARGET_PHONE, "text": text_msg, "delay": 300}).encode("utf-8"),
|
|
headers={"apikey": EVOLUTION_API_KEY, "Content-Type": "application/json"}
|
|
)
|
|
try:
|
|
with urllib.request.urlopen(req_text, context=ctx, timeout=40) as resp:
|
|
print(" [OK] Mensaje de texto enviado a WhatsApp (Status:", resp.status, ")", flush=True)
|
|
except Exception as e:
|
|
print(" [Aviso texto WhatsApp]:", e, flush=True)
|
|
|
|
# Envío del archivo binario APK como documento adjunto
|
|
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": "PacifictransGo.apk",
|
|
"caption": "📦 *PacifictransGo.apk* - App Oficial Pacifictrans Go",
|
|
"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=120) as resp:
|
|
print(" [OK] Documento APK enviado a WhatsApp (Status:", resp.status, ")", flush=True)
|
|
except Exception as e:
|
|
print(" [Aviso documento WhatsApp]:", e, flush=True)
|
|
|
|
print("\n✅ [PROCESO PACIFICTRANS GO COMPLETADO CON ÉXITO]", flush=True)
|
|
|
|
if __name__ == "__main__":
|
|
main()
|