video-stream/program/rmtrash.py

51 lines
1.5 KiB
Python
Raw Normal View History

2021-10-11 03:16:54 +00:00
# Copyright (C) 2021 By VeezMusicProject
import os
from pyrogram import Client, filters
from pyrogram.types import Message
2021-10-28 05:32:22 +00:00
from driver.filters import command, other_filters
2021-10-25 08:06:43 +00:00
from driver.decorators import sudo_users_only, errors
2021-10-11 03:16:54 +00:00
2021-10-25 08:06:43 +00:00
downloads = os.path.realpath("program/downloads")
2021-10-11 03:16:54 +00:00
raw = os.path.realpath(".")
2021-10-25 08:06:43 +00:00
@Client.on_message(command(["rmd", "clear"]) & ~filters.edited)
2021-10-11 03:16:54 +00:00
@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**")
2021-10-25 08:06:43 +00:00
2021-10-11 03:16:54 +00:00
2021-10-25 08:06:43 +00:00
@Client.on_message(command(["rmw", "clean"]) & ~filters.edited)
2021-10-11 03:16:54 +00:00
@errors
@sudo_users_only
async def clear_raw(_, message: Message):
ls_dir = os.listdir(raw)
if ls_dir:
for file in os.listdir(raw):
if file.endswith('.raw'):
os.remove(os.path.join(raw, file))
await message.reply_text("✅ **deleted all raw files**")
else:
await message.reply_text("❌ **no raw files**")
2021-10-25 08:06:43 +00:00
@Client.on_message(command(["cleanup"]) & ~filters.edited)
@errors
@sudo_users_only
async def cleanup(_, message: Message):
2021-10-11 03:16:54 +00:00
pth = os.path.realpath(".")
ls_dir = os.listdir(pth)
if ls_dir:
for dta in os.listdir(pth):
os.system("rm -rf *.raw *.jpg")
2021-10-25 08:06:43 +00:00
await message.reply_text("✅ **cleaned**")
2021-10-11 03:16:54 +00:00
else:
2021-10-25 08:06:43 +00:00
await message.reply_text("✅ **already cleaned**")