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

69 lines
2.4 KiB
Python
Raw Normal View History

2023-01-04 20:58:54 +02:00
from app import app
from pyrogram import filters
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
2023-01-23 19:25:03 +02:00
from modules.database import col_spoilers, col_applications
2023-01-04 20:58:54 +02:00
from modules import custom_filters
2023-03-09 17:25:06 +02:00
2023-01-04 20:58:54 +02:00
# Spoiler command ==============================================================================================================
2023-03-09 17:25:06 +02:00
@app.on_message(
custom_filters.enabled_spoilers
& ~filters.scheduled
& filters.private
& ~custom_filters.banned
& filters.command(["spoiler"], prefixes=["/"])
)
2023-01-04 20:58:54 +02:00
async def cmd_spoiler(app: Client, msg: Message):
try:
holo_user = HoloUser(msg.from_user)
except (UserInvalidError, UserNotFoundError):
return
2023-03-09 17:25:06 +02:00
if col_applications.find_one({"user": holo_user.id}) is None:
2023-01-23 12:29:58 +02:00
await msg.reply_text(locale("not_member", "message", locale=msg.from_user))
return
2023-03-09 17:25:06 +02:00
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:
2023-01-04 20:58:54 +02:00
col_spoilers.insert_one(
{
2023-01-23 19:25:03 +02:00
"user": holo_user.id,
2023-01-04 20:58:54 +02:00
"completed": False,
"category": None,
2023-01-04 20:58:54 +02:00
"description": None,
"photo": None,
"video": None,
2023-01-10 13:11:29 +02:00
"audio": None,
2023-01-04 20:58:54 +02:00
"animation": None,
2023-01-05 22:15:34 +02:00
"document": None,
"caption": None,
2023-03-09 17:25:06 +02:00
"text": None,
2023-01-04 20:58:54 +02:00
}
)
2023-03-09 17:25:06 +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:
2023-03-09 17:25:06 +02:00
await msg.reply_text(
locale("spoiler_unfinished", "message", locale=msg.from_user)
)
# ==============================================================================================================================