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

@@ -117,6 +117,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, filename: str, data: bytes) -> bool:
try:
mimetype = mimetypes.guess_type(filename)[0] or "application/octet-stream"
@@ -212,6 +231,13 @@ def run_forward():
else:
print(f"Trimis pe WhatsApp ({len(parts)} mesaje): {subject}")
full_text = "\n".join(parts)
ok_dc = send_discord_webhook(full_text)
if ok_dc:
print(f"Trimis pe Discord: {subject}")
else:
print(f"Discord eșuat: {subject}")
for fname, fdata in em.get('attachment_data', {}).items():
ok_att = send_whatsapp_document(owner_jid, fname, fdata)
if ok_att: