From fec885d85b7faf411f24b53fad7a9dd27feffb63 Mon Sep 17 00:00:00 2001 From: Lyreplus Date: Wed, 20 Nov 2024 13:07:27 +0100 Subject: [PATCH] fix: fixed handling of api output --- bot.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/bot.py b/bot.py index 315c1ed..2da014f 100644 --- a/bot.py +++ b/bot.py @@ -195,15 +195,18 @@ async def ore(update: Update, context: ContextTypes.DEFAULT_TYPE): if response.status_code == 200: data = response.json() ore = round(float(data.get("ore")), 2) - inlab = round(float(data.get("inlab")), 2) + inlab = data.get("inlab") answer_text = "" if ore is None: await update.message.reply_text("Errore, contatta lo staff IT.\n Codice errore: in ore function: ore is None") return - if inlab is None: + if inlab == "false": answer_text = "Ciao! Non sei in lab 😿 \n" - else: + else if inlab == "true": answer_text = "Ciao! Sei in lab 🐱\n" + else if inlab is None: + await update.message.reply_text("Errore, contatta lo staff IT.\n Codice errore: in ore function: inlab is None") + return reply_ore = answer_text + f"Mi risulta che finora tu abbia trascorso {ore} ore nel laboratorio di E-Agle TRT questo mese" await update.message.reply_text(reply_ore) else: