2023-01-04 20:58:54 +02:00
|
|
|
from app import app
|
|
|
|
from pyrogram import filters
|
2023-01-05 15:34:02 +02:00
|
|
|
from pyrogram.types import Message, ReplyKeyboardMarkup
|
2023-01-04 20:58:54 +02:00
|
|
|
from pyrogram.client import Client
|
2023-01-06 16:49:51 +02:00
|
|
|
from classes.errors.holo_user import UserNotFoundError, UserInvalidError
|
|
|
|
from classes.holo_user import HoloUser
|
2023-01-04 22:58:44 +02:00
|
|
|
from modules.logging import logWrite
|
2023-01-04 20:58:54 +02:00
|
|
|
from modules.utils import locale
|
|
|
|
from modules.database import col_spoilers
|
|
|
|
from modules import custom_filters
|
|
|
|
|
|
|
|
# Spoiler command ==============================================================================================================
|
|
|
|
@app.on_message(custom_filters.member & ~filters.scheduled & filters.private & filters.command(["spoiler"], prefixes=["/"]))
|
|
|
|
async def cmd_spoiler(app: Client, msg: Message):
|
|
|
|
|
|
|
|
try:
|
|
|
|
holo_user = HoloUser(msg.from_user)
|
|
|
|
except (UserInvalidError, UserNotFoundError):
|
|
|
|
return
|
|
|
|
|
|
|
|
if holo_user.application_state()[0] != "fill" and holo_user.sponsorship_state()[0] != "fill":
|
|
|
|
|
|
|
|
if col_spoilers.find_one( {"user": msg.from_user.id, "completed": False} ) is None:
|
|
|
|
|
|
|
|
col_spoilers.insert_one(
|
|
|
|
{
|
|
|
|
"user": msg.from_user.id,
|
|
|
|
"completed": False,
|
2023-01-05 15:34:02 +02:00
|
|
|
"category": None,
|
2023-01-04 20:58:54 +02:00
|
|
|
"description": None,
|
|
|
|
"photo": None,
|
|
|
|
"video": None,
|
|
|
|
"animation": None,
|
2023-01-05 22:15:34 +02:00
|
|
|
"document": None,
|
2023-01-05 15:34:02 +02:00
|
|
|
"caption": None,
|
2023-01-04 20:58:54 +02:00
|
|
|
"text": None
|
|
|
|
}
|
|
|
|
)
|
|
|
|
|
2023-01-05 15:34:02 +02:00
|
|
|
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))
|
2023-01-04 22:58:44 +02:00
|
|
|
logWrite(f"User {msg.from_user.id} started creating new spoiler")
|
2023-01-04 20:58:54 +02:00
|
|
|
|
|
|
|
else:
|
|
|
|
await msg.reply_text(locale("spoiler_unfinished", "message", locale=msg.from_user))
|
|
|
|
# ==============================================================================================================================
|