From 29a67eaecae3c7501545d4f4d79bcfe214158df9 Mon Sep 17 00:00:00 2001 From: Hykilpikonna Date: Sun, 22 Nov 2020 18:11:36 -0500 Subject: [PATCH] [+] Implement interval command --- src/commands.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/commands.py b/src/commands.py index b5553ee..454fa71 100644 --- a/src/commands.py +++ b/src/commands.py @@ -198,6 +198,25 @@ def interval(update: Update, context: CallbackContext): chat = update.effective_chat user = database.checkUser(chat.id) + # No args + if len(context.args) != 2: + return "Usage: /interval " + + # Check if name exists + name = context.args[0] + if name not in database.userRequests[user]: + return "*Error:* %s doesn't exist." % name + + # Validate the interval of the interval + i = int(context.args[1]) + if i < 40 or i > 60*60*24: + return "*Error:* %s is too long or too short. (Min: 40s, Max: 60 * 60 * 24s)" % i + + database.userRequests[user][name]['interval'] = i + database.save() + + return "Success!" + def enable(update: Update, context: CallbackContext): chat = update.effective_chat