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/spoiler.py

51 lines
2.2 KiB
Python

from app import app
from pyrogram import filters
from pyrogram.types import Message, ReplyKeyboardMarkup
from pyrogram.client import Client
from classes.errors.holo_user import UserNotFoundError, UserInvalidError
from classes.holo_user import HoloUser
from modules.logging import logWrite
from modules.utils import locale
from modules.database import col_spoilers, col_applications
from modules import custom_filters
# Spoiler command ==============================================================================================================
@app.on_message(custom_filters.enabled_spoilers & ~filters.scheduled & filters.private & ~custom_filters.banned & filters.command(["spoiler"], prefixes=["/"]))
async def cmd_spoiler(app: Client, msg: Message):
try:
holo_user = HoloUser(msg.from_user)
except (UserInvalidError, UserNotFoundError):
return
if col_applications.find_one( {"user": holo_user.id} ) is None:
await msg.reply_text(locale("not_member", "message", locale=msg.from_user))
return
if holo_user.application_state()[0] != "fill" and holo_user.sponsorship_state()[0] != "fill":
if col_spoilers.find_one( {"user": holo_user.id, "completed": False} ) is None:
col_spoilers.insert_one(
{
"user": holo_user.id,
"completed": False,
"category": None,
"description": None,
"photo": None,
"video": None,
"audio": None,
"animation": None,
"document": None,
"caption": None,
"text": None
}
)
await msg.reply_text(locale("spoiler_started", "message", locale=msg.from_user), reply_markup=ReplyKeyboardMarkup(locale("spoiler_categories", "keyboard"), resize_keyboard=True, one_time_keyboard=True))
logWrite(f"User {msg.from_user.id} started creating new spoiler")
else:
await msg.reply_text(locale("spoiler_unfinished", "message", locale=msg.from_user))
# ==============================================================================================================================