diff --git a/telegram-application/src/core/tg_service/utils.py b/telegram-application/src/core/tg_service/utils.py index 2211722..498f4e7 100644 --- a/telegram-application/src/core/tg_service/utils.py +++ b/telegram-application/src/core/tg_service/utils.py @@ -7,13 +7,21 @@ from src.core.database import TgMessage, User, TgChat def check_message_condition( message: Message, ) -> bool: - conditions = ( - message.chat.type not in [ChatType.PRIVATE, ChatType.BOT], - bool(message.from_user), - bool(message.text), - bool('bot' not in message.from_user.username.lower() if message.from_user.username else True), - ) - return all(conditions) + if message.chat.type in [ChatType.PRIVATE, ChatType.BOT]: + return False + + if not message.from_user: + return False + + 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(