Add user notification with ntfy

This commit is contained in:
Marty Oehme 2025-08-11 22:56:02 +02:00
parent 0e083bb23b
commit 11233e544f
Signed by: Marty
GPG key ID: 4E535BC19C61886E
2 changed files with 10 additions and 2 deletions

View file

@ -1,2 +0,0 @@
couchette6,99.9,Compartment for 6 passengers
couchette6,99.9,Compartment for 6 passengers
1 couchette6 99.9 Compartment for 6 passengers
2 couchette6 99.9 Compartment for 6 passengers

10
main.py
View file

@ -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():