74 lines
2.3 KiB
Python
74 lines
2.3 KiB
Python
# from aiogram import BaseMiddleware
|
||
# from aiogram.types import TelegramObject, Update
|
||
#
|
||
# from typing import Callable, Dict, Any, Awaitable
|
||
# from utils.defs import delete_msg
|
||
# from utils.db import Postgres, Redis
|
||
# from templates.message import send_preview
|
||
#
|
||
#
|
||
# class DeleteMessage(BaseMiddleware):
|
||
# """
|
||
# Мидлвари удаляющая сообщения с бан вордами
|
||
# """
|
||
#
|
||
# async def __call__(
|
||
# self,
|
||
# handler: Callable[[TelegramObject, Dict[str, Any]], Awaitable[Any]],
|
||
# event: Update,
|
||
# data: Dict[str, Any]
|
||
# ) -> Any:
|
||
# if not event.message:
|
||
# return await handler(event, data)
|
||
# if not (event.message.chat.type == 'group' or
|
||
# event.message.chat.type == 'supergroup'):
|
||
# return await handler(event, data)
|
||
#
|
||
# ban = False
|
||
# r = Redis()
|
||
# p = Postgres()
|
||
#
|
||
# ban_words = await r.get_list(
|
||
# key='ban_words'
|
||
# )
|
||
# if not ban_words:
|
||
# ban_words = await p.get_data(
|
||
# table_name='ban_words'
|
||
# )
|
||
# ban_words = [word['word'] for word in ban_words]
|
||
# await r.delete_key(
|
||
# 'ban_words'
|
||
# )
|
||
# await r.update_list(
|
||
# 'ban_words',
|
||
# *ban_words
|
||
# )
|
||
#
|
||
# for ban_word in ban_words:
|
||
# print(ban_word)
|
||
# if ban_word in event.message.text.lower():
|
||
# print(event.message.text.lower(), 'нашёл')
|
||
# ban = True
|
||
#
|
||
# if ban:
|
||
# await delete_msg(
|
||
# msg=event.message
|
||
# )
|
||
# message_data = await p.get_data(
|
||
# table_name='message'
|
||
# )
|
||
#
|
||
# if event.message.from_user.username:
|
||
# username = f'@{event.message.from_user.username}'
|
||
# else:
|
||
# username = event.message.from_user.full_name
|
||
#
|
||
# if message_data[0]['included']:
|
||
# await send_preview(
|
||
# chat_id=event.message.chat.id,
|
||
# message_data=message_data[0],
|
||
# username=username
|
||
# )
|
||
#
|
||
# return await handler(event, data)
|