feat: add whatsapp_modular_v3_6 - envio automatizado WhatsApp Web con busqueda por nombre, deteccion de ticks via msg-meta/SVG title, y validacion de selectores

This commit is contained in:
2026-06-25 14:25:59 -05:00
parent 3d42e4b84b
commit c1bcd57c4d
15 changed files with 1627 additions and 0 deletions

View File

@@ -0,0 +1,46 @@
import os
import shutil
from datetime import datetime, timedelta
from pathlib import Path
from .config import CLEAN_OLD_SESSIONS_DAYS, ESTADO_FILE, LOG_FILE
def log_text(line):
ts = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
with open(LOG_FILE, "a", encoding="utf-8") as file:
file.write(f"{ts} | {line}\n")
def asegurar_directorio(path):
os.makedirs(path, exist_ok=True)
def save_session_state(active):
try:
with open(ESTADO_FILE, "w", encoding="utf-8") as file:
file.write("SESION_ACTIVA" if active else "SESION_INACTIVA")
except Exception as exc:
print(f"No se pudo guardar estado de sesion: {exc}")
def cleanup_old_chrome_data(dirpath="./perfil_whatsapp", days=CLEAN_OLD_SESSIONS_DAYS):
if days <= 0:
return
try:
base = Path(dirpath)
if not base.exists():
return
cutoff = datetime.now() - timedelta(days=days)
for child in base.iterdir():
try:
mtime = datetime.fromtimestamp(child.stat().st_mtime)
if mtime < cutoff and child.is_dir():
shutil.rmtree(child)
print(f"Eliminada sesion antigua: {child}")
except Exception:
continue
except Exception as exc:
print(f"Error limpiando sesiones antiguas: {exc}")