1
Fork 0
mirror of https://github.com/RYGhub/royalnet.git synced 2024-11-23 19:44:20 +00:00

Handle correctly unpacking errors

This commit is contained in:
Steffo 2018-09-15 00:51:25 +02:00
parent 652db5895c
commit 0d5605d1c9

View file

@ -468,7 +468,7 @@ def parse_timestring(timestring: str) -> typing.Union[datetime.timedelta, dateti
def cmd_newevent(bot: Bot, update: Update):
try:
_, timestring, name_desc = update.message.text.split(" ", 2)
except (ValueError, IndexError):
except ValueError:
bot.send_message(update.message.chat.id, "⚠️ Sintassi del comando non valida.\n"
"Sintassi corretta:\n"
"```/newevent <timestamp|[[[anno-]mese-]giorno-]ore-minuti"
@ -477,7 +477,7 @@ def cmd_newevent(bot: Bot, update: Update):
return
try:
name, description = name_desc.split("\n", 1)
except IndexError:
except ValueError:
name = name_desc
description = None
# Parse the timestring