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

Implemented date check for /calendar

This commit is contained in:
Fabio De Simone 2019-01-03 18:01:43 +01:00 committed by Stefano Pigozzi
parent 47ecd7da1f
commit bd066e3ca7

View file

@ -485,6 +485,8 @@ def cmd_newevent(bot: Bot, update: Update):
# Parse the timestring
try:
parsed_time = parse_timestring(timestring)
if parsed_time < datetime.datetime.now():
raise PastDateError()
except ValueError:
bot.send_message(update.message.chat.id, "⚠ Non è stato possibile leggere la data.\n"
"Sintassi corretta:\n"
@ -492,6 +494,10 @@ def cmd_newevent(bot: Bot, update: Update):
"|{numero}{w|d|h|m}> <nome>\n"
"[descrizione]```", parse_mode="Markdown")
return
except PastDateError:
bot.send_message(update.message.chat.id, "⚠ La data inserita è una data passata.\n"
"per favore inserisci una data futura.\n", parse_mode="Markdown")
return
# Create the event
session = db.Session()
telegram_user = session.query(db.Telegram)\