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

19 lines
1.3 KiB
Python
Raw Normal View History

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-01-05 14:01:57 +02:00
# Cancel command ===============================================================================================================
2023-01-03 21:34:13 +02:00
@app.on_message((custom_filters.enabled_applications | custom_filters.enabled_sponsorships) & ~filters.scheduled & filters.command("cancel", prefixes=["/"]))
2022-12-27 14:36:54 +02:00
async def command_cancel(app: Client, msg: Message):
2023-01-10 13:07:40 +02:00
col_tmp.delete_many( {"user": msg.from_user.id, "sent": False} )
2023-01-04 20:58:54 +02:00
col_spoilers.delete_many( {"user": msg.from_user.id, "completed": False} )
2023-01-23 12:20:56 +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())
else:
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}")
# ==============================================================================================================================