From d04f71d78217fdd29bb6c7a52cd2e0f4bbfac1d1 Mon Sep 17 00:00:00 2001 From: Hykilpikonna Date: Sun, 22 Nov 2020 18:11:56 -0500 Subject: [PATCH] [+] Implement disable command --- src/commands.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/commands.py b/src/commands.py index 0a1fbda..4b3eb42 100644 --- a/src/commands.py +++ b/src/commands.py @@ -240,3 +240,24 @@ def enable(update: Update, context: CallbackContext): def disable(update: Update, context: CallbackContext): chat = update.effective_chat user = database.checkUser(chat.id) + + # No args + if len(context.args) != 1: + return "Usage: /disable " + + # Check if name is running + name = context.args[0] + if user not in tasks or name not in tasks[user]: + return "*Error:* %s isn't enabled." % name + + # Stop and remove task + job = tasks[user][name] + job.enabled = False + job.schedule_removal() + tasks[user].pop(name, None) + database.userStatus[user]['enabledTasks'].remove(name) + database.save() + + return "Removed!" + +