From b0b24567f5bd05c5e21416a27962d05f7c971639 Mon Sep 17 00:00:00 2001 From: levina <82658782+levina-lab@users.noreply.github.com> Date: Fri, 10 Sep 2021 20:21:48 +0700 Subject: [PATCH] added raw cleaner delete any downloaded file & raw file by executing the cleaner command --- bot/rmtrash.py | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 bot/rmtrash.py diff --git a/bot/rmtrash.py b/bot/rmtrash.py new file mode 100644 index 0000000..6d31078 --- /dev/null +++ b/bot/rmtrash.py @@ -0,0 +1,32 @@ +import os +from pyrogram import Client, filters +from pyrogram.types import Message +from helpers.filters import command +from helpers.decorators import sudo_users_only, errors + +downloads = os.path.realpath("downloads") +raw = os.path.realpath("raw_files") + +@Client.on_message(command(["rmd", "cleardl"]) & ~filters.edited) +@errors +@sudo_users_only +async def clear_downloads(_, message: Message): + ls_dir = os.listdir(downloads) + if ls_dir: + for file in os.listdir(downloads): + os.remove(os.path.join(downloads, file)) + await message.reply_text("✅ **deleted all downloaded files**") + else: + await message.reply_text("❌ **no files downloaded**") + +@Client.on_message(command(["clean", "wipe", "rmw"]) & ~filters.edited) +@errors +@sudo_users_only +async def clear_raw(_, message: Message): + ls_dir = os.listdir(raw) + if ls_dir: + for file in os.listdir(raw): + os.remove(os.path.join(raw, file)) + await message.reply_text("✅ **deleted all raw files**") + else: + await message.reply_text("❌ **no raw files**")