foxygit / RPA-Remisser Log in
commits tags

/rpa/notify.py · 604 B

raw
def notify_new_items(items: list[dict]) -> None:
    if not items:
        print("Inga nya eller ändrade i databas.")
        return

    title = "databass - uppdatering"
    message = f"{len(items)} ny(a)/ändrad(e) post(er) hittades."
    print(f"{title}: {message}")
    for item in items:
        preview = item["text"].splitlines()[0][:120]
        print(f"  - {preview}")

    try:
        from plyer import notification

        notification.notify(title=title, message=message, timeout=10)
    except Exception as exc:  # noqa: BLE001
        print(f"(Skrivbordsnotis kunde inte visas: {exc})")