From 2db7f783a1af2c1efc87488c2a059336fda50005 Mon Sep 17 00:00:00 2001 From: Sebastian Nagel Date: Tue, 15 Jun 2021 14:55:58 +0200 Subject: [PATCH] feat(notifications): Fire notification as soon as an appointment was found (#474) * Added title to telegram notification message * Fire notification as soon as an appointment was found --- tools/its.py | 4 ++++ tools/utils.py | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/tools/its.py b/tools/its.py index 7dc2c85e..3b686ec4 100644 --- a/tools/its.py +++ b/tools/its.py @@ -970,11 +970,15 @@ def reservierung_finden_mit_code( tp_angenommen = choice(terminpaare_angenommen) self.log.success(f"Termin gefunden!") self.log.success(f"'{zentrumsname}' in {plz} {ort}") + msg = f"'{zentrumsname}' in {plz} {ort}\n" for num, termin in enumerate(tp_angenommen, 1): ts = datetime.fromtimestamp(termin["begin"] / 1000).strftime( '%d.%m.%Y um %H:%M Uhr') self.log.success(f"{num}. Termin: {ts}") + msg += f"{num}. Termin: {ts}\n" self.log.success(f"Link: {url}impftermine/suche/{code}/{plz}") + msg += f"Link: {url}impftermine/suche/{code}/{plz}" + self.notify(title="Termin gefunden:", msg=msg) # Reservierungs-Objekt besteht aus Terminpaar und Impfzentrum return { diff --git a/tools/utils.py b/tools/utils.py index 1f944722..554d926f 100644 --- a/tools/utils.py +++ b/tools/utils.py @@ -235,7 +235,7 @@ def fire_notifications(notifications: dict, operating_system: str, title: str, m if 'pushover' in notifications: pushover_notification(notifications["pushover"], title, message) if 'telegram' in notifications: - telegram_notification(notifications["telegram"], message) + telegram_notification(notifications["telegram"], title + "\n" + message) def unique(seq):