Add user notification with ntfy
This commit is contained in:
parent
0e083bb23b
commit
11233e544f
2 changed files with 10 additions and 2 deletions
|
|
@ -1,2 +0,0 @@
|
|||
couchette6,99.9,Compartment for 6 passengers
|
||||
couchette6,99.9,Compartment for 6 passengers
|
||||
|
10
main.py
10
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():
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue