Improving response message
This commit is contained in:
@@ -486,10 +486,11 @@ async def handle_conjunta(update: Update, context: CallbackContext):
|
|||||||
quantity = 1
|
quantity = 1
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
my_quantity_left = quantity_left(conjunta_id)
|
||||||
quantity = int(quantity)
|
quantity = int(quantity)
|
||||||
if quantity <= 0:
|
if quantity <= 0:
|
||||||
raise ValueError
|
raise ValueError
|
||||||
if limit is not None and quantity > limit_per_user or limit is not None and quantity > quantity_left(conjunta_id):
|
if limit is not None and quantity > limit_per_user or limit is not None and quantity > my_quantity_left:
|
||||||
await update.message.reply_text("La cantidad deseada excede el límite por usuario de la conjunta o no quedan suficientes.")
|
await update.message.reply_text("La cantidad deseada excede el límite por usuario de la conjunta o no quedan suficientes.")
|
||||||
else:
|
else:
|
||||||
if user_name:
|
if user_name:
|
||||||
@@ -503,7 +504,14 @@ async def handle_conjunta(update: Update, context: CallbackContext):
|
|||||||
worksheet = spreadsheet.worksheet(f"{product_name} - {conjunta_id}")
|
worksheet = spreadsheet.worksheet(f"{product_name} - {conjunta_id}")
|
||||||
worksheet.append_row([user_name, quantity, "SÍ" if socio else "NO"])
|
worksheet.append_row([user_name, quantity, "SÍ" if socio else "NO"])
|
||||||
|
|
||||||
await update.message.reply_text(f"Te has unido a la conjunta para '{product_name}' con {quantity} unidades.")
|
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:
|
||||||
|
message += f"\n\n¡Todavía quedan {my_quantity_left} {quantity_string} disponibles!"
|
||||||
|
else:
|
||||||
|
message += f"\n\n¡Ya no quedan unidades disponibles!"
|
||||||
|
|
||||||
|
await update.message.reply_text(message)
|
||||||
await send_message_to_admins(update, context, f"@{user_name} se ha apuntado a la conjunta {product_name} - {conjunta_id} con {quantity} unidades")
|
await send_message_to_admins(update, context, f"@{user_name} se ha apuntado a la conjunta {product_name} - {conjunta_id} con {quantity} unidades")
|
||||||
try:
|
try:
|
||||||
await update_conjunta(update, context, conjunta_id)
|
await update_conjunta(update, context, conjunta_id)
|
||||||
|
|||||||
Reference in New Issue
Block a user