From 11233e544f8f10b060a21c3a2a543dc6a07af7a1 Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Mon, 11 Aug 2025 22:56:02 +0200 Subject: [PATCH] Add user notification with ntfy --- lowest.csv | 2 -- main.py | 10 ++++++++++ 2 files changed, 10 insertions(+), 2 deletions(-) delete mode 100644 lowest.csv diff --git a/lowest.csv b/lowest.csv deleted file mode 100644 index 8c3005a..0000000 --- a/lowest.csv +++ /dev/null @@ -1,2 +0,0 @@ -couchette6,99.9,Compartment for 6 passengers -couchette6,99.9,Compartment for 6 passengers diff --git a/main.py b/main.py index 2dbc00b..3aa3fbf 100644 --- a/main.py +++ b/main.py @@ -207,6 +207,16 @@ def get_last_price_from_csv() -> Price | None: return Price(last[0], last[2], float(last[1])) +def notify_user(previous: Price, new: Price, channel: str) -> None: + requests.post( + f"https://ntfy.sh/{channel}", + data=f"from {previous.price} -> {new.price} ({new.name})", + headers={ + "Title": f"Nightjet train price went {'down' if new.price < previous.price else 'up'}", + "Priority": "urgent" if new.price < previous.price else "default", + "Tags": "green_circle" if new.price < previous.price else "orange_circle", + }, + ) def main():