This commit is contained in:
harold 2025-05-05 17:02:20 +05:00
parent 55c2ab61d0
commit 7f59b35d62

View File

@ -7,13 +7,21 @@ from src.core.database import TgMessage, User, TgChat
def check_message_condition( def check_message_condition(
message: Message, message: Message,
) -> bool: ) -> bool:
conditions = ( if message.chat.type in [ChatType.PRIVATE, ChatType.BOT]:
message.chat.type not in [ChatType.PRIVATE, ChatType.BOT], return False
bool(message.from_user),
bool(message.text), if not message.from_user:
bool('bot' not in message.from_user.username.lower() if message.from_user.username else True), return False
)
return all(conditions) if not message.text:
return False
if message.from_user.username:
if 'bot' in message.from_user.username.lower():
return False
return True
def create_and_format_message( def create_and_format_message(