2022-12-23 02:40:23 +02:00
|
|
|
from app import app
|
|
|
|
from pyrogram import filters
|
2023-01-05 14:12:22 +02:00
|
|
|
from pyrogram.types import Message, ReplyKeyboardRemove
|
2022-12-27 14:36:54 +02:00
|
|
|
from pyrogram.client import Client
|
2023-01-03 14:04:10 +02:00
|
|
|
from modules.utils import should_quote, logWrite, locale
|
2023-01-23 12:20:56 +02:00
|
|
|
from modules.database import col_tmp, col_spoilers, col_applications
|
2023-01-03 21:34:13 +02:00
|
|
|
from modules import custom_filters
|
2022-12-23 02:40:23 +02:00
|
|
|
|
2023-03-09 17:25:06 +02:00
|
|
|
|
|
|
|
@app.on_message(
|
|
|
|
(custom_filters.enabled_applications | custom_filters.enabled_sponsorships)
|
|
|
|
& ~filters.scheduled
|
|
|
|
& filters.command("cancel", prefixes=["/"])
|
|
|
|
& ~custom_filters.banned
|
|
|
|
)
|
2022-12-27 14:36:54 +02:00
|
|
|
async def command_cancel(app: Client, msg: Message):
|
2023-03-09 17:25:06 +02:00
|
|
|
col_tmp.delete_many({"user": msg.from_user.id, "sent": False})
|
|
|
|
col_spoilers.delete_many({"user": msg.from_user.id, "completed": False})
|
2023-03-26 20:50:10 +03:00
|
|
|
try:
|
|
|
|
await app.listen.Cancel(filters.user(msg.from_user.id))
|
|
|
|
except:
|
|
|
|
pass
|
2023-03-09 17:25:06 +02:00
|
|
|
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(),
|
|
|
|
)
|
2023-01-23 12:20:56 +02:00
|
|
|
else:
|
2023-03-09 17:25:06 +02:00
|
|
|
await msg.reply_text(
|
|
|
|
locale("cancel", "message", locale=msg.from_user),
|
|
|
|
quote=should_quote(msg),
|
|
|
|
reply_markup=ReplyKeyboardRemove(),
|
|
|
|
)
|
2023-01-05 14:01:57 +02:00
|
|
|
logWrite(f"Cancelling all ongoing tmp operations for {msg.from_user.id}")
|