First commit
This commit is contained in:
19
bot/utils/auto_delete.py
Normal file
19
bot/utils/auto_delete.py
Normal file
@@ -0,0 +1,19 @@
|
||||
from asyncio import sleep
|
||||
from aiogram.exceptions import TelegramBadRequest
|
||||
|
||||
from bot import bot
|
||||
from middleware import logger
|
||||
|
||||
__all__ = ("auto_delete_message",)
|
||||
|
||||
async def auto_delete_message(chat_id: int, message_id: int, delay: int = 604800) -> None:
|
||||
"""
|
||||
Автоматически удаляет сообщение через указанный промежуток времени.
|
||||
По умолчанию — 7 суток (604800 секунд).
|
||||
"""
|
||||
await sleep(delay=delay)
|
||||
try:
|
||||
await bot.delete_message(chat_id=chat_id, message_id=message_id)
|
||||
logger.info("Закрепленное сообщение удалено")
|
||||
except TelegramBadRequest as e:
|
||||
logger.error(f"[ALL] Ошибка при автоудалении: {e}")
|
||||
Reference in New Issue
Block a user