This repository has been archived on 2024-05-31. You can view files and clone it, but cannot push or open issues or pull requests.
Telegram/modules/commands/applications.py

23 lines
1.1 KiB
Python
Raw Normal View History

2022-12-12 11:13:58 +02:00
from os import sep, makedirs, remove
from uuid import uuid1
2022-12-05 19:49:51 +02:00
from app import app, isAnAdmin
from pyrogram import filters
from pyrogram.enums.chat_action import ChatAction
2022-12-12 11:13:58 +02:00
from modules.utils import configGet, should_quote, jsonSave
from modules.database import col_applications
2022-12-05 19:49:51 +02:00
# Applications command =========================================================================================================
@app.on_message(~ filters.scheduled & filters.command(["applications"], prefixes=["/"]))
async def cmd_applications(app, msg):
2022-12-15 15:31:42 +02:00
if await isAnAdmin(msg.from_user.id) is True:
2022-12-05 19:49:51 +02:00
await app.send_chat_action(msg.chat.id, ChatAction.UPLOAD_DOCUMENT)
2022-12-12 11:13:58 +02:00
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")
2022-12-05 19:49:51 +02:00
# ==============================================================================================================================