From f7fdd11cfe65f430b936638d4e095d3889298208 Mon Sep 17 00:00:00 2001 From: Joan Date: Mon, 13 Nov 2023 17:38:51 +0100 Subject: [PATCH] Improving response message --- conjuntasbot/conjuntasbot.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/conjuntasbot/conjuntasbot.py b/conjuntasbot/conjuntasbot.py index ee22cdc..aba6a1b 100644 --- a/conjuntasbot/conjuntasbot.py +++ b/conjuntasbot/conjuntasbot.py @@ -486,11 +486,10 @@ async def handle_conjunta(update: Update, context: CallbackContext): quantity = 1 try: - my_quantity_left = quantity_left(conjunta_id) quantity = int(quantity) if quantity <= 0: raise ValueError - if limit is not None and quantity > limit_per_user or limit is not None and quantity > my_quantity_left: + if limit is not None and quantity > limit_per_user or limit is not None and quantity > quantity_left(conjunta_id): await update.message.reply_text("La cantidad deseada excede el límite por usuario de la conjunta o no quedan suficientes.") else: if user_name: @@ -504,6 +503,7 @@ async def handle_conjunta(update: Update, context: CallbackContext): worksheet = spreadsheet.worksheet(f"{product_name} - {conjunta_id}") worksheet.append_row([user_name, quantity, "SÍ" if socio else "NO"]) + my_quantity_left = quantity_left(conjunta_id) quantity_string = "unidades" if my_quantity_left > 1 else "unidad" message = f"Te has unido a la conjunta para '{product_name}' con {quantity} {quantity_string}." if my_quantity_left > 0: