No username, no party

This commit is contained in:
Joan
2023-10-31 17:26:50 +01:00
parent 482222ec67
commit f617561c58

View File

@@ -367,21 +367,24 @@ async def handle_conjunta(update: Update, context: CallbackContext):
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:
cursor.execute("INSERT INTO conjunta_users (conjunta_id, user_id, user_name, quantity) VALUES (?, ?, ?, ?)",
(conjunta_id, user_id, user_name, quantity))
conn.commit()
if user_name:
cursor.execute("INSERT INTO conjunta_users (conjunta_id, user_id, user_name, quantity) VALUES (?, ?, ?, ?)",
(conjunta_id, user_id, user_name, quantity))
conn.commit()
socios_worksheet = spreadsheet.worksheet("Socios")
socio = socios_worksheet.find(user_name)
worksheet = spreadsheet.worksheet(f"{product_name} - {conjunta_id}")
worksheet.append_row([user_name, quantity, "" if socio else "NO"])
await update.message.reply_text(f"Te has unido a la conjunta para '{product_name}' con {quantity} unidades.")
try:
await update_conjunta(update, context, conjunta_id)
except Exception:
pass
socios_worksheet = spreadsheet.worksheet("Socios")
socio = socios_worksheet.find(user_name)
worksheet = spreadsheet.worksheet(f"{product_name} - {conjunta_id}")
worksheet.append_row([user_name, quantity, "" if socio else "NO"])
await update.message.reply_text(f"Te has unido a la conjunta para '{product_name}' con {quantity} unidades.")
try:
await update_conjunta(update, context, conjunta_id)
except Exception:
pass
else:
await update.message.reply_text("Por favor, tienes que ponerte un nick en Telegram para poder participar.")
except ValueError:
await update.message.reply_text("Por favor, introduce una cantidad válida.")
else: