From 863e59b17ea134a373446031745cc55c2b9a17f0 Mon Sep 17 00:00:00 2001 From: ynerant Date: Tue, 11 May 2021 14:34:06 +0200 Subject: [PATCH] =?UTF-8?q?R=C3=A9activation=20des=20alertes=20si=20le=20c?= =?UTF-8?q?entre=20est=20=C3=A0=20nouveau=20disponible?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: ynerant --- chronodose.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/chronodose.py b/chronodose.py index 50144da..7588fe3 100755 --- a/chronodose.py +++ b/chronodose.py @@ -149,6 +149,8 @@ def main(): irc_client.privmsg(config.irc.channel, ' '.join(str(a) for a in mesg)) while True: + centres_id = [] # Centres disponibles + for search in config.search: places = [] for dpt in search.departements: @@ -160,10 +162,12 @@ def main(): print(sum(place[1] for place in places), "doses disponibles autour de", search.position.city) for centre, count in places: - if (centre.internal_id, date.today()) in already_indicated: + centres_id.append(centre.internal_id) + + if centre.internal_id in already_indicated: # Message déjà envoyé, on spam pas continue - already_indicated.append((centre.internal_id, date.today())) + already_indicated.append(centre.internal_id) msg(count, "doses dans le centre de", centre.nom) msg("Type de vaccin :", ", ".join(centre.vaccine_type)) @@ -172,6 +176,11 @@ def main(): msg(*search.mentions) msg(" ") + # Pour chaque centre indisponible, on réactive les alertes + for centre_id in already_indicated.copy(): + if all(cid != centre_id for cid in centres_id): + already_indicated.remove(centre_id) + # 5 minutes sleep(300)