From 8cee1b194692e2acd1bd8f804008e34a9c0ac7c8 Mon Sep 17 00:00:00 2001 From: Hykilpikonna Date: Sun, 22 Nov 2020 14:26:53 -0500 Subject: [PATCH] [+] Implement rm command --- src/commands.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/commands.py b/src/commands.py index a1539df..74d674b 100644 --- a/src/commands.py +++ b/src/commands.py @@ -82,7 +82,20 @@ def rm(update, context): chat = update.effective_chat user = database.checkUser(chat.id) + # No args + if len(context.args) != 1: + return "Usage: /rm " + # Check if name exists + name = context.args[0] + if name not in database.userRequests[user]: + return "%s doesn't exist, nothing changed." % name + + # Remove + database.userRequests[user].pop(name, None) + database.save() + + return "%s is successfully removed!" % name def nano(update, context):