Cancel should also cancel the message listener

This commit is contained in:
Profitroll 2023-03-26 19:50:10 +02:00
parent 2a2ad9f96e
commit 43e71c95c4
2 changed files with 6 additions and 0 deletions

View File

@ -16,6 +16,10 @@ from modules import custom_filters
async def command_cancel(app: Client, msg: Message): async def command_cancel(app: Client, msg: Message):
col_tmp.delete_many({"user": msg.from_user.id, "sent": False}) col_tmp.delete_many({"user": msg.from_user.id, "sent": False})
col_spoilers.delete_many({"user": msg.from_user.id, "completed": False}) col_spoilers.delete_many({"user": msg.from_user.id, "completed": False})
try:
await app.listen.Cancel(filters.user(msg.from_user.id))
except:
pass
if col_applications.find_one({"user": msg.from_user.id}) is None: if col_applications.find_one({"user": msg.from_user.id}) is None:
await msg.reply_text( await msg.reply_text(
locale("cancel_reapply", "message", locale=msg.from_user), locale("cancel_reapply", "message", locale=msg.from_user),

View File

@ -64,6 +64,8 @@ async def cmd_message(app: Client, msg: Message):
locale("message_enter", "message", locale=msg.from_user) locale("message_enter", "message", locale=msg.from_user)
) )
message = await listen_message(app, msg.chat.id, timeout=None) message = await listen_message(app, msg.chat.id, timeout=None)
if message.text is not None and message.text == "/cancel":
return
sent = await app.forward_messages( sent = await app.forward_messages(
configGet("admin", "groups"), msg.chat.id, message.id configGet("admin", "groups"), msg.chat.id, message.id
) )