From 111b101714f08d5be05879c331fa93ac4af25557 Mon Sep 17 00:00:00 2001 From: Ceda EI Date: Sun, 20 Jun 2021 18:42:25 +0530 Subject: [PATCH] Add /cancel --- bot.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/bot.py b/bot.py index 64ce667..de1946a 100755 --- a/bot.py +++ b/bot.py @@ -2,6 +2,7 @@ import os import os.path as pt +import shutil from telegram.ext import Updater, CommandHandler, MessageHandler, filters import config @@ -36,7 +37,11 @@ def on_finish(upd, ctx): def on_cancel(upd, ctx): - pass + user_id = upd.effective_chat.id + path = f"data/{user_id}" + if pt.isdir(path): + shutil.rmtree(f"data/{user_id}") + ctx.bot.send_message(upd.effective_chat.id, f"Cleared images") updater = Updater(token=config.API_KEY, use_context=True)