From c1306505a93bfb6ccfe7bdff0ca07a63ca94f3c4 Mon Sep 17 00:00:00 2001 From: Philotheephilix <110274378+Philotheephilix@users.noreply.github.com> Date: Tue, 2 May 2023 20:09:24 +0530 Subject: [PATCH] Fixed [Junk removal issue](https://github.com/Philotheephilix/Multi-funtional-telegram-bot/issues/2) Added junk_removal() function to remove all temporary pdf and image files from the host machine --- multi_bot.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/multi_bot.py b/multi_bot.py index 8010cb8..774113e 100644 --- a/multi_bot.py +++ b/multi_bot.py @@ -50,6 +50,16 @@ def convert(message): with open("merged.pdf", 'rb') as pdf_file: bot.send_document(message.chat.id, pdf_file) bot.reply_to(message, "PDF file sent") + def junk_removal(): + os.remove("merged\\merged.pdf") + print("merged pdf deleted....") + for i in a: + os.remove("tempimg\\"+i) + print("temp img is deleted") + for i in a: + os.remove("temppdf\\"+i+".pdf") + print("temp pdf is deleted..") + junk_removal() @bot.message_handler(commands=["check_email"]) def check_email(message): mail = imaplib.IMAP4_SSL("imap.gmail.com")