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:
parent
47ecd7da1f
commit
bd066e3ca7
1 changed files with 6 additions and 0 deletions
|
@ -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)\
|
||||
|
|
Loading…
Reference in a new issue