No username, no party
This commit is contained in:
@@ -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):
|
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.")
|
await update.message.reply_text("La cantidad deseada excede el límite por usuario de la conjunta o no quedan suficientes.")
|
||||||
else:
|
else:
|
||||||
cursor.execute("INSERT INTO conjunta_users (conjunta_id, user_id, user_name, quantity) VALUES (?, ?, ?, ?)",
|
if user_name:
|
||||||
(conjunta_id, user_id, user_name, quantity))
|
cursor.execute("INSERT INTO conjunta_users (conjunta_id, user_id, user_name, quantity) VALUES (?, ?, ?, ?)",
|
||||||
conn.commit()
|
(conjunta_id, user_id, user_name, quantity))
|
||||||
|
conn.commit()
|
||||||
|
|
||||||
socios_worksheet = spreadsheet.worksheet("Socios")
|
socios_worksheet = spreadsheet.worksheet("Socios")
|
||||||
socio = socios_worksheet.find(user_name)
|
socio = socios_worksheet.find(user_name)
|
||||||
|
|
||||||
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.")
|
await update.message.reply_text(f"Te has unido a la conjunta para '{product_name}' con {quantity} unidades.")
|
||||||
try:
|
try:
|
||||||
await update_conjunta(update, context, conjunta_id)
|
await update_conjunta(update, context, conjunta_id)
|
||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
else:
|
||||||
|
await update.message.reply_text("Por favor, tienes que ponerte un nick en Telegram para poder participar.")
|
||||||
except ValueError:
|
except ValueError:
|
||||||
await update.message.reply_text("Por favor, introduce una cantidad válida.")
|
await update.message.reply_text("Por favor, introduce una cantidad válida.")
|
||||||
else:
|
else:
|
||||||
|
|||||||
Reference in New Issue
Block a user