chore: auto-commit from dashboard

This commit is contained in:
2026-04-22 11:05:14 +00:00
parent 51af0918a4
commit bfc2283e6f
7 changed files with 103 additions and 46 deletions

View File

@@ -88,6 +88,25 @@ def send_whatsapp(to: str, text: str) -> bool:
return False
def send_discord_webhook(text: str) -> bool:
"""Trimite mesaj pe Discord via webhook (max 2000 chars per mesaj)."""
config = Config(PROJECT_ROOT / "config.json")
url = config.get("discord.email_webhook_url", "")
if not url:
return False
try:
chunks = [text[i:i+2000] for i in range(0, len(text), 2000)]
for chunk in chunks:
resp = requests.post(url, json={"content": chunk}, timeout=15)
if resp.status_code not in (200, 204):
print(f"[discord webhook] status {resp.status_code}", file=sys.stderr)
return False
return True
except Exception as e:
print(f"[discord webhook eroare] {e}", file=sys.stderr)
return False
def send_whatsapp_document(to: str, filepath: str) -> bool:
"""Trimite un fișier ca document WhatsApp prin bridge."""
try:
@@ -145,6 +164,12 @@ def run_digest():
else:
print(f"❌ Trimitere eșuată: {subject}")
ok_dc = send_discord_webhook(summary)
if ok_dc:
print(f"✅ Trimis pe Discord: {subject}")
else:
print(f"❌ Discord eșuat: {subject}")
for att_path in attachment_paths:
ok_att = send_whatsapp_document(owner_jid, att_path)
name = Path(att_path).name