36 lines
1.5 KiB
Python
36 lines
1.5 KiB
Python
from app import app
|
|
from pyrogram import filters
|
|
from pyrogram.types import Message, ReplyKeyboardRemove
|
|
from pyrogram.client import Client
|
|
from modules.utils import should_quote, logWrite, locale
|
|
from modules.database import col_tmp, col_spoilers, col_applications
|
|
from modules import custom_filters
|
|
|
|
|
|
# Cancel command ===============================================================================================================
|
|
@app.on_message(
|
|
(custom_filters.enabled_applications | custom_filters.enabled_sponsorships)
|
|
& ~filters.scheduled
|
|
& filters.command("cancel", prefixes=["/"])
|
|
& ~custom_filters.banned
|
|
)
|
|
async def command_cancel(app: Client, msg: Message):
|
|
col_tmp.delete_many({"user": msg.from_user.id, "sent": False})
|
|
col_spoilers.delete_many({"user": msg.from_user.id, "completed": False})
|
|
if col_applications.find_one({"user": msg.from_user.id}) is None:
|
|
await msg.reply_text(
|
|
locale("cancel_reapply", "message", locale=msg.from_user),
|
|
quote=should_quote(msg),
|
|
reply_markup=ReplyKeyboardRemove(),
|
|
)
|
|
else:
|
|
await msg.reply_text(
|
|
locale("cancel", "message", locale=msg.from_user),
|
|
quote=should_quote(msg),
|
|
reply_markup=ReplyKeyboardRemove(),
|
|
)
|
|
logWrite(f"Cancelling all ongoing tmp operations for {msg.from_user.id}")
|
|
|
|
|
|
# ==============================================================================================================================
|