From fb3e6989a3b7462f0e860f8e738b9b7658adc820 Mon Sep 17 00:00:00 2001 From: hkc Date: Tue, 6 Feb 2024 12:05:14 +0300 Subject: [PATCH] Added auto-removal of the message --- nfuck/__init__.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/nfuck/__init__.py b/nfuck/__init__.py index b8521f3..dec5438 100644 --- a/nfuck/__init__.py +++ b/nfuck/__init__.py @@ -3,6 +3,7 @@ from aiogram import Dispatcher from aiogram.types import Message from aiogram.filters import Command from httpx import AsyncClient +from asyncio import sleep from nfuck.link_verifier import ( explain_verification, @@ -66,7 +67,7 @@ async def on_message(message: Message): detected_links.append((entity.url, confidence)) if detected_links: if message.from_user and message.chat.id not in SILENT_REMOVAL_IDS: - await message.reply( + msg = await message.reply( str.join( "\n", [ @@ -81,8 +82,13 @@ async def on_message(message: Message): ], ), f"Sender: {message.from_user.full_name} #{message.from_user.id} (@{message.from_user.username})", + "(message will be deleted in 10 seconds)" ], ), parse_mode="html", ) - await message.delete() + await message.delete() + await sleep(10) + await msg.delete() + else: + await message.delete()