From 30fc3d00895697dd3a6c1dc249cdf7a5895adafb Mon Sep 17 00:00:00 2001 From: Profitroll <47523801+profitrollgame@users.noreply.github.com> Date: Mon, 12 Dec 2022 10:13:58 +0100 Subject: [PATCH] Now using database for export --- modules/commands/applications.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/modules/commands/applications.py b/modules/commands/applications.py index a15203c..4b7578c 100644 --- a/modules/commands/applications.py +++ b/modules/commands/applications.py @@ -1,8 +1,10 @@ -from os import sep +from os import sep, makedirs, remove +from uuid import uuid1 from app import app, isAnAdmin from pyrogram import filters from pyrogram.enums.chat_action import ChatAction -from modules.utils import configGet, should_quote +from modules.utils import configGet, should_quote, jsonSave +from modules.database import col_applications # Applications command ========================================================================================================= @app.on_message(~ filters.scheduled & filters.command(["applications"], prefixes=["/"])) @@ -10,5 +12,12 @@ async def cmd_applications(app, msg): if (await isAnAdmin(msg.from_user.id)) or (msg.chat.id == configGet("admin_group")): await app.send_chat_action(msg.chat.id, ChatAction.UPLOAD_DOCUMENT) - await msg.reply_document(document=f"{configGet('data', 'locations')}{sep}applications.json", quote=should_quote(msg)) + filename = uuid1() + output = [] + for entry in col_applications.find(): + output.append(entry) + makedirs("tmp", exist_ok=True) + jsonSave(output, f"tmp{sep}{filename}.json") + await msg.reply_document(document=f"tmp{sep}{filename}.json", file_name="applications", quote=should_quote(msg)) + remove(f"tmp{sep}{filename}.json") # ============================================================================================================================== \ No newline at end of file