From 137b0ce4515abbdc0e9ae6d0ab52e405696b41d4 Mon Sep 17 00:00:00 2001 From: Joan Cano Date: Thu, 4 May 2023 14:34:14 +0200 Subject: [PATCH] Added error handling --- tesla-raffle/tesla-raffle.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tesla-raffle/tesla-raffle.py b/tesla-raffle/tesla-raffle.py index 597709e..0f7ba35 100644 --- a/tesla-raffle/tesla-raffle.py +++ b/tesla-raffle/tesla-raffle.py @@ -61,7 +61,11 @@ async def sorteo(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None: return logging.info("Empezando sorteo") - frase = update.message.text.split("/sorteo ")[1] + try: + frase = update.message.text.split("/sorteo ")[1] + except: + await context.bot.send_message(chat_id=update.effective_chat.id, text="Error al arrancar el sorteo, asegúrate de poner la frase.") + return global SORTEO_ACTIVO # Empezamos a leer mensajes SORTEO_ACTIVO = True