122 lines
5.7 KiB
Python
122 lines
5.7 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://drip-zone.online/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()]
|
|
drip_containers = [c for c in containers if 'drip' in c.lower() or 'bfmno' in c.lower()]
|
|
|
|
for c in drip_containers:
|
|
ssh.exec_command(f"docker cp {REMOTE_APK} {c}:/app/public/PacifictransGo.apk 2>/dev/null || true")
|
|
print(f" -> Sincronizado en contenedor público: {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: Actualización Oficial de Plataforma & APK*\n\n"
|
|
"¡Hola Carlos! Se ha desplegado una nueva versión con el sistema completo de control financiero, liquidación y Bre-B:\n\n"
|
|
"📱 *App Oficial:* `Pacifictrans Go`\n"
|
|
"📦 *Archivo APK:* `PacifictransGo.apk` (37.07 MB)\n"
|
|
"🆔 *Package ID:* `co.pacifictrans.go`\n\n"
|
|
"⚡ *Novedades y Módulos Operativos Integrados:*\n"
|
|
"• 💳 *Control de Pagos en Viaje Planificado:* Identificación clara por pasajero de quién ya pagó en línea (Bold, Nequi, Bre-B) y quién está pendiente de pago en efectivo al abordar con toggle interactivo.\n"
|
|
"• ⚖️ *Liquidación Automática al Finalizar Recorrido:* Split de comisiones (15% Pacifictrans Go vs 85% Conductor) y abono automático del saldo neto a la billetera digital del conductor.\n"
|
|
"• ⚡ *Transferencias Inmediatas Bre-B (Banco de la República):* Despacho 24/7 a cualquier entidad bancaria (Bancolombia, Nequi, Davivienda, Dale, Nu) con Llaves Bre-B (celular, cédula o correo) y costo $0 COP.\n"
|
|
"• 🧾 *Comprobante Digital Oficial Bre-B:* Emisión de recibo con código de autorización BanRep y opción de compartir por WhatsApp.\n"
|
|
"• 🔒 *Seguridad 2FA & OTP:* Verificación por WhatsApp y correo electrónico estilo Dripzone.\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()
|