chore(kb): notițe youtube mai, fix email tools, update newsletter/anaf-monitor
Adaugă 4 notițe YouTube (llama.cpp, Mario Zechner, bonificatie impozit, AI scaffolding) + notă coaching grok. Actualizează index KB. Fix email_digest și email_forward. Update newsletter cercetasi + cron jobs. ANAF monitor hashes/snapshots/versions la zi. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -186,6 +186,7 @@ def fetch_unread_emails():
|
||||
att_data[fname] = payload
|
||||
|
||||
results.append({
|
||||
'id': eid.decode(),
|
||||
'subject': decode_mime_header(msg['Subject']),
|
||||
'from_full': from_addr,
|
||||
'date': msg['Date'],
|
||||
@@ -198,6 +199,21 @@ def fetch_unread_emails():
|
||||
return results
|
||||
|
||||
|
||||
def mark_as_seen(email_ids: list[str]) -> None:
|
||||
"""Marchează emailurile ca citite pe server IMAP."""
|
||||
if not email_ids:
|
||||
return
|
||||
try:
|
||||
mail = imaplib.IMAP4_SSL(IMAP_SERVER, IMAP_PORT)
|
||||
mail.login(IMAP_USER, IMAP_PASS)
|
||||
mail.select('INBOX')
|
||||
for eid in email_ids:
|
||||
mail.store(eid.encode(), '+FLAGS', '\\Seen')
|
||||
mail.logout()
|
||||
except Exception as e:
|
||||
print(f"[warn] Marcare Seen esuata: {e}", file=sys.stderr)
|
||||
|
||||
|
||||
def run_forward():
|
||||
print("Verific emailuri necitite...")
|
||||
emails = fetch_unread_emails()
|
||||
@@ -223,12 +239,14 @@ def run_forward():
|
||||
if em.get('attachment_data'):
|
||||
print(f"Atașamente: {list(em['attachment_data'].keys())}")
|
||||
else:
|
||||
wa_ok = True
|
||||
for part in parts:
|
||||
ok = send_whatsapp(owner_jid, part)
|
||||
if not ok:
|
||||
print(f"Trimitere esuata: {subject}")
|
||||
wa_ok = False
|
||||
break
|
||||
else:
|
||||
if wa_ok:
|
||||
print(f"Trimis pe WhatsApp ({len(parts)} mesaje): {subject}")
|
||||
|
||||
full_text = "\n".join(parts)
|
||||
@@ -245,6 +263,9 @@ def run_forward():
|
||||
else:
|
||||
print(f"Atașament eșuat: {fname}")
|
||||
|
||||
if wa_ok:
|
||||
mark_as_seen([em['id']])
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
run_forward()
|
||||
|
||||
Reference in New Issue
Block a user